]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix build errors in cpuafinity.cc
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 24 Nov 2015 06:36:50 +0000 (22:36 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 24 Nov 2015 06:36:50 +0000 (22:36 -0800)
So OS provide stub sched.h which contain various amounts of the CPU_*
macro gadgets but not working sched_setaffinity / sched_getaffinity.

We need to check for each macro separately and limit the
HAVE_CPU_AFFINITY protection to the syscalls which configure actually
checked for.

compat/cpu.h

index 5579a76e4a8748028c8534060aad94996bd7348c..14b688714792ad2d53ae3ffd12831560944220d9 100644 (file)
@@ -9,12 +9,38 @@
 #ifndef SQUID_COMPAT_CPU_H
 #define SQUID_COMPAT_CPU_H
 
-#if HAVE_CPU_AFFINITY
-
+#if HAVE_ERRNO_H
+#include <errno.h> /* for ENOTSUP */
+#endif
 #if HAVE_SCHED_H
 #include <sched.h>
 #endif
 
+#if !HAVE_CPU_AFFINITY
+/* failing replacements to minimize the number of if-HAVE_CPU_AFFINITYs */
+typedef struct {
+    int bits;
+} cpu_set_t;
+inline int sched_setaffinity(int, size_t, cpu_set_t *) { return ENOTSUP; }
+inline int sched_getaffinity(int, size_t, cpu_set_t *) { return ENOTSUP; }
+#endif /* HAVE_CPU_AFFINITY */
+
+#if !defined(CPU_SETSIZE)
+#define CPU_SETSIZE 0
+#endif
+
+#if !defined(CPU_ZERO)
+#define CPU_ZERO(set) (void)0
+#endif
+
+#if !defined(CPU_SET)
+#define CPU_SET(cpu, set) (void)0
+#endif
+
+#if !defined(CPU_CLR)
+#define CPU_CLR(cpu, set) (void)0
+#endif
+
 // glibc prior to 2.6 lacks CPU_COUNT
 #ifndef CPU_COUNT
 #define CPU_COUNT(set) CpuCount(set)
@@ -47,26 +73,5 @@ CpuAnd(cpu_set_t *destset, const cpu_set_t *srcset1, const cpu_set_t *srcset2)
 }
 #endif /* CPU_AND */
 
-#else /* HAVE_CPU_AFFINITY */
-
-#if HAVE_ERRNO_H
-#include <errno.h> /* for ENOTSUP */
-#endif
-
-/* failing replacements to minimize the number of if-HAVE_CPU_AFFINITYs */
-typedef struct {
-    int bits;
-} cpu_set_t;
-#define CPU_SETSIZE 0
-#define CPU_COUNT(set) 0
-#define CPU_AND(destset, srcset1, srcset2) (void)0
-#define CPU_ZERO(set) (void)0
-#define CPU_SET(cpu, set) (void)0
-#define CPU_CLR(cpu, set) (void)0
-inline int sched_setaffinity(int, size_t, cpu_set_t *) { return ENOTSUP; }
-inline int sched_getaffinity(int, size_t, cpu_set_t *) { return ENOTSUP; }
-
-#endif /* HAVE_CPU_AFFINITY */
-
 #endif /* SQUID_COMPAT_CPU_H */