Blame sysdeps/unix/syscall-template.S

Packit Service 82fcde
/* Assembly code template for system call stubs.
Packit Service 82fcde
   Copyright (C) 2009-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
/* The real guts of this work are in the macros defined in the
Packit Service 82fcde
   machine- and kernel-specific sysdep.h header file.  Cancellable syscalls
Packit Service 82fcde
   should be implemented using C implementation with SYSCALL_CANCEL macro.
Packit Service 82fcde
Packit Service 82fcde
   Each system call's object is built by a rule in sysd-syscalls
Packit Service 82fcde
   generated by make-syscalls.sh that #include's this file after
Packit Service 82fcde
   defining a few macros:
Packit Service 82fcde
	SYSCALL_NAME		syscall name
Packit Service 82fcde
	SYSCALL_NARGS		number of arguments this call takes
Packit Service 82fcde
	SYSCALL_SYMBOL		primary symbol name
Packit Service 82fcde
	SYSCALL_NOERRNO		1 to define a no-errno version (see below)
Packit Service 82fcde
	SYSCALL_ERRVAL		1 to define an error-value version (see below)
Packit Service 82fcde
Packit Service 82fcde
   We used to simply pipe the correct three lines below through cpp into
Packit Service 82fcde
   the assembler.  The main reason to have this file instead is so that
Packit Service 82fcde
   stub objects can be assembled with -g and get source line information
Packit Service 82fcde
   that leads a user back to a source file and these fine comments.  The
Packit Service 82fcde
   average user otherwise has a hard time knowing which "syscall-like"
Packit Service 82fcde
   functions in libc are plain stubs and which have nontrivial C wrappers.
Packit Service 82fcde
   Some versions of the "plain" stub generation macros are more than a few
Packit Service 82fcde
   instructions long and the untrained eye might not distinguish them from
Packit Service 82fcde
   some compiled code that inexplicably lacks source line information.  */
Packit Service 82fcde
Packit Service 82fcde
#include <sysdep.h>
Packit Service 82fcde
Packit Service 82fcde
/* This indirection is needed so that SYMBOL gets macro-expanded.  */
Packit Service 82fcde
#define syscall_hidden_def(SYMBOL)		hidden_def (SYMBOL)
Packit Service 82fcde
Packit Service 82fcde
#define T_PSEUDO(SYMBOL, NAME, N)		PSEUDO (SYMBOL, NAME, N)
Packit Service 82fcde
#define T_PSEUDO_NOERRNO(SYMBOL, NAME, N)	PSEUDO_NOERRNO (SYMBOL, NAME, N)
Packit Service 82fcde
#define T_PSEUDO_ERRVAL(SYMBOL, NAME, N)	PSEUDO_ERRVAL (SYMBOL, NAME, N)
Packit Service 82fcde
#define T_PSEUDO_END(SYMBOL)			PSEUDO_END (SYMBOL)
Packit Service 82fcde
#define T_PSEUDO_END_NOERRNO(SYMBOL)		PSEUDO_END_NOERRNO (SYMBOL)
Packit Service 82fcde
#define T_PSEUDO_END_ERRVAL(SYMBOL)		PSEUDO_END_ERRVAL (SYMBOL)
Packit Service 82fcde
Packit Service 82fcde
#if SYSCALL_NOERRNO
Packit Service 82fcde
Packit Service 82fcde
/* This kind of system call stub never returns an error.
Packit Service 82fcde
   We return the return value register to the caller unexamined.  */
Packit Service 82fcde
Packit Service 82fcde
T_PSEUDO_NOERRNO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
Packit Service 82fcde
	ret_NOERRNO
Packit Service 82fcde
T_PSEUDO_END_NOERRNO (SYSCALL_SYMBOL)
Packit Service 82fcde
Packit Service 82fcde
#elif SYSCALL_ERRVAL
Packit Service 82fcde
Packit Service 82fcde
/* This kind of system call stub returns the errno code as its return
Packit Service 82fcde
   value, or zero for success.  We may massage the kernel's return value
Packit Service 82fcde
   to meet that ABI, but we never set errno here.  */
Packit Service 82fcde
Packit Service 82fcde
T_PSEUDO_ERRVAL (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
Packit Service 82fcde
	ret_ERRVAL
Packit Service 82fcde
T_PSEUDO_END_ERRVAL (SYSCALL_SYMBOL)
Packit Service 82fcde
Packit Service 82fcde
#else
Packit Service 82fcde
Packit Service 82fcde
/* This is a "normal" system call stub: if there is an error,
Packit Service 82fcde
   it returns -1 and sets errno.  */
Packit Service 82fcde
Packit Service 82fcde
T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
Packit Service 82fcde
	ret
Packit Service 82fcde
T_PSEUDO_END (SYSCALL_SYMBOL)
Packit Service 82fcde
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
syscall_hidden_def (SYSCALL_SYMBOL)