]>
Commit | Line | Data |
---|---|---|
036e46b6 | 1 | /* Assembly code template for system call stubs. |
b168057a | 2 | Copyright (C) 2009-2015 Free Software Foundation, Inc. |
036e46b6 RM |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
036e46b6 RM |
18 | |
19 | /* The real guts of this work are in the macros defined in the | |
20 | machine- and kernel-specific sysdep.h header file. When we | |
21 | are defining a cancellable system call, the sysdep-cancel.h | |
22 | versions of those macros are what we really use. | |
23 | ||
24 | Each system call's object is built by a rule in sysd-syscalls | |
25 | generated by make-syscalls.sh that #include's this file after | |
26 | defining a few macros: | |
27 | SYSCALL_NAME syscall name | |
28 | SYSCALL_NARGS number of arguments this call takes | |
29 | SYSCALL_SYMBOL primary symbol name | |
30 | SYSCALL_CANCELLABLE 1 if the call is a cancelation point | |
31 | SYSCALL_NOERRNO 1 to define a no-errno version (see below) | |
32 | SYSCALL_ERRVAL 1 to define an error-value version (see below) | |
33 | ||
34 | We used to simply pipe the correct three lines below through cpp into | |
35 | the assembler. The main reason to have this file instead is so that | |
36 | stub objects can be assembled with -g and get source line information | |
37 | that leads a user back to a source file and these fine comments. The | |
38 | average user otherwise has a hard time knowing which "syscall-like" | |
39 | functions in libc are plain stubs and which have nontrivial C wrappers. | |
40 | Some versions of the "plain" stub generation macros are more than a few | |
41 | instructions long and the untrained eye might not distinguish them from | |
42 | some compiled code that inexplicably lacks source line information. */ | |
43 | ||
44 | #if SYSCALL_CANCELLABLE | |
45 | # include <sysdep-cancel.h> | |
46 | #else | |
47 | # include <sysdep.h> | |
48 | #endif | |
49 | ||
50 | #define T_PSEUDO(SYMBOL, NAME, N) PSEUDO (SYMBOL, NAME, N) | |
51 | #define T_PSEUDO_NOERRNO(SYMBOL, NAME, N) PSEUDO_NOERRNO (SYMBOL, NAME, N) | |
52 | #define T_PSEUDO_ERRVAL(SYMBOL, NAME, N) PSEUDO_ERRVAL (SYMBOL, NAME, N) | |
53 | #define T_PSEUDO_END(SYMBOL) PSEUDO_END (SYMBOL) | |
54 | #define T_PSEUDO_END_NOERRNO(SYMBOL) PSEUDO_END_NOERRNO (SYMBOL) | |
55 | #define T_PSEUDO_END_ERRVAL(SYMBOL) PSEUDO_END_ERRVAL (SYMBOL) | |
56 | ||
57 | #if SYSCALL_NOERRNO | |
58 | ||
59 | /* This kind of system call stub never returns an error. | |
60 | We return the return value register to the caller unexamined. */ | |
61 | ||
62 | T_PSEUDO_NOERRNO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) | |
63 | ret_NOERRNO | |
64 | T_PSEUDO_END_NOERRNO (SYSCALL_SYMBOL) | |
65 | ||
66 | #elif SYSCALL_ERRVAL | |
67 | ||
68 | /* This kind of system call stub returns the errno code as its return | |
69 | value, or zero for success. We may massage the kernel's return value | |
70 | to meet that ABI, but we never set errno here. */ | |
71 | ||
72 | T_PSEUDO_ERRVAL (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) | |
73 | ret_ERRVAL | |
74 | T_PSEUDO_END_ERRVAL (SYSCALL_SYMBOL) | |
75 | ||
76 | #else | |
77 | ||
78 | /* This is a "normal" system call stub: if there is an error, | |
79 | it returns -1 and sets errno. */ | |
80 | ||
81 | T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) | |
82 | ret | |
83 | T_PSEUDO_END (SYSCALL_SYMBOL) | |
84 | ||
85 | #endif | |
86 | ||
87 | libc_hidden_def (SYSCALL_SYMBOL) |