hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/unix/syscall-template.S

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