]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/cpu.h
1 #ifndef SQUID_COMPAT_CPU_H
2 #define SQUID_COMPAT_CPU_H
10 // glibc prior to 2.6 lacks CPU_COUNT
12 #define CPU_COUNT(set) CpuCount(set)
13 /// CPU_COUNT replacement
15 CpuCount(const cpu_set_t
*set
)
18 for (int i
= 0; i
< CPU_SETSIZE
; ++i
) {
19 if (CPU_ISSET(i
, set
))
24 #endif /* CPU_COUNT */
26 // glibc prior to 2.7 lacks CPU_AND
28 #define CPU_AND(destset, srcset1, srcset2) CpuAnd((destset), (srcset1), (srcset2))
29 /// CPU_AND replacement
31 CpuAnd(cpu_set_t
*destset
, const cpu_set_t
*srcset1
, const cpu_set_t
*srcset2
)
33 for (int i
= 0; i
< CPU_SETSIZE
; ++i
) {
34 if (CPU_ISSET(i
, srcset1
) && CPU_ISSET(i
, srcset2
))
42 #else /* HAVE_CPU_AFFINITY */
45 #include <errno.h> /* for ENOTSUP */
48 /* failing replacements to minimize the number of if-HAVE_CPU_AFFINITYs */
53 #define CPU_COUNT(set) 0
54 #define CPU_AND(destset, srcset1, srcset2) (void)0
55 #define CPU_ZERO(set) (void)0
56 #define CPU_SET(cpu, set) (void)0
57 #define CPU_CLR(cpu, set) (void)0
58 inline int sched_setaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
59 inline int sched_getaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
61 #endif /* HAVE_CPU_AFFINITY */
63 #endif /* SQUID_COMPAT_CPU_H */