]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/syscall-template.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / syscall-template.S
CommitLineData
036e46b6 1/* Assembly code template for system call stubs.
d614a753 2 Copyright (C) 2009-2020 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 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
036e46b6
RM
18
19/* The real guts of this work are in the macros defined in the
ebd6f007
AZ
20 machine- and kernel-specific sysdep.h header file. Cancellable syscalls
21 should be implemented using C implementation with SYSCALL_CANCEL macro.
036e46b6
RM
22
23 Each system call's object is built by a rule in sysd-syscalls
24 generated by make-syscalls.sh that #include's this file after
25 defining a few macros:
26 SYSCALL_NAME syscall name
27 SYSCALL_NARGS number of arguments this call takes
28 SYSCALL_SYMBOL primary symbol name
036e46b6
RM
29 SYSCALL_NOERRNO 1 to define a no-errno version (see below)
30 SYSCALL_ERRVAL 1 to define an error-value version (see below)
31
32 We used to simply pipe the correct three lines below through cpp into
33 the assembler. The main reason to have this file instead is so that
34 stub objects can be assembled with -g and get source line information
35 that leads a user back to a source file and these fine comments. The
36 average user otherwise has a hard time knowing which "syscall-like"
37 functions in libc are plain stubs and which have nontrivial C wrappers.
38 Some versions of the "plain" stub generation macros are more than a few
39 instructions long and the untrained eye might not distinguish them from
40 some compiled code that inexplicably lacks source line information. */
41
ebd6f007 42#include <sysdep.h>
036e46b6 43
c21d37de
JM
44/* This indirection is needed so that SYMBOL gets macro-expanded. */
45#define syscall_hidden_def(SYMBOL) hidden_def (SYMBOL)
46
036e46b6
RM
47#define T_PSEUDO(SYMBOL, NAME, N) PSEUDO (SYMBOL, NAME, N)
48#define T_PSEUDO_NOERRNO(SYMBOL, NAME, N) PSEUDO_NOERRNO (SYMBOL, NAME, N)
49#define T_PSEUDO_ERRVAL(SYMBOL, NAME, N) PSEUDO_ERRVAL (SYMBOL, NAME, N)
50#define T_PSEUDO_END(SYMBOL) PSEUDO_END (SYMBOL)
51#define T_PSEUDO_END_NOERRNO(SYMBOL) PSEUDO_END_NOERRNO (SYMBOL)
52#define T_PSEUDO_END_ERRVAL(SYMBOL) PSEUDO_END_ERRVAL (SYMBOL)
53
54#if SYSCALL_NOERRNO
55
56/* This kind of system call stub never returns an error.
57 We return the return value register to the caller unexamined. */
58
59T_PSEUDO_NOERRNO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
60 ret_NOERRNO
61T_PSEUDO_END_NOERRNO (SYSCALL_SYMBOL)
62
63#elif SYSCALL_ERRVAL
64
65/* This kind of system call stub returns the errno code as its return
66 value, or zero for success. We may massage the kernel's return value
67 to meet that ABI, but we never set errno here. */
68
69T_PSEUDO_ERRVAL (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
70 ret_ERRVAL
71T_PSEUDO_END_ERRVAL (SYSCALL_SYMBOL)
72
73#else
74
75/* This is a "normal" system call stub: if there is an error,
76 it returns -1 and sets errno. */
77
78T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
79 ret
80T_PSEUDO_END (SYSCALL_SYMBOL)
81
82#endif
83
c21d37de 84syscall_hidden_def (SYSCALL_SYMBOL)