File: pthread_getaffinity_np.cpp

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,998,872 kB
  • sloc: cpp: 6,951,694; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,033; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,177; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (23 lines) | stat: -rw-r--r-- 574 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// RUN: %clangxx -O0 %s -o %t && %run %t

// Android does not implement pthread_getaffinity_np.
// (Note: libresolv is integrated with libc, but apparently only
// sched_getaffinity).
// UNSUPPORTED: android

#include <assert.h>
#include <pthread.h>
#include <sys/sysinfo.h>

#include <sanitizer/msan_interface.h>

int main() {
  cpu_set_t set_x[4];
  pthread_t tid = pthread_self();
  int res = pthread_getaffinity_np(tid, sizeof(set_x), set_x);
  assert(res == 0);
  int cpus = CPU_COUNT_S(sizeof(set_x), set_x);
  assert(cpus > 0 && cpus <= get_nprocs());

  return 0;
}