chiark / gitweb /
[PATCH] sync with latest version of klibc (0.107)
[elogind.git] / klibc / klibc / arch / x86_64 / include / klibc / archsys.h
1 /*
2  * arch/x86_64/include/klibc/archsys.h
3  *
4  * Architecture-specific syscall definitions
5  */
6
7 #ifndef _KLIBC_ARCHSYS_H
8 #define _KLIBC_ARCHSYS_H
9
10 /* The x86-64 syscall headers are needlessly inefficient */
11
12 #undef _syscall0
13 #undef _syscall1
14 #undef _syscall2
15 #undef _syscall3
16 #undef _syscall4
17 #undef _syscall5
18 #undef _syscall6
19
20 #define _syscall0(type,name) \
21 type name (void) \
22 { \
23 long __res; \
24 __asm__ volatile (__syscall \
25         : "=a" (__res) \
26         : "0" (__NR_##name) \
27         : __syscall_clobber); \
28 __syscall_return(type,__res); \
29 }
30
31 #define _syscall1(type,name,type1,arg1) \
32 type name (type1 arg1) \
33 { \
34 long __res; \
35 __asm__ volatile (__syscall \
36         : "=a" (__res) \
37         : "0" (__NR_##name),"D" (arg1) \
38         : __syscall_clobber); \
39 __syscall_return(type,__res); \
40 }
41
42 #define _syscall2(type,name,type1,arg1,type2,arg2) \
43 type name (type1 arg1,type2 arg2) \
44 { \
45 long __res; \
46 __asm__ volatile (__syscall \
47         : "=a" (__res) \
48         : "0" (__NR_##name),"D" (arg1),"S" (arg2) \
49         : __syscall_clobber); \
50 __syscall_return(type,__res); \
51 }
52
53 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
54 type name (type1 arg1,type2 arg2,type3 arg3) \
55 { \
56 long __res; \
57 __asm__ volatile (__syscall \
58         : "=a" (__res) \
59         : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
60           "d" (arg3) \
61         : __syscall_clobber); \
62 __syscall_return(type,__res); \
63 }
64
65 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
66 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
67 { \
68 long __res; \
69 register type4 __r10 asm("%r10") = arg4; \
70 __asm__ volatile (__syscall \
71         : "=a" (__res) \
72         : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
73           "d" (arg3),"r" (__r10) \
74         : __syscall_clobber); \
75 __syscall_return(type,__res); \
76 }
77
78 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
79           type5,arg5) \
80 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
81 { \
82 long __res; \
83 register type4 __r10 asm("%r10") = arg4; \
84 register type5 __r8  asm("%r8")  = arg5; \
85 __asm__ volatile (__syscall \
86         : "=a" (__res) \
87         : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
88           "d" (arg3),"r" (__r10),"r" (__r8) \
89         : __syscall_clobber); \
90 __syscall_return(type,__res); \
91 }
92
93 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
94           type5,arg5,type6,arg6) \
95 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
96 { \
97 long __res; \
98 register type4 __r10 asm("%r10") = arg4; \
99 register type5 __r8  asm("%r8")  = arg5; \
100 register type6 __r9  asm("%r9")  = arg6; \
101 __asm__ volatile (__syscall \
102         : "=a" (__res) \
103         : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
104           "d" (arg3),"r" (__r10),"r" (__r8), "r" (__r9) \
105         : __syscall_clobber); \
106 __syscall_return(type,__res); \
107 }
108
109 #endif /* _KLIBC_ARCHSYS_H */