]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
26836620f28c976009a62a2fd4048595ebda9335
1 /* Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
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 <https://www.gnu.org/licenses/>. */
19 #ifndef _LINUX_S390_SYSDEP_H
20 #define _LINUX_S390_SYSDEP_H
22 #include <sysdeps/s390/s390-32/sysdep.h>
23 #include <sysdeps/unix/sysdep.h>
24 #include <sysdeps/unix/sysv/linux/s390/sysdep.h>
25 #include <sysdeps/unix/sysv/linux/sysdep.h>
26 #include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
29 /* For Linux we can use the system call table in the header file
30 /usr/include/asm/unistd.h
31 of the kernel. But these symbols do not follow the SYS_* syntax
32 so we have to redefine the `SYS_ify' macro here. */
33 /* in newer 2.1 kernels __NR_syscall is missing so we define it here */
34 #define __NR_syscall 0
38 /* Linux uses a negative return value to indicate syscall errors, unlike
39 most Unices, which use the condition codes' carry flag.
41 Since version 2.1 the return value of a system call might be negative
42 even if the call succeeded. E.g., the `lseek' system call might return
43 a large offset. Therefore we must not anymore test for < 0, but test
44 for a real error by making sure the value in gpr2 is a real error
45 number. Linus said he will make sure that no syscall returns a value
46 in -1 .. -4095 as a valid result so we can savely test with -4095. */
49 #define PSEUDO(name, syscall_name, args) \
52 DO_CALL (syscall_name, args); \
55 jnl SYSCALL_ERROR_LABEL
58 #define PSEUDO_END(name) \
59 SYSCALL_ERROR_HANDLER; \
63 #define PSEUDO_NOERRNO(name, syscall_name, args) \
66 DO_CALL (syscall_name, args)
68 #undef PSEUDO_END_NOERRNO
69 #define PSEUDO_END_NOERRNO(name) \
73 #define PSEUDO_ERRVAL(name, syscall_name, args) \
76 DO_CALL (syscall_name, args); \
79 #undef PSEUDO_END_ERRVAL
80 #define PSEUDO_END_ERRVAL(name) \
83 #undef SYSCALL_ERROR_LABEL
85 # undef SYSCALL_ERROR_LABEL
86 # define SYSCALL_ERROR_LABEL 0f
87 # define SYSCALL_ERROR_HANDLER \
89 1: l %r1,2f-1b(%r1); \
91 2: .long syscall_error
93 # if RTLD_PRIVATE_ERRNO
94 # undef SYSCALL_ERROR_LABEL
95 # define SYSCALL_ERROR_LABEL 0f
96 # define SYSCALL_ERROR_HANDLER \
98 1: al %r1,2f-1b(%r1); \
103 2: .long rtld_errno-1b
104 # elif defined _LIBC_REENTRANT
106 # define SYSCALL_ERROR_ERRNO __libc_errno
108 # define SYSCALL_ERROR_ERRNO errno
110 # undef SYSCALL_ERROR_LABEL
111 # define SYSCALL_ERROR_LABEL 0f
112 # define SYSCALL_ERROR_HANDLER \
115 1: al %r1,2f-1b(%r1); \
116 l %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1); \
121 2: .long _GLOBAL_OFFSET_TABLE_-1b
123 # undef SYSCALL_ERROR_LABEL
124 # define SYSCALL_ERROR_LABEL 0f
125 # define SYSCALL_ERROR_HANDLER \
127 1: al %r1,2f-1b(%r1); \
128 l %r1,errno@GOT(%r1); \
133 2: .long _GLOBAL_OFFSET_TABLE_-1b
134 # endif /* _LIBC_REENTRANT */
137 /* Linux takes system call arguments in registers:
139 syscall number 1 call-clobbered
140 arg 1 2 call-clobbered
141 arg 2 3 call-clobbered
142 arg 3 4 call-clobbered
143 arg 4 5 call-clobbered
147 (Of course a function with say 3 arguments does not have entries for
149 For system calls with 6 parameters a stack operation is required
150 to load the 6th parameter to register 7. Call saved register 7 is
151 moved to register 0 and back to avoid an additional stack frame.
154 #define DO_CALL(syscall, args) \
159 .if SYS_ify (syscall) < 256; \
160 svc SYS_ify (syscall); \
162 lhi %r1,SYS_ify (syscall); \
172 #define ret_NOERRNO \
180 # undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
181 # define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
183 #endif /* __ASSEMBLER__ */
185 /* Pointer mangling support. */
187 /* We cannot use the thread descriptor because in ld.so we use setjmp
188 earlier than the descriptor is initialized. */
190 /* For the time being just use stack_guard rather than a separate
192 # ifdef __ASSEMBLER__
193 # define PTR_MANGLE(reg, tmpreg) \
195 x reg,STACK_GUARD(tmpreg)
196 # define PTR_MANGLE2(reg, tmpreg) \
197 x reg,STACK_GUARD(tmpreg)
198 # define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
200 # define PTR_MANGLE(var) \
201 (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
202 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
206 #endif /* _LINUX_S390_SYSDEP_H */