[PATCH] uml: properly invoke x86_64 system calls
[linux-2.6.git] / arch / um / include / sysdep-i386 / stub.h
blob6ba8cbbe0d36a34308d302466d243f897466b4a2
1 /*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
9 #include <asm/ptrace.h>
10 #include <asm/unistd.h>
12 extern void stub_segv_handler(int sig);
13 extern void stub_clone_handler(void);
15 #define STUB_SYSCALL_RET EAX
16 #define STUB_MMAP_NR __NR_mmap2
17 #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT)
19 static inline long stub_syscall0(long syscall)
21 long ret;
23 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));
25 return ret;
28 static inline long stub_syscall1(long syscall, long arg1)
30 long ret;
32 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));
34 return ret;
37 static inline long stub_syscall2(long syscall, long arg1, long arg2)
39 long ret;
41 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
42 "c" (arg2));
44 return ret;
47 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
49 long ret;
51 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
52 "c" (arg2), "d" (arg3));
54 return ret;
57 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
58 long arg4)
60 long ret;
62 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
63 "c" (arg2), "d" (arg3), "S" (arg4));
65 return ret;
68 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
69 long arg4, long arg5)
71 long ret;
73 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
74 "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));
76 return ret;
79 static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
80 long arg4, long arg5, long arg6)
82 long ret;
84 __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; "
85 "int $0x80 ; pop %%ebp"
86 : "=a" (ret)
87 : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3),
88 "S" (arg4), "D" (arg5), "0" (arg6));
90 return ret;
93 static inline void trap_myself(void)
95 __asm("int3");
98 #endif