]> mj.ucw.cz Git - eval.git/blob - test-syscalls.c
46c001ce3f8e5ac5727ff09a87c9e9d86cb27961
[eval.git] / test-syscalls.c
1 int main(void)
2 {
3   /*
4    *  This program calls exit(42) using several different
5    *  syscall mechanisms.
6    */
7 #if defined(TEST_INT80)
8   asm volatile("int $0x80" : : "a" (1), "b" (42) : "memory");
9 #elif defined(TEST_SYSCALL_32)
10   asm volatile("syscall" : : "a" (1), "b" (42) : "memory");
11 #elif defined(TEST_SYSCALL_64)
12   asm volatile("syscall" : : "a" (60), "D" (42) : "memory");
13 #elif defined(TEST_SYSENTER_32)
14   /*
15    *  Hack alert! The SYSENTER instruction does not record
16    *  the return address, so the syscall returns to a fixed
17    *  address inside the VDSO. However, we need not worry
18    *  about all this, since exit() never returns anyway.
19    */
20   asm volatile("sysenter" : : "a" (1), "b" (42) : "memory");
21 #else
22 #error "TEST_xxx must be defined."
23 #endif
24   return 1;
25 }