1 /* Test that all instructions that make syscalls are handled correctly.
2 Note that it isn't possible to run this program natively. */
5 #include <sys/syscall.h>
8 #define SYSCALL(instr, scnum, out) \
10 __asm__ __volatile__( \
12 "leal 0f,%%edx\n" /* Set return address for SYSENTER. */ \
18 : "eax", "edx", "cc", "memory"); \
21 static void check_pid(int pid
, int pid2
, const char *instr
)
26 fprintf(stderr
, "Pid values differ, instruction: %s\n", instr
);
33 /* Normal Solaris/x86 syscall instructions. */
34 SYSCALL("int $0x91", SYS_getpid
, pid
);
36 /* AMD's syscall instruction. */
37 SYSCALL("syscall", SYS_getpid
, pid2
);
38 check_pid(pid
, pid2
, "syscall");
40 /* Intel's sysenter instruction. */
41 SYSCALL("sysenter", SYS_getpid
, pid2
);
42 check_pid(pid
, pid2
, "sysenter");
44 /* Linux syscall instructions that are handled as "int $0x91". */
45 SYSCALL("int $0x80", SYS_getpid
, pid2
);
46 check_pid(pid
, pid2
, "int $0x80");
48 SYSCALL("int $0x81", SYS_getpid
, pid2
);
49 check_pid(pid
, pid2
, "int $0x81");
51 SYSCALL("int $0x82", SYS_getpid
, pid2
);
52 check_pid(pid
, pid2
, "int $0x82");
55 SYSCALL("int $0xd2", T_GETHRTIME
, dummy
);