• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* This is the arm64 variant of memcheck/tests/x86-linux/scalar.h */
2 #include "../../../include/vki/vki-scnums-arm64-linux.h"
3 
4 #include <assert.h>
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <sys/syscall.h>
10 #include <sys/stat.h>
11 #include <sys/ptrace.h>
12 #include <sys/types.h>
13 #include <sys/mman.h>
14 
15 // Since we use vki_unistd.h, we can't include <unistd.h>.  So we have to
16 // declare this ourselves.
17 extern long int syscall (long int __sysno, ...) __THROW;
18 
19 // Thorough syscall scalar arg checking.  Also serves as thorough checking
20 // for (very) basic syscall use.  Generally not trying to do anything
21 // meaningful with the syscalls.
22 
23 #define GO(__NR_xxx, s) \
24    fprintf(stderr, "-----------------------------------------------------\n"  \
25                    "%3d:%20s %s\n"                                            \
26                    "-----------------------------------------------------\n", \
27                    __NR_xxx, #__NR_xxx, s);
28 
29 #define SY  res = syscall
30 
31 #define FAIL  assert(-1 == res);
32 #define SUCC  assert(-1 != res);
33 #define SUCC_OR_FAIL    /* no test */
34 
35 #define FAILx(E) \
36    do { \
37       int myerrno = errno; \
38       if (-1 == res) { \
39          if (E == myerrno) { \
40             /* as expected */ \
41          } else { \
42          fprintf(stderr, "Expected error %s (%d), got %d\n", #E, E, myerrno); \
43          exit(1); \
44          } \
45       } else { \
46          fprintf(stderr, "Expected error %s (%d), got success\n", #E, E); \
47          exit(1); \
48       } \
49    } while (0);
50 
51 #define SUCC_OR_FAILx(E) \
52    do { \
53       int myerrno = errno; \
54       if (-1 == res) { \
55          if (E == myerrno) { \
56             /* as expected */ \
57          } else { \
58          fprintf(stderr, "Expected error %s (%d), got %d\n", #E, E, myerrno); \
59          exit(1); \
60          } \
61       } \
62    } while (0);
63