2d64b0b0eafb9bcbea9e57d8635604b67cd02cb2
[musl] / arch / i386 / syscall_arch.h
1 #define __SYSCALL_LL_E(x) \
2 ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
3 ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
4 #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
5
6 #define __SYSCALL_SSLEN 8
7
8 static inline long __syscall0(long n)
9 {
10         unsigned long __ret;
11         __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n) : "memory");
12         return __ret;
13 }
14
15 static inline long __syscall1(long n, long a1)
16 {
17         unsigned long __ret;
18         __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
19         return __ret;
20 }
21
22 static inline long __syscall2(long n, long a1, long a2)
23 {
24         unsigned long __ret;
25         __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
26         return __ret;
27 }
28
29 static inline long __syscall3(long n, long a1, long a2, long a3)
30 {
31         unsigned long __ret;
32         __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3) : "memory");
33         return __ret;
34 }
35
36 static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
37 {
38         unsigned long __ret;
39         __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4) : "memory");
40         return __ret;
41 }
42
43 static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
44 {
45         unsigned long __ret;
46         __asm__ __volatile__ ("push %6 ; call __vsyscall ; add $4,%%esp" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4), "g"(a5) : "memory");
47         return __ret;
48 }
49
50 static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
51 {
52         unsigned long __ret;
53         __asm__ __volatile__ ("push %6 ; call __vsyscall6 ; add $4,%%esp" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4), "g"((long[]){a5, a6}) : "memory");
54         return __ret;
55 }
56
57
58 #define __SC_socket      1
59 #define __SC_bind        2
60 #define __SC_connect     3
61 #define __SC_listen      4
62 #define __SC_accept      5
63 #define __SC_getsockname 6
64 #define __SC_getpeername 7
65 #define __SC_socketpair  8
66 #define __SC_send        9
67 #define __SC_recv        10
68 #define __SC_sendto      11
69 #define __SC_recvfrom    12
70 #define __SC_shutdown    13
71 #define __SC_setsockopt  14
72 #define __SC_getsockopt  15
73 #define __SC_sendmsg     16
74 #define __SC_recvmsg     17
75 #define __SC_accept4     18
76 #define __SC_recvmmsg    19
77 #define __SC_sendmmsg    20