about summary refs log tree commit diff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/bits/sched.h57
1 files changed, 46 insertions, 11 deletions
diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h
index d3c21ae3a2..b19822c4a3 100644
--- a/sysdeps/unix/sysv/linux/bits/sched.h
+++ b/sysdeps/unix/sysv/linux/bits/sched.h
@@ -118,27 +118,62 @@ typedef struct
 } cpu_set_t;
 
 /* Access functions for CPU masks.  */
-# define __CPU_ZERO(cpusetp) \
+# define __CPU_ZERO_S(setsize, cpusetp) \
   do {									      \
-    unsigned int __i;							      \
+    size_t __i;								      \
+    size_t __imax = (setsize) / sizeof (__cpu_mask);			      \
     cpu_set_t *__arr = (cpusetp);					      \
-    for (__i = 0; __i < sizeof (cpu_set_t) / sizeof (__cpu_mask); ++__i)      \
+    for (__i = 0; __i < __imax; ++__i)					      \
       __arr->__bits[__i] = 0;						      \
   } while (0)
-# define __CPU_SET(cpu, cpusetp) \
-  ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu))
-# define __CPU_CLR(cpu, cpusetp) \
-  ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu))
-# define __CPU_ISSET(cpu, cpusetp) \
-  (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0)
+# define __CPU_SET_S(cpu, setsize, cpusetp) \
+  ({ size_t __cpu = (cpu);						      \
+     __cpu < 8 * (setsize)						      \
+     ? ((cpusetp)->__bits[__CPUELT (__cpu)] |= __CPUMASK (__cpu)) : 0; })
+# define __CPU_CLR_S(cpu, setsize, cpusetp) \
+  ({ size_t __cpu = (cpu);						      \
+     __cpu < 8 * (setsize)						      \
+     ? ((cpusetp)->__bits[__CPUELT (__cpu)] &= ~__CPUMASK (__cpu)) : 0; })
+# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
+  ({ size_t __cpu = (cpu);						      \
+     __cpu < 8 * (setsize)						      \
+     ? (((cpusetp)->__bits[__CPUELT (__cpu)] & __CPUMASK (__cpu))) != 0 : 0; })
+
+# define __CPU_COUNT_S(setsize, cpusetp) \
+  __sched_cpucount (setsize, cpusetp)
+
+# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
+  ({ cpu_set_t *__arr1 = (cpusetp1);					      \
+     cpu_set_t *__arr2 = (cpusetp2);					      \
+     size_t __imax = (setsize) / sizeof (__cpu_mask);			      \
+     size_t __i;							      \
+     for (__i = 0; __i < __imax; ++__i)					      \
+       if (__arr1->__bits[__i] != __arr2->__bits[__i])			      \
+	 break;								      \
+     __i == __imax; })
+
+# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
+  ({ cpu_set_t *__dest = (destset);					      \
+     cpu_set_t *__arr1 = (srcset1);					      \
+     cpu_set_t *__arr2 = (srcset2);					      \
+     size_t __imax = (setsize) / sizeof (__cpu_mask);			      \
+     size_t __i;							      \
+     for (__i = 0; __i < __imax; ++__i)					      \
+       __dest->__bits[__i] = __arr1->__bits[__i] op __arr2->__bits[__i];      \
+     __dest; })
+
+# define __CPU_ALLOC_SIZE(count) \
+  ((((count) + __NCPUBITS - 1) / __NCPUBITS) * 8)
+# define __CPU_ALLOC(count) __sched_cpualloc (count)
+# define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
 
 __BEGIN_DECLS
 
 extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
   __THROW;
+extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
+extern void __sched_cpufree (cpu_set_t *__set) __THROW;
 
 __END_DECLS
 
-# define __CPU_COUNT(cpusetp) \
-  __sched_cpucount (sizeof (cpu_set_t), cpusetp)
 #endif