avoid "inline" in public headers for strict c89 compatibility
[musl] / include / sys / syscall.h
1 #ifndef _SYS_SYSCALL_H
2 #define _SYS_SYSCALL_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
8 #define __inline inline
9 #endif
10
11 long __syscall_ret(unsigned long);
12 long __syscall(long, ...);
13 long syscall(long, ...);
14
15 #include <bits/syscall.h>
16
17 #define __syscall1(n,a) __syscall1(n,(long)(a))
18 #define __syscall2(n,a,b) __syscall2(n,(long)(a),(long)(b))
19 #define __syscall3(n,a,b,c) __syscall3(n,(long)(a),(long)(b),(long)(c))
20 #define __syscall4(n,a,b,c,d) __syscall4(n,(long)(a),(long)(b),(long)(c),(long)(d))
21 #define __syscall5(n,a,b,c,d,e) __syscall5(n,(long)(a),(long)(b),(long)(c),(long)(d),(long)(e))
22 #define __syscall6(n,a,b,c,d,e,f) __syscall6(n,(long)(a),(long)(b),(long)(c),(long)(d),(long)(e),(long)(f))
23
24 #define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,n,...) n
25 #define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,6,5,4,3,2,1,0)
26 #define __SYSCALL_CONCAT_X(a,b) a##b
27 #define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b)
28 #define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
29
30 #define __syscall(...) __SYSCALL_DISP(__syscall,__VA_ARGS__)
31 #define syscall(...) __syscall_ret(__syscall(__VA_ARGS__))
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif