]> sourceware.org Git - systemtap.git/blob - testsuite/systemtap.base/utrace_syscall_args.c
Use a value for bad syscall that works better on 32-bit ARM
[systemtap.git] / testsuite / systemtap.base / utrace_syscall_args.c
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <sys/mman.h>
4 #include <fcntl.h>
5 #include <unistd.h>
6 #include <sys/syscall.h> /* For SYS_xxx definitions */
7
8 int main()
9 {
10 int fd, ret;
11 struct stat fs;
12 void *r;
13 int rc;
14
15 /* create a file with something in it */
16 fd = open("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600);
17 lseek(fd, 1024, SEEK_SET);
18 write(fd, "abcdef", 6);
19 close(fd);
20
21 fd = open("foobar", O_RDONLY);
22
23 /* stat for file size */
24 ret = fstat(fd, &fs);
25
26 /* mmap file file, then unmap it. */
27 r = mmap(NULL, fs.st_size, PROT_READ, MAP_SHARED, fd, 0);
28 if (r != MAP_FAILED)
29 munmap(r, fs.st_size);
30 close(fd);
31
32 /* OK, try some system calls to see if we get the arguments
33 * correctly. */
34 #if (__LONG_MAX__ > __INT_MAX__)
35 rc = syscall (__NR_dup, (unsigned long)-12345,
36 (unsigned long)0xffffffffffffffff,
37 (unsigned long)0xa5a5a5a5a5a5a5a5,
38 (unsigned long)0xf0f0f0f0f0f0f0f0,
39 (unsigned long)0x5a5a5a5a5a5a5a5a,
40 (unsigned long)0xe38e38e38e38e38e);
41 #else
42 rc = syscall (__NR_dup, (unsigned long)-12345,
43 (unsigned long)0xffffffff,
44 (unsigned long)0xa5a5a5a5,
45 (unsigned long)0xf0f0f0f0,
46 (unsigned long)0x5a5a5a5a,
47 (unsigned long)0xe38e38e3);
48 #endif
49 #if (__LONG_MAX__ > __INT_MAX__)
50 rc = syscall ((unsigned long)0xffff,
51 (unsigned long)0x1c71c71c71c71c71,
52 (unsigned long)0x0f0f0f0f0f0f0f0f,
53 (unsigned long)0xdb6db6db6db6db6d,
54 (unsigned long)0x2492492492492492,
55 (unsigned long)0xad6b5ad6b5ad6b5a,
56 (unsigned long)0xdef7ddef7ddef7dd);
57 #else
58 rc = syscall ((unsigned long)0xffff,
59 (unsigned long)0x1c71c71c,
60 (unsigned long)0x0f0f0f0f,
61 (unsigned long)0xdb6db6db,
62 (unsigned long)0x24924924,
63 (unsigned long)0xad6b5ad6,
64 (unsigned long)0xdef7ddef);
65 #endif
66 return 0;
67 }
This page took 0.035416 seconds and 5 git commands to generate.