]>
Commit | Line | Data |
---|---|---|
f7a9f785 | 1 | /* Copyright (C) 1991-2016 Free Software Foundation, Inc. |
b5791037 | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
b5791037 | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
28f540f4 | 8 | |
b5791037 UD |
9 | The GNU C Library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
28f540f4 | 17 | |
e75154a6 RM |
18 | #include <sysdeps/generic/sysdep.h> |
19 | ||
df4ef2ab | 20 | #include <sys/syscall.h> |
28f540f4 RM |
21 | #define HAVE_SYSCALLS |
22 | ||
23 | /* Note that using a `PASTE' macro loses. */ | |
28f540f4 | 24 | #define SYSCALL__(name, args) PSEUDO (__##name, name, args) |
28f540f4 RM |
25 | #define SYSCALL(name, args) PSEUDO (name, name, args) |
26 | ||
fc48bfbc AZ |
27 | #define __SYSCALL0(name) \ |
28 | INLINE_SYSCALL (name, 0) | |
29 | #define __SYSCALL1(name, a1) \ | |
30 | INLINE_SYSCALL (name, 1, a1) | |
31 | #define __SYSCALL2(name, a1, a2) \ | |
32 | INLINE_SYSCALL (name, 2, a1, a2) | |
33 | #define __SYSCALL3(name, a1, a2, a3) \ | |
34 | INLINE_SYSCALL (name, 3, a1, a2, a3) | |
35 | #define __SYSCALL4(name, a1, a2, a3, a4) \ | |
36 | INLINE_SYSCALL (name, 4, a1, a2, a3, a4) | |
37 | #define __SYSCALL5(name, a1, a2, a3, a4, a5) \ | |
38 | INLINE_SYSCALL (name, 5, a1, a2, a3, a4, a5) | |
39 | #define __SYSCALL6(name, a1, a2, a3, a4, a5, a6) \ | |
40 | INLINE_SYSCALL (name, 6, a1, a2, a3, a4, a5, a6) | |
41 | #define __SYSCALL7(name, a1, a2, a3, a4, a5, a6, a7) \ | |
42 | INLINE_SYSCALL (name, 7, a1, a2, a3, a4, a5, a6, a7) | |
43 | ||
44 | #define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n | |
c6bb095e | 45 | #define __SYSCALL_NARGS(...) \ |
fc48bfbc AZ |
46 | __SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,) |
47 | #define __SYSCALL_CONCAT_X(a,b) a##b | |
48 | #define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X (a, b) | |
49 | #define __SYSCALL_DISP(b,...) \ | |
50 | __SYSCALL_CONCAT (b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__) | |
51 | ||
52 | #define __SYSCALL_CALL(...) __SYSCALL_DISP (__SYSCALL, __VA_ARGS__) | |
c6bb095e | 53 | |
fc48bfbc | 54 | #define SYSCALL_CANCEL(...) \ |
c6bb095e AZ |
55 | ({ \ |
56 | long int sc_ret; \ | |
57 | if (SINGLE_THREAD_P) \ | |
fc48bfbc | 58 | sc_ret = __SYSCALL_CALL (__VA_ARGS__); \ |
c6bb095e AZ |
59 | else \ |
60 | { \ | |
61 | int sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \ | |
fc48bfbc | 62 | sc_ret = __SYSCALL_CALL (__VA_ARGS__); \ |
c6bb095e AZ |
63 | LIBC_CANCEL_RESET (sc_cancel_oldtype); \ |
64 | } \ | |
65 | sc_ret; \ | |
66 | }) | |
67 | ||
28f540f4 RM |
68 | /* Machine-dependent sysdep.h files are expected to define the macro |
69 | PSEUDO (function_name, syscall_name) to emit assembly code to define the | |
70 | C-callable function FUNCTION_NAME to do system call SYSCALL_NAME. | |
71 | r0 and r1 are the system call outputs. MOVE(x, y) should be defined as | |
72 | an instruction such that "MOVE(r1, r0)" works. ret should be defined | |
73 | as the return instruction. */ | |
74 | ||
c6bb095e | 75 | #ifndef SYS_ify |
28f540f4 | 76 | #define SYS_ify(syscall_name) SYS_##syscall_name |
c6bb095e | 77 | #endif |
84724245 | 78 | |
a1470b6f RM |
79 | /* Terminate a system call named SYM. This is used on some platforms |
80 | to generate correct debugging information. */ | |
b5791037 | 81 | #ifndef PSEUDO_END |
a1470b6f | 82 | #define PSEUDO_END(sym) |
b5791037 | 83 | #endif |
da058e45 UD |
84 | #ifndef PSEUDO_END_NOERRNO |
85 | #define PSEUDO_END_NOERRNO(sym) PSEUDO_END(sym) | |
9eb88290 | 86 | #endif |
137ffcdc UD |
87 | #ifndef PSEUDO_END_ERRVAL |
88 | #define PSEUDO_END_ERRVAL(sym) PSEUDO_END(sym) | |
89 | #endif | |
0dee6738 UD |
90 | |
91 | /* Wrappers around system calls should normally inline the system call code. | |
92 | But sometimes it is not possible or implemented and we use this code. */ | |
c6bb095e | 93 | #ifndef INLINE_SYSCALL |
0dee6738 | 94 | #define INLINE_SYSCALL(name, nr, args...) __syscall_##name (args) |
c6bb095e | 95 | #endif |