2018-01-29 18:27:52 +00:00
|
|
|
/* Assembly macros for RISC-V.
|
|
|
|
Copyright (C) 2011-2018
|
|
|
|
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
|
|
|
|
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/>. */
|
2018-01-29 18:27:52 +00:00
|
|
|
|
|
|
|
#ifndef _LINUX_RISCV_SYSDEP_H
|
|
|
|
#define _LINUX_RISCV_SYSDEP_H 1
|
|
|
|
|
|
|
|
#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
|
|
|
|
#include <tls.h>
|
|
|
|
|
2020-07-08 14:49:40 +00:00
|
|
|
#undef SYS_ify
|
|
|
|
#define SYS_ify(syscall_name) __NR_##syscall_name
|
|
|
|
|
2019-06-25 23:32:38 +00:00
|
|
|
#if __WORDSIZE == 32
|
|
|
|
|
|
|
|
/* Workarounds for generic code needing to handle 64-bit time_t. */
|
|
|
|
|
|
|
|
/* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c. */
|
|
|
|
#define __NR_clock_getres __NR_clock_getres_time64
|
|
|
|
/* Fix sysdeps/nptl/lowlevellock-futex.h. */
|
|
|
|
#define __NR_futex __NR_futex_time64
|
|
|
|
/* Fix sysdeps/unix/sysv/linux/pause.c. */
|
|
|
|
#define __NR_ppoll __NR_ppoll_time64
|
|
|
|
/* Fix sysdeps/unix/sysv/linux/select.c. */
|
|
|
|
#define __NR_pselect6 __NR_pselect6_time64
|
|
|
|
/* Fix sysdeps/unix/sysv/linux/recvmmsg.c. */
|
|
|
|
#define __NR_recvmmsg __NR_recvmmsg_time64
|
|
|
|
/* Fix sysdeps/unix/sysv/linux/sigtimedwait.c. */
|
|
|
|
#define __NR_rt_sigtimedwait __NR_rt_sigtimedwait_time64
|
|
|
|
/* Fix sysdeps/unix/sysv/linux/semtimedop.c. */
|
|
|
|
#define __NR_semtimedop __NR_semtimedop_time64
|
|
|
|
/* Hack sysdeps/unix/sysv/linux/generic/utimes.c. */
|
|
|
|
#define __NR_utimensat __NR_utimensat_time64
|
|
|
|
|
|
|
|
#endif /* __WORDSIZE == 32 */
|
|
|
|
|
2018-01-29 18:27:52 +00:00
|
|
|
#ifdef __ASSEMBLER__
|
|
|
|
|
|
|
|
# include <sys/asm.h>
|
|
|
|
|
|
|
|
# define ENTRY(name) LEAF(name)
|
|
|
|
|
|
|
|
# define L(label) .L ## label
|
|
|
|
|
|
|
|
/* Performs a system call, handling errors by setting errno. Linux indicates
|
|
|
|
errors by setting a0 to a value between -1 and -4095. */
|
|
|
|
# undef PSEUDO
|
|
|
|
# define PSEUDO(name, syscall_name, args) \
|
|
|
|
.text; \
|
|
|
|
.align 2; \
|
|
|
|
ENTRY (name); \
|
|
|
|
li a7, SYS_ify (syscall_name); \
|
|
|
|
scall; \
|
|
|
|
li a7, -4096; \
|
|
|
|
bgtu a0, a7, .Lsyscall_error ## name;
|
|
|
|
|
|
|
|
# undef PSEUDO_END
|
|
|
|
# define PSEUDO_END(sym) \
|
|
|
|
SYSCALL_ERROR_HANDLER (sym) \
|
|
|
|
ret; \
|
|
|
|
END (sym)
|
|
|
|
|
|
|
|
# if !IS_IN (libc)
|
|
|
|
# if RTLD_PRIVATE_ERRNO
|
|
|
|
# define SYSCALL_ERROR_HANDLER(name) \
|
|
|
|
.Lsyscall_error ## name: \
|
|
|
|
li t1, -4096; \
|
|
|
|
neg a0, a0; \
|
|
|
|
sw a0, rtld_errno, t1; \
|
|
|
|
li a0, -1;
|
|
|
|
# elif defined (__PIC__)
|
|
|
|
# define SYSCALL_ERROR_HANDLER(name) \
|
|
|
|
.Lsyscall_error ## name: \
|
|
|
|
la.tls.ie t1, errno; \
|
|
|
|
add t1, t1, tp; \
|
|
|
|
neg a0, a0; \
|
|
|
|
sw a0, 0(t1); \
|
|
|
|
li a0, -1;
|
|
|
|
# else
|
|
|
|
# define SYSCALL_ERROR_HANDLER(name) \
|
|
|
|
.Lsyscall_error ## name: \
|
|
|
|
lui t1, %tprel_hi(errno); \
|
|
|
|
add t1, t1, tp, %tprel_add(errno); \
|
|
|
|
neg a0, a0; \
|
|
|
|
sw a0, %tprel_lo(errno)(t1); \
|
|
|
|
li a0, -1;
|
|
|
|
# endif
|
|
|
|
# else
|
|
|
|
# define SYSCALL_ERROR_HANDLER(name) \
|
|
|
|
.Lsyscall_error ## name: \
|
|
|
|
j __syscall_error;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
/* Performs a system call, not setting errno. */
|
|
|
|
# undef PSEUDO_NEORRNO
|
|
|
|
# define PSEUDO_NOERRNO(name, syscall_name, args) \
|
|
|
|
.align 2; \
|
|
|
|
ENTRY (name); \
|
|
|
|
li a7, SYS_ify (syscall_name); \
|
|
|
|
scall;
|
|
|
|
|
|
|
|
# undef PSEUDO_END_NOERRNO
|
|
|
|
# define PSEUDO_END_NOERRNO(name) \
|
|
|
|
END (name)
|
|
|
|
|
|
|
|
# undef ret_NOERRNO
|
|
|
|
# define ret_NOERRNO ret
|
|
|
|
|
|
|
|
/* Perfroms a system call, returning the error code. */
|
|
|
|
# undef PSEUDO_ERRVAL
|
|
|
|
# define PSEUDO_ERRVAL(name, syscall_name, args) \
|
|
|
|
PSEUDO_NOERRNO (name, syscall_name, args) \
|
|
|
|
neg a0, a0;
|
|
|
|
|
|
|
|
# undef PSEUDO_END_ERRVAL
|
|
|
|
# define PSEUDO_END_ERRVAL(name) \
|
|
|
|
END (name)
|
|
|
|
|
|
|
|
# undef ret_ERRVAL
|
|
|
|
# define ret_ERRVAL ret
|
|
|
|
|
2020-07-08 14:49:40 +00:00
|
|
|
#else /* !__ASSEMBLER__ */
|
2018-01-29 18:27:52 +00:00
|
|
|
|
2019-09-18 15:41:59 +00:00
|
|
|
# if __WORDSIZE == 64
|
|
|
|
# define VDSO_NAME "LINUX_4.15"
|
|
|
|
# define VDSO_HASH 182943605
|
|
|
|
|
|
|
|
/* List of system calls which are supported as vsyscalls only
|
|
|
|
for RV64. */
|
|
|
|
# define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
|
|
|
|
# define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
|
|
|
|
# define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
|
|
|
|
# else
|
|
|
|
# define VDSO_NAME "LINUX_5.4"
|
|
|
|
# define VDSO_HASH 61765876
|
|
|
|
|
|
|
|
/* RV32 does not support the gettime VDSO syscalls. */
|
|
|
|
# endif
|
Remove PREPARE_VERSION and PREPARE_VERSION_KNOW
This patch removes the PREPARE_VERSION and PREPARE_VERSION_KNOW macro
and uses a static inline function instead, get_vdso_symbol. Each
architecture that supports vDSO must define the Linux version and its
hash for symbol resolution (VDSO_NAME and VDSO_HASH macro respectively).
It also organizes the HAVE_*_VSYSCALL for mips, powerpc, and s390 to
define them on a common header.
The idea is to require less code to configure and enable vDSO support
for newer ports. No semantic changes are expected.
Checked with a build against all affected architectures.
* sysdeps/unix/make-syscalls.sh: Make vDSO call use get_vdso_symbol.
* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c (__gettimeofday):
Use get_vdso_symbol instead of _dl_vdso_vsym.
* sysdeps/unix/sysv/linux/powerpc/time.c (time): Likewise.
* sysdeps/unix/sysv/linux/riscv/flush-icache.c
(__lookup_riscv_flush_icache): Likewise.
* sysdeps/unix/sysv/linux/x86/gettimeofday.c (__gettimeofday):
Likewise.
* sysdeps/unix/sysv/linux/x86/time.c (time): Likewise.
* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h (VDSO_NAME, VDSO_HASH):
Define.
* sysdeps/unix/sysv/linux/arm/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/riscv/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Remove
definition.
* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep.h: New file.
* sysdeps/unix/sysv/linux/powerpc/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/dl-vdso.h (PREPARE_VERSION,
PREPARE_VERSION_KNOWN, VDSO_NAME_LINUX_2_6, VDSO_HASH_LINUX_2_6,
VDSO_NAME_LINUX_2_6_15, VDSO_HASH_LINUX_2_6_15,
VDSO_NAME_LINUX_2_6_29, VDSO_HASH_LINUX_2_6_29,
VDSO_NAME_LINUX_4_15, VDSO_HASH_LINUX_4_15): Remove defines.
(get_vdso_symbol): New function.
2019-05-23 19:33:32 +00:00
|
|
|
|
2019-09-18 15:41:59 +00:00
|
|
|
/* List of system calls which are supported as vsyscalls (for RV32 and
|
|
|
|
RV64). */
|
Refactor vDSO initialization code
Linux vDSO initialization code the internal function pointers require a
lot of duplicated boilerplate over different architectures. This patch
aims to simplify not only the code but the required definition to enable
a vDSO symbol.
The changes are:
1. Consolidate all init-first.c on only one implementation and enable
the symbol based on HAVE_*_VSYSCALL existence.
2. Set the HAVE_*_VSYSCALL to the architecture expected names string.
3. Add a new internal implementation, get_vdso_mangle_symbol, which
returns a mangled function pointer.
Currently the clock_gettime, clock_getres, gettimeofday, getcpu, and time
are handled in an arch-independent way, powerpc still uses some
arch-specific vDSO symbol handled in a specific init-first implementation.
Checked on aarch64-linux-gnu, arm-linux-gnueabihf, i386-linux-gnu,
mips64-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gnu,
sparc64-linux-gnu, and x86_64-linux-gnu.
* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address,
is_sigtramp_address_rt): Use HAVE_SIGTRAMP_{RT}32 instead of SHARED.
* sysdeps/powerpc/powerpc64/backtrace.c (is_sigtramp_address):
Likewise.
* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove file.
* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/mips/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/s390/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Define value based on kernel exported
name.
* sysdeps/unix/sysv/linux/arm/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETCPU_VSYSCALL, HAVE_TIME_VSYSCALL, HAVE_GET_TBFREQ,
HAVE_SIGTRAMP_RT64, HAVE_SIGTRAMP_32, HAVE_SIGTRAMP_RT32i,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/riscv/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/dl-vdso.h (VDSO_NAME, VDSO_HASH): Define to
invalid names if architecture does not define them.
(get_vdso_mangle_symbol): New symbol.
* sysdeps/unix/sysv/linux/init-first.c: New file.
* sysdeps/unix/sysv/linux/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/init-first.c (gettimeofday,
clock_gettime, clock_getres, getcpu, time): Remove declaration.
(__libc_vdso_platform_setup_arch): Likewise and use
get_vdso_mangle_symbol to setup vDSO symbols.
(sigtramp_rt64, sigtramp32, sigtramp_rt32, get_tbfreq): Add
attribute_hidden.
* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/sysdep-vdso.h (VDSO_SYMBOL): Remove
definition.
2019-06-03 13:22:13 +00:00
|
|
|
# define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
|
2018-01-29 18:27:52 +00:00
|
|
|
|
2020-06-26 19:06:49 +00:00
|
|
|
# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
|
|
|
|
# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define INTERNAL_SYSCALL(name, nr, args...) \
|
|
|
|
internal_syscall##nr (SYS_ify (name), args)
|
2018-01-29 18:27:52 +00:00
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define INTERNAL_SYSCALL_NCS(number, nr, args...) \
|
|
|
|
internal_syscall##nr (number, args)
|
2018-01-29 18:27:52 +00:00
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall0(number, dummy...) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
|
|
|
register long int __a0 asm ("a0"); \
|
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "=r" (__a0) \
|
|
|
|
: "r" (__a7) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall1(number, arg0) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
2020-02-10 13:32:14 +00:00
|
|
|
long int _arg0 = (long int) (arg0); \
|
2018-01-29 18:27:52 +00:00
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
2020-02-10 13:32:14 +00:00
|
|
|
register long int __a0 asm ("a0") = _arg0; \
|
2018-01-29 18:27:52 +00:00
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "+r" (__a0) \
|
|
|
|
: "r" (__a7) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall2(number, arg0, arg1) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
2020-02-10 13:32:14 +00:00
|
|
|
long int _arg0 = (long int) (arg0); \
|
|
|
|
long int _arg1 = (long int) (arg1); \
|
2018-01-29 18:27:52 +00:00
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
2020-02-10 13:32:14 +00:00
|
|
|
register long int __a0 asm ("a0") = _arg0; \
|
|
|
|
register long int __a1 asm ("a1") = _arg1; \
|
2018-01-29 18:27:52 +00:00
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "+r" (__a0) \
|
|
|
|
: "r" (__a7), "r" (__a1) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall3(number, arg0, arg1, arg2) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
2020-02-10 13:32:14 +00:00
|
|
|
long int _arg0 = (long int) (arg0); \
|
|
|
|
long int _arg1 = (long int) (arg1); \
|
|
|
|
long int _arg2 = (long int) (arg2); \
|
2018-01-29 18:27:52 +00:00
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
2020-02-10 13:32:14 +00:00
|
|
|
register long int __a0 asm ("a0") = _arg0; \
|
|
|
|
register long int __a1 asm ("a1") = _arg1; \
|
|
|
|
register long int __a2 asm ("a2") = _arg2; \
|
2018-01-29 18:27:52 +00:00
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "+r" (__a0) \
|
|
|
|
: "r" (__a7), "r" (__a1), "r" (__a2) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall4(number, arg0, arg1, arg2, arg3) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
2020-02-10 13:32:14 +00:00
|
|
|
long int _arg0 = (long int) (arg0); \
|
|
|
|
long int _arg1 = (long int) (arg1); \
|
|
|
|
long int _arg2 = (long int) (arg2); \
|
|
|
|
long int _arg3 = (long int) (arg3); \
|
2018-01-29 18:27:52 +00:00
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
2020-02-10 13:32:14 +00:00
|
|
|
register long int __a0 asm ("a0") = _arg0; \
|
|
|
|
register long int __a1 asm ("a1") = _arg1; \
|
|
|
|
register long int __a2 asm ("a2") = _arg2; \
|
|
|
|
register long int __a3 asm ("a3") = _arg3; \
|
2018-01-29 18:27:52 +00:00
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "+r" (__a0) \
|
|
|
|
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall5(number, arg0, arg1, arg2, arg3, arg4) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
2020-02-10 13:32:14 +00:00
|
|
|
long int _arg0 = (long int) (arg0); \
|
|
|
|
long int _arg1 = (long int) (arg1); \
|
|
|
|
long int _arg2 = (long int) (arg2); \
|
|
|
|
long int _arg3 = (long int) (arg3); \
|
|
|
|
long int _arg4 = (long int) (arg4); \
|
2018-01-29 18:27:52 +00:00
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
2020-02-10 13:32:14 +00:00
|
|
|
register long int __a0 asm ("a0") = _arg0; \
|
|
|
|
register long int __a1 asm ("a1") = _arg1; \
|
|
|
|
register long int __a2 asm ("a2") = _arg2; \
|
|
|
|
register long int __a3 asm ("a3") = _arg3; \
|
|
|
|
register long int __a4 asm ("a4") = _arg4; \
|
2018-01-29 18:27:52 +00:00
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "+r" (__a0) \
|
|
|
|
: "r" (__a7), "r"(__a1), "r"(__a2), "r"(__a3), "r" (__a4) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall6(number, arg0, arg1, arg2, arg3, arg4, arg5) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
2020-02-10 13:32:14 +00:00
|
|
|
long int _arg0 = (long int) (arg0); \
|
|
|
|
long int _arg1 = (long int) (arg1); \
|
|
|
|
long int _arg2 = (long int) (arg2); \
|
|
|
|
long int _arg3 = (long int) (arg3); \
|
|
|
|
long int _arg4 = (long int) (arg4); \
|
|
|
|
long int _arg5 = (long int) (arg5); \
|
2018-01-29 18:27:52 +00:00
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
2020-02-10 13:32:14 +00:00
|
|
|
register long int __a0 asm ("a0") = _arg0; \
|
|
|
|
register long int __a1 asm ("a1") = _arg1; \
|
|
|
|
register long int __a2 asm ("a2") = _arg2; \
|
|
|
|
register long int __a3 asm ("a3") = _arg3; \
|
|
|
|
register long int __a4 asm ("a4") = _arg4; \
|
|
|
|
register long int __a5 asm ("a5") = _arg5; \
|
2018-01-29 18:27:52 +00:00
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "+r" (__a0) \
|
|
|
|
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), \
|
|
|
|
"r" (__a4), "r" (__a5) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
# define internal_syscall7(number, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
|
2018-01-29 18:27:52 +00:00
|
|
|
({ \
|
|
|
|
long int _sys_result; \
|
2020-02-10 13:32:14 +00:00
|
|
|
long int _arg0 = (long int) (arg0); \
|
|
|
|
long int _arg1 = (long int) (arg1); \
|
|
|
|
long int _arg2 = (long int) (arg2); \
|
|
|
|
long int _arg3 = (long int) (arg3); \
|
|
|
|
long int _arg4 = (long int) (arg4); \
|
|
|
|
long int _arg5 = (long int) (arg5); \
|
|
|
|
long int _arg6 = (long int) (arg6); \
|
2018-01-29 18:27:52 +00:00
|
|
|
\
|
|
|
|
{ \
|
|
|
|
register long int __a7 asm ("a7") = number; \
|
2020-02-10 13:32:14 +00:00
|
|
|
register long int __a0 asm ("a0") = _arg0; \
|
|
|
|
register long int __a1 asm ("a1") = _arg1; \
|
|
|
|
register long int __a2 asm ("a2") = _arg2; \
|
|
|
|
register long int __a3 asm ("a3") = _arg3; \
|
|
|
|
register long int __a4 asm ("a4") = _arg4; \
|
|
|
|
register long int __a5 asm ("a5") = _arg5; \
|
|
|
|
register long int __a6 asm ("a6") = _arg6; \
|
2018-01-29 18:27:52 +00:00
|
|
|
__asm__ volatile ( \
|
|
|
|
"scall\n\t" \
|
|
|
|
: "+r" (__a0) \
|
|
|
|
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), \
|
|
|
|
"r" (__a4), "r" (__a5), "r" (__a6) \
|
|
|
|
: __SYSCALL_CLOBBERS); \
|
|
|
|
_sys_result = __a0; \
|
|
|
|
} \
|
|
|
|
_sys_result; \
|
|
|
|
})
|
|
|
|
|
|
|
|
# define __SYSCALL_CLOBBERS "memory"
|
|
|
|
|
|
|
|
extern long int __syscall_error (long int neg_errno);
|
|
|
|
|
|
|
|
#endif /* ! __ASSEMBLER__ */
|
|
|
|
|
|
|
|
/* Pointer mangling is not supported. */
|
|
|
|
#define PTR_MANGLE(var) (void) (var)
|
|
|
|
#define PTR_DEMANGLE(var) (void) (var)
|
|
|
|
|
|
|
|
#endif /* linux/riscv/sysdep.h */
|