2009-08-24 00:43:21 +00:00
|
|
|
/* Assembly code template for system call stubs.
|
2022-01-01 18:54:23 +00:00
|
|
|
Copyright (C) 2009-2022 Free Software Foundation, Inc.
|
2009-08-24 00:43:21 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2009-08-24 00:43:21 +00:00
|
|
|
|
|
|
|
/* The real guts of this work are in the macros defined in the
|
2015-11-12 16:01:36 +00:00
|
|
|
machine- and kernel-specific sysdep.h header file. Cancellable syscalls
|
|
|
|
should be implemented using C implementation with SYSCALL_CANCEL macro.
|
2009-08-24 00:43:21 +00:00
|
|
|
|
|
|
|
Each system call's object is built by a rule in sysd-syscalls
|
|
|
|
generated by make-syscalls.sh that #include's this file after
|
|
|
|
defining a few macros:
|
|
|
|
SYSCALL_NAME syscall name
|
|
|
|
SYSCALL_NARGS number of arguments this call takes
|
2020-04-29 12:35:34 +00:00
|
|
|
SYSCALL_ULONG_ARG_1 the first unsigned long int argument this
|
|
|
|
call takes. 0 means that there are no
|
|
|
|
unsigned long int arguments.
|
|
|
|
SYSCALL_ULONG_ARG_2 the second unsigned long int argument this
|
|
|
|
call takes. 0 means that there is at most
|
|
|
|
one unsigned long int argument.
|
2009-08-24 00:43:21 +00:00
|
|
|
SYSCALL_SYMBOL primary symbol name
|
|
|
|
SYSCALL_NOERRNO 1 to define a no-errno version (see below)
|
|
|
|
SYSCALL_ERRVAL 1 to define an error-value version (see below)
|
|
|
|
|
|
|
|
We used to simply pipe the correct three lines below through cpp into
|
|
|
|
the assembler. The main reason to have this file instead is so that
|
|
|
|
stub objects can be assembled with -g and get source line information
|
|
|
|
that leads a user back to a source file and these fine comments. The
|
|
|
|
average user otherwise has a hard time knowing which "syscall-like"
|
|
|
|
functions in libc are plain stubs and which have nontrivial C wrappers.
|
|
|
|
Some versions of the "plain" stub generation macros are more than a few
|
|
|
|
instructions long and the untrained eye might not distinguish them from
|
|
|
|
some compiled code that inexplicably lacks source line information. */
|
|
|
|
|
2015-11-12 16:01:36 +00:00
|
|
|
#include <sysdep.h>
|
2009-08-24 00:43:21 +00:00
|
|
|
|
2015-06-17 20:17:49 +00:00
|
|
|
/* This indirection is needed so that SYMBOL gets macro-expanded. */
|
|
|
|
#define syscall_hidden_def(SYMBOL) hidden_def (SYMBOL)
|
|
|
|
|
2020-04-29 12:35:34 +00:00
|
|
|
/* If PSEUDOS_HAVE_ULONG_INDICES is defined, PSEUDO and T_PSEUDO macros
|
|
|
|
have 2 extra arguments for unsigned long int arguments:
|
|
|
|
Extra argument 1: Position of the first unsigned long int argument.
|
|
|
|
Extra argument 2: Position of the second unsigned long int argument.
|
|
|
|
*/
|
|
|
|
#ifndef PSEUDOS_HAVE_ULONG_INDICES
|
|
|
|
# undef SYSCALL_ULONG_ARG_1
|
|
|
|
# define SYSCALL_ULONG_ARG_1 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SYSCALL_ULONG_ARG_1
|
|
|
|
# define T_PSEUDO(SYMBOL, NAME, N, U1, U2) \
|
|
|
|
PSEUDO (SYMBOL, NAME, N, U1, U2)
|
|
|
|
# define T_PSEUDO_NOERRNO(SYMBOL, NAME, N, U1, U2) \
|
|
|
|
PSEUDO_NOERRNO (SYMBOL, NAME, N, U1, U2)
|
|
|
|
# define T_PSEUDO_ERRVAL(SYMBOL, NAME, N, U1, U2) \
|
|
|
|
PSEUDO_ERRVAL (SYMBOL, NAME, N, U1, U2)
|
|
|
|
#else
|
|
|
|
# define T_PSEUDO(SYMBOL, NAME, N) \
|
|
|
|
PSEUDO (SYMBOL, NAME, N)
|
|
|
|
# define T_PSEUDO_NOERRNO(SYMBOL, NAME, N) \
|
|
|
|
PSEUDO_NOERRNO (SYMBOL, NAME, N)
|
|
|
|
# define T_PSEUDO_ERRVAL(SYMBOL, NAME, N) \
|
|
|
|
PSEUDO_ERRVAL (SYMBOL, NAME, N)
|
|
|
|
#endif
|
2009-08-24 00:43:21 +00:00
|
|
|
#define T_PSEUDO_END(SYMBOL) PSEUDO_END (SYMBOL)
|
|
|
|
#define T_PSEUDO_END_NOERRNO(SYMBOL) PSEUDO_END_NOERRNO (SYMBOL)
|
|
|
|
#define T_PSEUDO_END_ERRVAL(SYMBOL) PSEUDO_END_ERRVAL (SYMBOL)
|
|
|
|
|
|
|
|
#if SYSCALL_NOERRNO
|
|
|
|
|
|
|
|
/* This kind of system call stub never returns an error.
|
|
|
|
We return the return value register to the caller unexamined. */
|
|
|
|
|
2020-04-29 12:35:34 +00:00
|
|
|
# if SYSCALL_ULONG_ARG_1
|
|
|
|
T_PSEUDO_NOERRNO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS,
|
|
|
|
SYSCALL_ULONG_ARG_1, SYSCALL_ULONG_ARG_2)
|
|
|
|
# else
|
2009-08-24 00:43:21 +00:00
|
|
|
T_PSEUDO_NOERRNO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
|
2020-04-29 12:35:34 +00:00
|
|
|
# endif
|
2009-08-24 00:43:21 +00:00
|
|
|
ret_NOERRNO
|
|
|
|
T_PSEUDO_END_NOERRNO (SYSCALL_SYMBOL)
|
|
|
|
|
|
|
|
#elif SYSCALL_ERRVAL
|
|
|
|
|
|
|
|
/* This kind of system call stub returns the errno code as its return
|
|
|
|
value, or zero for success. We may massage the kernel's return value
|
|
|
|
to meet that ABI, but we never set errno here. */
|
|
|
|
|
2020-04-29 12:35:34 +00:00
|
|
|
# if SYSCALL_ULONG_ARG_1
|
|
|
|
T_PSEUDO_ERRVAL (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS,
|
|
|
|
SYSCALL_ULONG_ARG_1, SYSCALL_ULONG_ARG_2)
|
|
|
|
# else
|
2009-08-24 00:43:21 +00:00
|
|
|
T_PSEUDO_ERRVAL (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
|
2020-04-29 12:35:34 +00:00
|
|
|
# endif
|
2009-08-24 00:43:21 +00:00
|
|
|
ret_ERRVAL
|
|
|
|
T_PSEUDO_END_ERRVAL (SYSCALL_SYMBOL)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* This is a "normal" system call stub: if there is an error,
|
|
|
|
it returns -1 and sets errno. */
|
|
|
|
|
2020-04-29 12:35:34 +00:00
|
|
|
# if SYSCALL_ULONG_ARG_1
|
|
|
|
T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS,
|
|
|
|
SYSCALL_ULONG_ARG_1, SYSCALL_ULONG_ARG_2)
|
|
|
|
# else
|
2009-08-24 00:43:21 +00:00
|
|
|
T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
|
2020-04-29 12:35:34 +00:00
|
|
|
# endif
|
2009-08-24 00:43:21 +00:00
|
|
|
ret
|
|
|
|
T_PSEUDO_END (SYSCALL_SYMBOL)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-06-17 20:17:49 +00:00
|
|
|
syscall_hidden_def (SYSCALL_SYMBOL)
|