From 7aba0fdb9e1a77935a4e5ca0cfaedebd285222e7 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Tue, 19 Oct 2010 22:16:57 -0600 Subject: [PATCH] Do not zero the destination set in CpuAnd() replacement for CPU_AND() because the destination set may be one of the source sets. This fixes ERROR: invalid CPU affinity for process PID 17935, may be caused by an invalid core in 'cpu_affinity_map' or by external affinity restrictions errors on systems with partial CPU affinity support lacking their own CPU_AND. based on 3p2-plus r10834. --- compat/cpu.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compat/cpu.h b/compat/cpu.h index 9e58847b82..cc5530c687 100644 --- a/compat/cpu.h +++ b/compat/cpu.h @@ -38,10 +38,11 @@ CpuCount(const cpu_set_t *set) inline void CpuAnd(cpu_set_t *destset, const cpu_set_t *srcset1, const cpu_set_t *srcset2) { - CPU_ZERO(destset); for (int i = 0; i < CPU_SETSIZE; ++i) { if (CPU_ISSET(i, srcset1) && CPU_ISSET(i, srcset2)) CPU_SET(i, destset); + else + CPU_CLR(i, destset); } } #endif /* CPU_AND */ @@ -61,6 +62,7 @@ typedef struct { #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; } -- 2.47.2