]> err.no Git - linux-2.6/blob - arch/um/include/sysdep-x86_64/stub.h
Merge branch 'master'
[linux-2.6] / arch / um / include / sysdep-x86_64 / stub.h
1 /*
2  * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3  * Licensed under the GPL
4  */
5
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
8
9 #include <asm/unistd.h>
10 #include <sysdep/ptrace_user.h>
11
12 extern void stub_segv_handler(int sig);
13 extern void stub_clone_handler(void);
14
15 #define STUB_SYSCALL_RET PT_INDEX(RAX)
16 #define STUB_MMAP_NR __NR_mmap
17 #define MMAP_OFFSET(o) (o)
18
19 #define __syscall_clobber "r11","rcx","memory"
20 #define __syscall "syscall"
21
22 static inline long stub_syscall0(long syscall)
23 {
24         long ret;
25
26         __asm__ volatile (__syscall
27                 : "=a" (ret)
28                 : "0" (syscall) : __syscall_clobber );
29
30         return ret;
31 }
32
33 static inline long stub_syscall2(long syscall, long arg1, long arg2)
34 {
35         long ret;
36
37         __asm__ volatile (__syscall
38                 : "=a" (ret)
39                 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
40
41         return ret;
42 }
43
44 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
45 {
46         long ret;
47
48         __asm__ volatile (__syscall
49                 : "=a" (ret)
50                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
51                 : __syscall_clobber );
52
53         return ret;
54 }
55
56 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
57                                  long arg4)
58 {
59         long ret;
60
61         __asm__ volatile ("movq %5,%%r10 ; " __syscall
62                 : "=a" (ret)
63                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
64                   "g" (arg4)
65                 : __syscall_clobber, "r10" );
66
67         return ret;
68 }
69
70 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
71                                  long arg4, long arg5)
72 {
73         long ret;
74
75         __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
76                 : "=a" (ret)
77                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
78                   "g" (arg4), "g" (arg5)
79                 : __syscall_clobber, "r10", "r8" );
80
81         return ret;
82 }
83
84 static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
85                                  long arg4, long arg5, long arg6)
86 {
87         long ret;
88
89         __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; "
90                 "movq %7, %%r9; " __syscall : "=a" (ret)
91                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
92                   "g" (arg4), "g" (arg5), "g" (arg6)
93                 : __syscall_clobber, "r10", "r8", "r9" );
94
95         return ret;
96 }
97
98 static inline void trap_myself(void)
99 {
100         __asm("int3");
101 }
102
103 #endif