1 // SPDX-License-Identifier: LGPL-2.1
2 // Definitions taken from glibc for use with older systems, same licensing.
3 #ifndef _CPU_SET_SCHED_PERF_H
4 #define _CPU_SET_SCHED_PERF_H
11 #if __GNUC_PREREQ (2, 91)
12 # define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
13 (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
15 # define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
17 ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
18 const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
19 size_t __imax = (setsize) / sizeof (__cpu_mask); \
21 for (__i = 0; __i < __imax; ++__i) \
22 if (__arr1[__i] != __arr2[__i]) \
26 #endif // __CPU_EQUAL_S
28 #define CPU_EQUAL(cpusetp1, cpusetp2) \
29 __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
34 #define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
36 ({ cpu_set_t *__dest = (destset); \
37 const __cpu_mask *__arr1 = (srcset1)->__bits; \
38 const __cpu_mask *__arr2 = (srcset2)->__bits; \
39 size_t __imax = (setsize) / sizeof (__cpu_mask); \
41 for (__i = 0; __i < __imax; ++__i) \
42 ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
46 #define CPU_OR(destset, srcset1, srcset2) \
47 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
50 #endif // _CPU_SET_SCHED_PERF_H