]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/cpu.h
2 * Copyright (C) 1996-2017 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
13 #include <errno.h> /* for ENOTSUP */
19 #if !HAVE_CPU_AFFINITY
20 /* failing replacements to minimize the number of if-HAVE_CPU_AFFINITYs */
21 #if !defined(__cpu_set_t_defined)
26 inline int sched_setaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
27 inline int sched_getaffinity(int, size_t, cpu_set_t
*) { return ENOTSUP
; }
28 #endif /* HAVE_CPU_AFFINITY */
30 #if !defined(CPU_SETSIZE)
34 #if !defined(CPU_ZERO)
35 #define CPU_ZERO(set) (void)0
39 #define CPU_SET(cpu, set) (void)0
43 #define CPU_CLR(cpu, set) (void)0
46 #if !defined(CPU_ISSET)
47 #define CPU_ISSET(cpu, set) false
50 // glibc prior to 2.6 lacks CPU_COUNT
52 #define CPU_COUNT(set) CpuCount(set)
53 /// CPU_COUNT replacement
55 CpuCount(const cpu_set_t
*set
)
58 for (int i
= 0; i
< CPU_SETSIZE
; ++i
) {
59 if (CPU_ISSET(i
, set
))
64 #endif /* CPU_COUNT */
66 // glibc prior to 2.7 lacks CPU_AND
68 #define CPU_AND(destset, srcset1, srcset2) CpuAnd((destset), (srcset1), (srcset2))
69 /// CPU_AND replacement
71 CpuAnd(cpu_set_t
*destset
, const cpu_set_t
*srcset1
, const cpu_set_t
*srcset2
)
73 for (int i
= 0; i
< CPU_SETSIZE
; ++i
) {
74 if (CPU_ISSET(i
, srcset1
) && CPU_ISSET(i
, srcset2
))
82 #endif /* SQUID_COMPAT_CPU_H */