This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi!
alpha (ev67), ia64 and powerpc (power5 and later) implement popcount
in hardware. For alpha I have used inline assembly, because
__builtin_popcount would only expand to ctpop if the selected gcc
arch is ev67, which isn't sure. Calling libgcc function there is not a good
idea. On ia64 we can use it unconditionally, for ppc only for power5 and
later, but inline asm would be larger there, so I use the builtin guarded
with predefined macro for power5 and later.
glibc build supports only GCC 3.4 and later, so __builtin_popcountl
is supported.
2007-07-17 Jakub Jelinek <jakub@redhat.com>
* sysdeps/alpha/alphaev67/sched_cpucount.c: New file.
* sysdeps/ia64/sched_cpucount.c: New file.
* sysdeps/powerpc/sched_cpucount.c: New file.
--- libc/sysdeps/alpha/alphaev67/sched_cpucount.c.jj 2007-07-17 22:21:33.000000000 +0200
+++ libc/sysdeps/alpha/alphaev67/sched_cpucount.c 2007-07-17 22:22:37.000000000 +0200
@@ -0,0 +1,24 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define POPCNT(l) \
+ ({ __cpu_mask r; \
+ asm ("ctpop %1, %0" : "=r" (r) : "0" (l)); \
+ r; })
+
+#include <posix/sched_cpucount.c>
--- libc/sysdeps/ia64/sched_cpucount.c.jj 2007-07-17 22:21:33.000000000 +0200
+++ libc/sysdeps/ia64/sched_cpucount.c 2007-07-17 22:25:50.000000000 +0200
@@ -0,0 +1,21 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define POPCNT(l) __builtin_popcountl (l)
+
+#include <posix/sched_cpucount.c>
--- libc/sysdeps/powerpc/sched_cpucount.c.jj 2007-07-17 22:21:33.000000000 +0200
+++ libc/sysdeps/powerpc/sched_cpucount.c 2007-07-17 22:34:26.000000000 +0200
@@ -0,0 +1,23 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifdef _ARCH_PWR5
+# define POPCNT(l) __builtin_popcountl (l)
+#endif
+
+#include <posix/sched_cpucount.c>
Jakub
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |