[Infra] Fix version-check workflow (#100090)
[llvm-project.git] / third-party / benchmark / cmake / pthread_affinity.cpp
blob7b143bc02128beb48f4d4aed78d48db20272ff0e
1 #include <pthread.h>
2 int main() {
3 cpu_set_t set;
4 CPU_ZERO(&set);
5 for (int i = 0; i < CPU_SETSIZE; ++i) {
6 CPU_SET(i, &set);
7 CPU_CLR(i, &set);
9 pthread_t self = pthread_self();
10 int ret;
11 ret = pthread_getaffinity_np(self, sizeof(set), &set);
12 if (ret != 0) return ret;
13 ret = pthread_setaffinity_np(self, sizeof(set), &set);
14 if (ret != 0) return ret;
15 return 0;