From 82a975f2f2671f0fb54ccc56d3cc621dad8b645b Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 15 Nov 2002 14:12:12 +0000 Subject: This draws from an old patch by David Blythe for the now-dead unified syscall interface. I reworked his old patch considerably and cleaned up his version of bits/syscalls.h with some sneaky macro magic. And I implemented a powerpc correct version of pread/pwrite -Erik --- libc/sysdeps/linux/powerpc/bits/syscalls.h | 99 +++++++++++++++++------------- 1 file changed, 55 insertions(+), 44 deletions(-) (limited to 'libc/sysdeps/linux/powerpc/bits/syscalls.h') diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h index 6b11315e2..f2a1b6da4 100644 --- a/libc/sysdeps/linux/powerpc/bits/syscalls.h +++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h @@ -1,60 +1,71 @@ #ifndef _BITS_SYSCALLS_H #define _BITS_SYSCALLS_H + #ifndef _SYSCALL_H # error "Never use directly; include instead." #endif -#include - -/* Do something very evil for now. Until we create our own syscall - * macros, short circuit bits/sysnum.h and use asm/unistd.h instead */ -#include - /* This includes the `__NR_' syscall numbers taken from the Linux kernel * header files. It also defines the traditional `SYS_' macros for older * programs. */ #include -/* The kernel includes don't provide _syscall6, so provide our own */ -#undef _syscall6 -#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \ -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ -{ \ - unsigned long __sc_ret, __sc_err; \ - { \ - register unsigned long __sc_0 __asm__ ("r0"); \ - register unsigned long __sc_3 __asm__ ("r3"); \ - register unsigned long __sc_4 __asm__ ("r4"); \ - register unsigned long __sc_5 __asm__ ("r5"); \ - register unsigned long __sc_6 __asm__ ("r6"); \ - register unsigned long __sc_7 __asm__ ("r7"); \ - register unsigned long __sc_8 __asm__ ("r8"); \ - \ - __sc_3 = (unsigned long) (arg1); \ - __sc_4 = (unsigned long) (arg2); \ - __sc_5 = (unsigned long) (arg3); \ - __sc_6 = (unsigned long) (arg4); \ - __sc_7 = (unsigned long) (arg5); \ - __sc_8 = (unsigned long) (arg6); \ - __sc_0 = __NR_##name; \ - __asm__ __volatile__ \ - ("sc \n\t" \ - "mfcr %1 " \ - : "=&r" (__sc_3), "=&r" (__sc_0) \ - : "0" (__sc_3), "1" (__sc_0), \ - "r" (__sc_4), \ - "r" (__sc_5), \ - "r" (__sc_6), \ - "r" (__sc_7), \ - "r" (__sc_8) \ - : __syscall_clobbers); \ - __sc_ret = __sc_3; \ - __sc_err = __sc_0; \ - } \ - __syscall_return (type); \ -} +#define STRINGIFY(s) STRINGIFY2 (s) +#define STRINGIFY2(s) #s + +#ifdef __PIC__ +#define JUMPTARGET(name) STRINGIFY(name##@plt) +#else +#define JUMPTARGET(name) STRINGIFY(name) +#endif + +#define unified_syscall_body(name) \ + __asm__ ( \ + ".section \".text\"\n\t" \ + ".align 2\n\t" \ + ".globl "###name"\n\t" \ + ".type "###name",@function\n" \ + #name":\n\tli 0," STRINGIFY(__NR_##name) "\n\t" \ + "b "JUMPTARGET(__uClibc_syscall)"\n" \ + ".Lfe1"###name":\n\t" \ + ".size\t"###name ",.Lfe1"###name"-"###name"\n" \ + ) +#undef _syscall0 +#define _syscall0(type,name) \ +type name(void); \ +unified_syscall_body(name) + +#undef _syscall1 +#define _syscall1(type,name,type1,arg1) \ +type name(type1 arg1); \ +unified_syscall_body(name) + +#undef _syscall2 +#define _syscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 arg1, type2 arg2); \ +unified_syscall_body(name) + +#undef _syscall3 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type name(type1 arg1, type2 arg2, type3 arg3); \ +unified_syscall_body(name) + +#undef _syscall4 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4); \ +unified_syscall_body(name) + +#undef _syscall5 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5); \ +unified_syscall_body(name) + +#undef _syscall6 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \ +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6); \ +unified_syscall_body(name) #endif /* _BITS_SYSCALLS_H */ -- cgit v1.2.3