nptl: Change tst-typesizes to _Static_assert
[glibc.git] / posix / tst-cpuset.c
blobd736793222af5ec6a83e3d6e81f91b468f174243
1 #include <sched.h>
2 #include <stdio.h>
4 static int
5 do_test (void)
7 int result = 0;
9 cpu_set_t s1;
10 cpu_set_t s2;
11 cpu_set_t s3;
13 CPU_ZERO (&s1);
14 CPU_SET (0, &s1);
16 CPU_ZERO (&s2);
17 CPU_SET (0, &s2);
18 CPU_SET (1, &s2);
20 CPU_AND (&s3, &s1, &s2);
21 if (! CPU_EQUAL (&s3, &s1))
23 puts ("result of CPU_AND wrong");
24 result = 1;
27 CPU_OR (&s3, &s1, &s2);
28 if (! CPU_EQUAL (&s3, &s2))
30 puts ("result of CPU_OR wrong");
31 result = 1;
34 CPU_XOR (&s3, &s1, &s2);
35 if (CPU_COUNT (&s3) != 1)
37 puts ("result of CPU_XOR wrong");
38 result = 1;
41 cpu_set_t *vs1 = CPU_ALLOC (2048);
42 cpu_set_t *vs2 = CPU_ALLOC (2048);
43 cpu_set_t *vs3 = CPU_ALLOC (2048);
44 size_t vssize = CPU_ALLOC_SIZE (2048);
46 CPU_ZERO_S (vssize, vs1);
47 CPU_SET_S (0, vssize, vs1);
49 CPU_ZERO_S (vssize, vs2);
50 CPU_SET_S (0, vssize, vs2);
51 CPU_SET_S (2047, vssize, vs2);
53 CPU_AND_S (vssize, vs3, vs1, vs2);
54 if (! CPU_EQUAL_S (vssize, vs3, vs1))
56 puts ("result of CPU_AND_S wrong");
57 result = 1;
60 CPU_OR_S (vssize, vs3, vs1, vs2);
61 if (! CPU_EQUAL_S (vssize, vs3, vs2))
63 puts ("result of CPU_OR_S wrong");
64 result = 1;
67 CPU_XOR_S (vssize, vs3, vs1, vs2);
68 if (CPU_COUNT_S (vssize, vs3) != 1)
70 puts ("result of CPU_XOR_S wrong");
71 result = 1;
74 CPU_FREE (vs1);
75 CPU_FREE (vs2);
76 CPU_FREE (vs3);
78 return result;
81 #define TEST_FUNCTION do_test ()
82 #include "../test-skeleton.c"