Fix pathconf statvfs namespace (bug 18507).
[glibc.git] / sysdeps / unix / sysv / linux / tst-getcpu.c
blob77baebc0a85af0787c2cfc4cc14e05d5b9df04ed
1 #include <errno.h>
2 #include <stdio.h>
3 #include <sched.h>
4 #include <unistd.h>
7 static int
8 do_test (void)
10 cpu_set_t cs;
11 if (sched_getaffinity (getpid (), sizeof (cs), &cs) != 0)
13 printf ("getaffinity failed: %m\n");
14 return 1;
17 int result = 0;
18 int cpu = 0;
19 while (CPU_COUNT (&cs) != 0)
21 if (CPU_ISSET (cpu, &cs))
23 cpu_set_t cs2;
24 CPU_ZERO (&cs2);
25 CPU_SET (cpu, &cs2);
26 if (sched_setaffinity (getpid (), sizeof (cs2), &cs2) != 0)
28 printf ("setaffinity(%d) failed: %m\n", cpu);
29 result = 1;
31 else
33 int cpu2 = sched_getcpu ();
34 if (cpu2 == -1)
36 if (errno == ENOSYS)
38 puts ("getcpu syscall not implemented");
39 return 0;
41 perror ("getcpu failed");
42 result = 1;
44 if (cpu2 != cpu)
46 printf ("getcpu results %d not possible\n", cpu2);
47 result = 1;
50 CPU_CLR (cpu, &cs);
52 ++cpu;
55 return result;
58 #define TEST_FUNCTION do_test ()
59 #include <test-skeleton.c>