Debian Codegraph @

internal/overlay/musl/arch/i386/syscall_arch.h

raw
1 #ifdef __CCGO__
2
3 static __inline long __syscall0(long n);
4 static __inline long __syscall1(long n, long a1);
5 static __inline long __syscall2(long n, long a1, long a2);
6 static __inline long __syscall3(long n, long a1, long a2, long a3);
7 static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
8 static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
9 static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
10
11 #define __SYSCALL_LL_E(x) ((int)(x)), ((int)((x)>>32))
12 #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
13
14 #else // __CCGO__
15
16 #define __SYSCALL_LL_E(x) \
17 ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
18 ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
19 #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
20
21 #if SYSCALL_NO_TLS
22 #define SYSCALL_INSNS "int $128"
23 #else
24 #define SYSCALL_INSNS "call *%%gs:16"
25 #endif
26
27 #define SYSCALL_INSNS_12 "xchg %%ebx,%%edx ; " SYSCALL_INSNS " ; xchg %%ebx,%%edx"
28 #define SYSCALL_INSNS_34 "xchg %%ebx,%%edi ; " SYSCALL_INSNS " ; xchg %%ebx,%%edi"
29
30 static inline long __syscall0(long n)
31 {
32 unsigned long __ret;
33 __asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n) : "memory");
34 return __ret;
35 }
36
37 static inline long __syscall1(long n, long a1)
38 {
39 unsigned long __ret;
40 __asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
41 return __ret;
42 }
43
44 static inline long __syscall2(long n, long a1, long a2)
45 {
46 unsigned long __ret;
47 __asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
48 return __ret;
49 }
50
51 static inline long __syscall3(long n, long a1, long a2, long a3)
52 {
53 unsigned long __ret;
54 #if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
55 __asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3) : "memory");
56 #else
57 __asm__ __volatile__ (SYSCALL_INSNS_34 : "=a"(__ret) : "a"(n), "D"(a1), "c"(a2), "d"(a3) : "memory");
58 #endif
59 return __ret;
60 }
61
62 static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
63 {
64 unsigned long __ret;
65 #if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
66 __asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
67 #else
68 __asm__ __volatile__ (SYSCALL_INSNS_34 : "=a"(__ret) : "a"(n), "D"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
69 #endif
70 return __ret;
71 }
72
73 static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
74 {
75 unsigned long __ret;
76 #if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
77 __asm__ __volatile__ (SYSCALL_INSNS
78 : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
79 #else
80 __asm__ __volatile__ ("pushl %2 ; push %%ebx ; mov 4(%%esp),%%ebx ; " SYSCALL_INSNS " ; pop %%ebx ; add $4,%%esp"
81 : "=a"(__ret) : "a"(n), "g"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
82 #endif
83 return __ret;
84 }
85
86 static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
87 {
88 unsigned long __ret;
89 #if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
90 __asm__ __volatile__ ("pushl %7 ; push %%ebp ; mov 4(%%esp),%%ebp ; " SYSCALL_INSNS " ; pop %%ebp ; add $4,%%esp"
91 : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5), "g"(a6) : "memory");
92 #else
93 unsigned long a1a6[2] = { a1, a6 };
94 __asm__ __volatile__ ("pushl %1 ; push %%ebx ; push %%ebp ; mov 8(%%esp),%%ebx ; mov 4(%%ebx),%%ebp ; mov (%%ebx),%%ebx ; " SYSCALL_INSNS " ; pop %%ebp ; pop %%ebx ; add $4,%%esp"
95 : "=a"(__ret) : "g"(&a1a6), "a"(n), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
96 #endif
97 return __ret;
98 }
99
100 #define VDSO_USEFUL
101 #define VDSO_CGT32_SYM "__vdso_clock_gettime"
102 #define VDSO_CGT32_VER "LINUX_2.6"
103 #define VDSO_CGT_SYM "__vdso_clock_gettime64"
104 #define VDSO_CGT_VER "LINUX_2.6"
105
106 #endif // __CCGO__