xref: /llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp (revision d231efe1ee1102e10cef1dd294778ccbea103e9c)
1 // RUN: %clangxx -O0 %s -o %t && %run %t
2 
3 // Android does not implement pthread_getaffinity_np.
4 // (Note: libresolv is integrated with libc, but apparently only
5 // sched_getaffinity).
6 // UNSUPPORTED: android
7 
8 #include <assert.h>
9 #include <pthread.h>
10 #include <sys/sysinfo.h>
11 
12 #include <sanitizer/msan_interface.h>
13 
main()14 int main() {
15   cpu_set_t set_x[4];
16   pthread_t tid = pthread_self();
17   int res = pthread_getaffinity_np(tid, sizeof(set_x), set_x);
18   assert(res == 0);
19   int cpus = CPU_COUNT_S(sizeof(set_x), set_x);
20   assert(cpus > 0 && cpus <= get_nprocs());
21 
22   return 0;
23 }
24