1 /* Assembly macros for RISC-V.
2 Copyright (C) 2011-2018
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _LINUX_RISCV_SYSDEP_H
20 #define _LINUX_RISCV_SYSDEP_H 1
22 #include <common/sysdep.h>
23 #include <sys/syscall.h>
29 # define ENTRY(name) LEAF(name)
31 # define L(label) .L ## label
33 /* Performs a system call, handling errors by setting errno. Linux indicates
34 errors by setting a0 to a value between -1 and -4095. */
36 # define PSEUDO(name, syscall_name, args) \
40 li a7, SYS_ify (syscall_name); \
43 bgtu a0, a7, .Lsyscall_error ## name;
46 # define PSEUDO_END(sym) \
47 SYSCALL_ERROR_HANDLER (sym) \
52 # if defined (__PIC__)
53 # define SYSCALL_ERROR_HANDLER(name) \
54 .Lsyscall_error ## name: \
55 la.tls.ie t1, errno; \
61 # define SYSCALL_ERROR_HANDLER(name) \
62 .Lsyscall_error ## name: \
63 lui t1, %tprel_hi(errno); \
64 add t1, t1, tp, %tprel_add(errno); \
66 sw a0, %tprel_lo(errno)(t1); \
70 # define SYSCALL_ERROR_HANDLER(name) \
71 .Lsyscall_error ## name: \
75 /* Performs a system call, not setting errno. */
76 # undef PSEUDO_NEORRNO
77 # define PSEUDO_NOERRNO(name, syscall_name, args) \
80 li a7, SYS_ify (syscall_name); \
83 # undef PSEUDO_END_NOERRNO
84 # define PSEUDO_END_NOERRNO(name) \
88 # define ret_NOERRNO ret
90 /* Perfroms a system call, returning the error code. */
92 # define PSEUDO_ERRVAL(name, syscall_name, args) \
93 PSEUDO_NOERRNO (name, syscall_name, args) \
96 # undef PSEUDO_END_ERRVAL
97 # define PSEUDO_END_ERRVAL(name) \
101 # define ret_ERRVAL ret
103 #endif /* __ASSEMBLER__ */
105 /* In order to get __set_errno() definition in INLINE_SYSCALL. */
106 #ifndef __ASSEMBLER__
111 #define SYS_ify(syscall_name) __NR_##syscall_name
113 #ifndef __ASSEMBLER__
115 /* List of system calls which are supported as vsyscalls. */
116 # define HAVE_CLOCK_GETRES_VSYSCALL 1
117 # define HAVE_CLOCK_GETTIME_VSYSCALL 1
118 # define HAVE_GETTIMEOFDAY_VSYSCALL 1
119 # define HAVE_GETCPU_VSYSCALL 1
122 extern long int __syscall_error (long int neg_errno
);
124 #endif /* ! __ASSEMBLER__ */
126 #endif /* linux/riscv/sysdep.h */