about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-07-29 22:43:00 +0000
committerUlrich Drepper <drepper@redhat.com>2007-07-29 22:43:00 +0000
commitc5705565e5eca6b3c3e65715f5480617337ffc1d (patch)
treeb7c7dcf47fd7ce41a45d690f692cdc5f4cbd4c33
parent44f08a6ecc9d04fbb97475ebb99eaec26be36f90 (diff)
downloadglibc-c5705565e5eca6b3c3e65715f5480617337ffc1d.tar.gz
glibc-c5705565e5eca6b3c3e65715f5480617337ffc1d.tar.xz
glibc-c5705565e5eca6b3c3e65715f5480617337ffc1d.zip
* sysdeps/unix/sysv/linux/bits/sched.h (__CPU_ZERO_S): Optimize
	using gcc builtin.
	(__CPU_EQUAL_S): Likewise.
-rw-r--r--ChangeLog4
-rw-r--r--sysdeps/unix/sysv/linux/bits/sched.h16
2 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 59fbdab24a..f875458669 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-07-29  Ulrich Drepper  <drepper@redhat.com>
 
+	* sysdeps/unix/sysv/linux/bits/sched.h (__CPU_ZERO_S): Optimize
+	using gcc builtin.
+	(__CPU_EQUAL_S): Likewise.
+
 	* posix/Makefile (routines): Add sched_cpualloc and sched_cpufree.
 	(tests): Add tst-cpuset.
 	* posix/sched_cpualloc.c: New file.
diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h
index b19822c4a3..5eaa2fe528 100644
--- a/sysdeps/unix/sysv/linux/bits/sched.h
+++ b/sysdeps/unix/sysv/linux/bits/sched.h
@@ -104,7 +104,7 @@ struct __sched_param
 # define __CPU_SETSIZE	1024
 # define __NCPUBITS	(8 * sizeof (__cpu_mask))
 
-/* Type for array elements in 'cpu_set'.  */
+/* Type for array elements in 'cpu_set_t'.  */
 typedef unsigned long int __cpu_mask;
 
 /* Basic access functions.  */
@@ -118,7 +118,11 @@ typedef struct
 } cpu_set_t;
 
 /* Access functions for CPU masks.  */
-# define __CPU_ZERO_S(setsize, cpusetp) \
+# if __GNUC_PREREQ (2, 91)
+#  define __CPU_ZERO_S(setsize, cpusetp) \
+  do __builtin_memset (cpusetp, '\0', setsize); while (0)
+# else
+#  define __CPU_ZERO_S(setsize, cpusetp) \
   do {									      \
     size_t __i;								      \
     size_t __imax = (setsize) / sizeof (__cpu_mask);			      \
@@ -126,6 +130,7 @@ typedef struct
     for (__i = 0; __i < __imax; ++__i)					      \
       __arr->__bits[__i] = 0;						      \
   } while (0)
+# endif
 # define __CPU_SET_S(cpu, setsize, cpusetp) \
   ({ size_t __cpu = (cpu);						      \
      __cpu < 8 * (setsize)						      \
@@ -142,7 +147,11 @@ typedef struct
 # define __CPU_COUNT_S(setsize, cpusetp) \
   __sched_cpucount (setsize, cpusetp)
 
-# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
+# if __GNUC_PREREQ (2, 91)
+#  define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
+  (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
+# else
+#  define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
   ({ cpu_set_t *__arr1 = (cpusetp1);					      \
      cpu_set_t *__arr2 = (cpusetp2);					      \
      size_t __imax = (setsize) / sizeof (__cpu_mask);			      \
@@ -151,6 +160,7 @@ typedef struct
        if (__arr1->__bits[__i] != __arr2->__bits[__i])			      \
 	 break;								      \
      __i == __imax; })
+# endif
 
 # define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
   ({ cpu_set_t *__dest = (destset);					      \