Skip to content

Commit

Permalink
Fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Johnson committed Oct 2, 2012
1 parent 23549c5 commit 42d1f75
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/affinity5.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,31 @@

#include "test.h"

typedef union
{
/* Violates opacity */
cpu_set_t cpuset;
unsigned long int bits; /* To stop GCC complaining about %lx args to printf */
} cpuset_to_ulint;

void *
mythread(void * arg)
{
HANDLE threadH = GetCurrentThread();
cpu_set_t *parentCpus = (cpu_set_t*) arg;
cpu_set_t threadCpus;
DWORD_PTR vThreadMask;
unsigned long int a, b; /* To stop GCC complaining about %lx args to printf */
cpuset_to_ulint a, b;

assert(pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &threadCpus) == 0);
assert(CPU_EQUAL(parentCpus, &threadCpus));
vThreadMask = SetThreadAffinityMask(threadH, (*(PDWORD_PTR)&threadCpus) /* Violating Opacity */);
assert(vThreadMask != 0);
assert(memcmp(&vThreadMask, &threadCpus, sizeof(DWORD_PTR)) == 0);
printf("Parent/Thread CPU affinity = 0x%lx/0x%lx\n",
a = (*(unsigned long int*)&parentCpus) /* Violating Opacity */,
b = (*(unsigned long int*)&threadCpus)) /* Violating Opacity */;
a.cpuset = *parentCpus;
b.cpuset = threadCpus;
/* Violates opacity */
printf("CPU affinity: Parent/Thread = 0x%lx/0x%lx\n", a.bits, b.bits);

return (void*) 0;
}
Expand Down

0 comments on commit 42d1f75

Please sign in to comment.