]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/cpu.h
9 #ifndef SQUID_COMPAT_CPU_H
10 #define SQUID_COMPAT_CPU_H
18 // glibc prior to 2.6 lacks CPU_COUNT
20 #define CPU_COUNT(set) CpuCount(set)
21 /// CPU_COUNT replacement
23 CpuCount(const cpu_set_t
*set
)
26 for (int i
= 0; i
< CPU_SETSIZE
; ++i
) {
27 if (CPU_ISSET(i
, set
))
32 #endif /* CPU_COUNT */
34 // glibc prior to 2.7 lacks CPU_AND
36 #define CPU_AND(destset, srcset1, srcset2) CpuAnd((destset), (srcset1), (srcset2))
37 /// CPU_AND replacement
39 CpuAnd(cpu_set_t
*destset
, const cpu_set_t
*srcset1
, const cpu_set_t
*srcset2
)
42 for (int i
= 0; i
< CPU_SETSIZE
; ++i
) {
43 if (CPU_ISSET(i
, srcset1
) && CPU_ISSET(i
, srcset2
))
49 #else /* HAVE_CPU_AFFINITY */
52 #include <errno.h> /* for ENOTSUP */
55 /* failing replacements to minimize the number of if-HAVE_CPU_AFFINITYs */
61 #define CPU_COUNT(set) 0
62 #define CPU_AND(destset, srcset1, srcset2) (void)0
63 #define CPU_ZERO(set) (void)0
64 #define CPU_SET(cpu, set) (void)0
65 inline int sched_setaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
66 inline int sched_getaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
68 #endif /* HAVE_CPU_AFFINITY */
70 #endif /* SQUID_COMPAT_CPU_H */