]> granicus.if.org Git - strace/blob - tests/membarrier.c
Implement membarrier syscall decoding
[strace] / tests / membarrier.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <errno.h>
6 #include <stdio.h>
7 #include <unistd.h>
8 #include <sys/syscall.h>
9
10 int
11 main(void)
12 {
13 #ifdef __NR_membarrier
14         if (syscall(__NR_membarrier, 3, 255) != -1)
15                 return 77;
16         printf("membarrier(0x3 /* MEMBARRIER_CMD_??? */, 255) = -1 %s\n",
17                errno == ENOSYS ?
18                         "ENOSYS (Function not implemented)" :
19                         "EINVAL (Invalid argument)");
20         if (errno != ENOSYS) {
21                 if (syscall(__NR_membarrier, 0, 0) != 1)
22                         return 1;  /* the test needs to be updated? */
23                 puts("membarrier(MEMBARRIER_CMD_QUERY, 0)"
24                      " = 0x1 (MEMBARRIER_CMD_SHARED)");
25         }
26         puts("+++ exited with 0 +++");
27         return 0;
28 #else
29         return 77;
30 #endif
31 }