]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/cpu.h
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
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
)
41 for (int i
= 0; i
< CPU_SETSIZE
; ++i
) {
42 if (CPU_ISSET(i
, srcset1
) && CPU_ISSET(i
, srcset2
))
50 #else /* HAVE_CPU_AFFINITY */
53 #include <errno.h> /* for ENOTSUP */
56 /* 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 #define CPU_CLR(cpu, set) (void)0
66 inline int sched_setaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
67 inline int sched_getaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
69 #endif /* HAVE_CPU_AFFINITY */
71 #endif /* SQUID_COMPAT_CPU_H */