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