1 // RUN: %clangxx %s -o %t && %run %t %p
2 
3 #include <assert.h>
4 #include <errno.h>
5 #include <stdint.h>
6 #include <sys/prctl.h>
7 
8 #ifndef PR_SCHED_CORE
9 #  define PR_SCHED_CORE 62
10 #endif
11 
12 #ifndef PR_SCHED_CORE_CREATE
13 #  define PR_SCHED_CORE_CREATE 1
14 #endif
15 
16 #ifndef PR_SCHED_CORE_GET
17 #  define PR_SCHED_CORE_GET 0
18 #endif
19 
20 int main() {
21 
22   int res;
23   res = prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, 0, 0, 0);
24   if (res < 0) {
25     assert(errno == EINVAL || errno == ENODEV);
26     return 0;
27   }
28 
29   uint64_t cookie = 0;
30   res = prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, 0, 0, &cookie);
31   if (res < 0) {
32     assert(errno == EINVAL);
33   } else {
34     assert(cookie != 0);
35   }
36 
37   return 0;
38 }
39