diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux/s390/sysdep.h')
-rw-r--r-- | sysdeps/unix/sysv/linux/s390/sysdep.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h index 33ed86f252..7731d2ec7f 100644 --- a/sysdeps/unix/sysv/linux/s390/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/sysdep.h @@ -16,6 +16,107 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#ifndef __ASSEMBLY__ + +#undef SYS_ify +#define SYS_ify(syscall_name) __NR_##syscall_name + +#undef INLINE_SYSCALL +#define INLINE_SYSCALL(name, nr, args...) \ + ({ \ + long int _ret = INTERNAL_SYSCALL (name, , nr, args); \ + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, ))) \ + { \ + __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, )); \ + _ret = -1; \ + } \ + _ret; }) + +#undef INTERNAL_SYSCALL_DECL +#define INTERNAL_SYSCALL_DECL(err) do { } while (0) + +#undef INTERNAL_SYSCALL_DIRECT +#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...) \ + ({ \ + DECLARGS_##nr(args) \ + register long int _ret __asm__("2"); \ + __asm__ __volatile__ ( \ + "svc %b1\n\t" \ + : "=d" (_ret) \ + : "i" (__NR_##name) ASMFMT_##nr \ + : "memory" ); \ + _ret; }) + +#undef INTERNAL_SYSCALL_SVC0 +#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...) \ + ({ \ + DECLARGS_##nr(args) \ + register unsigned long int _nr __asm__("1") = \ + (unsigned long int)(__NR_##name); \ + register long int _ret __asm__("2"); \ + __asm__ __volatile__ ( \ + "svc 0\n\t" \ + : "=d" (_ret) \ + : "d" (_nr) ASMFMT_##nr \ + : "memory" ); \ + _ret; }) + +#undef INTERNAL_SYSCALL_NCS +#define INTERNAL_SYSCALL_NCS(no, err, nr, args...) \ + ({ \ + DECLARGS_##nr(args) \ + register unsigned long int _nr __asm__("1") = (unsigned long int)(no); \ + register long int _ret __asm__("2"); \ + __asm__ __volatile__ ( \ + "svc 0\n\t" \ + : "=d" (_ret) \ + : "d" (_nr) ASMFMT_##nr \ + : "memory" ); \ + _ret; }) + +#undef INTERNAL_SYSCALL +#define INTERNAL_SYSCALL(name, nr, args...) \ + (((__NR_##name) < 256) \ + ? INTERNAL_SYSCALL_DIRECT(name, nr, args) \ + : INTERNAL_SYSCALL_SVC0(name, nr, args)) + +#undef INTERNAL_SYSCALL_ERROR_P +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned long int) (val) > -4096UL) + +#undef INTERNAL_SYSCALL_ERRNO +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) + +#define DECLARGS_0() +#define DECLARGS_1(arg1) \ + register unsigned long int gpr2 __asm__ ("2") = (unsigned long int)(arg1); +#define DECLARGS_2(arg1, arg2) \ + DECLARGS_1(arg1) \ + register unsigned long int gpr3 __asm__ ("3") = (unsigned long int)(arg2); +#define DECLARGS_3(arg1, arg2, arg3) \ + DECLARGS_2(arg1, arg2) \ + register unsigned long int gpr4 __asm__ ("4") = (unsigned long int)(arg3); +#define DECLARGS_4(arg1, arg2, arg3, arg4) \ + DECLARGS_3(arg1, arg2, arg3) \ + register unsigned long int gpr5 __asm__ ("5") = (unsigned long int)(arg4); +#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \ + DECLARGS_4(arg1, arg2, arg3, arg4) \ + register unsigned long int gpr6 __asm__ ("6") = (unsigned long int)(arg5); +#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \ + DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \ + register unsigned long int gpr7 __asm__ ("7") = (unsigned long int)(arg6); + +#define ASMFMT_0 +#define ASMFMT_1 , "0" (gpr2) +#define ASMFMT_2 , "0" (gpr2), "d" (gpr3) +#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4) +#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5) +#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6) +#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7) + +#define SINGLE_THREAD_BY_GLOBAL 1 + + #define VDSO_NAME "LINUX_2.6.29" #define VDSO_HASH 123718585 @@ -29,3 +130,5 @@ #endif #define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday" #define HAVE_GETCPU_VSYSCALL "__kernel_getcpu" + +#endif |