1 // commit 5f95f965e933c5b155db75520ac27c92ddbcf400 2014-03-18 2 // syscall should not sign extend pointers on x32 3 #define _GNU_SOURCE 4 #include <errno.h> 5 #include <fcntl.h> 6 #include <string.h> 7 #include <sys/syscall.h> 8 #include <unistd.h> 9 #include "test.h" 10 11 #define T(f) (!(f) && (t_error(#f " failed: %s\n", strerror(errno)), 0)) 12 main(void)13int main(void) 14 { 15 char buf[1] = {1}; 16 int fd; 17 int r; 18 19 // test syscall with pointer 20 T((fd = open("/dev/zero", O_RDONLY)) >= 0); 21 T((r = syscall(SYS_read, fd, buf, 1)) == 1); 22 if (buf[0] != 0) 23 t_error("read %d instead of 0\n", buf[0]); 24 25 return t_status; 26 } 27