Skip to content

Commit

Permalink
* sysdeps/unix/sysv/linux/bits/sched.h (__CPU_ZERO_S): Optimize
Browse files Browse the repository at this point in the history
	using gcc builtin.
	(__CPU_EQUAL_S): Likewise.
  • Loading branch information
Ulrich Drepper committed Jul 29, 2007
1 parent 44f08a6 commit c570556
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
16 changes: 13 additions & 3 deletions sysdeps/unix/sysv/linux/bits/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -118,14 +118,19 @@ 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); \
cpu_set_t *__arr = (cpusetp); \
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) \
Expand All @@ -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); \
Expand All @@ -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); \
Expand Down

0 comments on commit c570556

Please sign in to comment.