Blame src/regression/syscall-sign-extend.c
|
Szabolcs Nagy |
b21548 |
// commit 5f95f965e933c5b155db75520ac27c92ddbcf400 2014-03-18
|
|
Szabolcs Nagy |
b21548 |
// syscall should not sign extend pointers on x32
|
|
Szabolcs Nagy |
b21548 |
#define _GNU_SOURCE
|
|
Szabolcs Nagy |
b21548 |
#include <errno.h>
|
|
Szabolcs Nagy |
c6fc4f |
#include <fcntl.h>
|
|
Szabolcs Nagy |
c6fc4f |
#include <string.h>
|
|
Szabolcs Nagy |
b21548 |
#include <sys/syscall.h>
|
|
Szabolcs Nagy |
c6fc4f |
#include <unistd.h>
|
|
Szabolcs Nagy |
b21548 |
#include "test.h"
|
|
Szabolcs Nagy |
b21548 |
|
|
Szabolcs Nagy |
c6fc4f |
#define T(f) (!(f) && (t_error(#f " failed: %s\n", strerror(errno)), 0))
|
|
Szabolcs Nagy |
b21548 |
|
|
Szabolcs Nagy |
b21548 |
int main(void)
|
|
Szabolcs Nagy |
b21548 |
{
|
|
Szabolcs Nagy |
c6fc4f |
char buf[1] = {1};
|
|
Szabolcs Nagy |
c6fc4f |
int fd;
|
|
Szabolcs Nagy |
c6fc4f |
int r;
|
|
Szabolcs Nagy |
b21548 |
|
|
Szabolcs Nagy |
b21548 |
// test syscall with pointer
|
|
Szabolcs Nagy |
c6fc4f |
T((fd = open("/dev/zero", O_RDONLY)) >= 0);
|
|
Szabolcs Nagy |
c6fc4f |
T((r = syscall(SYS_read, fd, buf, 1)) == 1);
|
|
Szabolcs Nagy |
c6fc4f |
if (buf[0] != 0)
|
|
Szabolcs Nagy |
c6fc4f |
t_error("read %d instead of 0\n", buf[0]);
|
|
Szabolcs Nagy |
b21548 |
|
|
Szabolcs Nagy |
b21548 |
return t_status;
|
|
Szabolcs Nagy |
b21548 |
}
|