From a8d9ee1f663268a01583923a792d5ede5cd4a0f8 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sun, 15 Jun 2003 01:08:45 +0000 Subject: Implement syscall() for powerpc. Fixup syscall code so it compiles properly with gcc 3.3. -Erik --- libc/sysdeps/linux/powerpc/Makefile | 3 +- libc/sysdeps/linux/powerpc/_mmap.c | 2 +- libc/sysdeps/linux/powerpc/bits/syscalls.h | 25 +++++++++-------- libc/sysdeps/linux/powerpc/syscall.S | 45 ++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 libc/sysdeps/linux/powerpc/syscall.S (limited to 'libc') diff --git a/libc/sysdeps/linux/powerpc/Makefile b/libc/sysdeps/linux/powerpc/Makefile index 8e979a1e8..e19da0fba 100644 --- a/libc/sysdeps/linux/powerpc/Makefile +++ b/libc/sysdeps/linux/powerpc/Makefile @@ -24,7 +24,8 @@ CRT0_SRC = crt0.S CRT0_OBJ = crt0.o crt1.o gcrt1.o CRT0_DEPS=gmon-start.S -SSRC=__longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S clone.S __uClibc_syscall.S +SSRC=__longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \ + clone.S __uClibc_syscall.S syscall.S ifeq ($(strip $(UCLIBC_PROFILING)),y) SSRC+=mcount.S endif diff --git a/libc/sysdeps/linux/powerpc/_mmap.c b/libc/sysdeps/linux/powerpc/_mmap.c index 350f4c49e..ec4bfd1f9 100644 --- a/libc/sysdeps/linux/powerpc/_mmap.c +++ b/libc/sysdeps/linux/powerpc/_mmap.c @@ -5,7 +5,7 @@ #include #define __syscall_clobbers \ - "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" + "r9", "r10", "r11", "r12" #define __syscall_return(type) \ return (__sc_err & 0x10000000 ? errno = __sc_ret, __sc_ret = -1 : 0), \ (type) __sc_ret diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h index ec9e8507f..ac7395097 100644 --- a/libc/sysdeps/linux/powerpc/bits/syscalls.h +++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h @@ -11,30 +11,31 @@ #include -#define STRINGIFY(s) STRINGIFY2 (s) -#define STRINGIFY2(s) #s +#define __STRINGIFY(s) __STRINGIFY2 (s) +#define __STRINGIFY2(s) #s +#undef JUMPTARGET #ifdef __PIC__ -#define JUMPTARGET(name) STRINGIFY(name##@plt) +#define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall@plt) #else -#define JUMPTARGET(name) STRINGIFY(name) +#define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall) #endif #define unified_syscall_body(name) \ __asm__ ( \ ".section \".text\"\n\t" \ ".align 2\n\t" \ - ".globl " STRINGIFY(name) "\n\t" \ - ".type " STRINGIFY(name) ",@function\n" \ - #name":\n\tli 0," STRINGIFY(__NR_##name) "\n\t" \ - "b " JUMPTARGET(__uClibc_syscall) "\n" \ - ".Lfe1" STRINGIFY(name) ":\n\t" \ - ".size\t" STRINGIFY(name) ",.Lfe1" STRINGIFY(name) "-" STRINGIFY(name) "\n" \ + ".globl " __STRINGIFY(name) "\n\t" \ + ".type " __STRINGIFY(name) ",@function\n\t" \ + #name":\n\tli 0," __STRINGIFY(__NR_##name) "\n\t" \ + "b " __MAKE_SYSCALL "\n\t" \ + ".Lfe1" __STRINGIFY(name) ":\n\t" \ + ".size\t" __STRINGIFY(name) ",.Lfe1" __STRINGIFY(name) "-" __STRINGIFY(name) "\n" \ ) #undef _syscall0 -#define _syscall0(type,name) \ -type name(void); \ +#define _syscall0(type,name) \ +type name(void); \ unified_syscall_body(name) #undef _syscall1 diff --git a/libc/sysdeps/linux/powerpc/syscall.S b/libc/sysdeps/linux/powerpc/syscall.S new file mode 100644 index 000000000..71f711931 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/syscall.S @@ -0,0 +1,45 @@ +/* Copyright (C) 1991, 1992, 1997, 1999 Free Software Foundation, Inc. + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + + .section ".text" + .globl syscall; + .type syscall,@function; + .align 2; + +.globl syscall; +.type syscall,@function; +.align 2; + +syscall: + mr 0,3 + mr 3,4 + mr 4,5 + mr 5,6 + mr 6,7 + mr 7,8 + sc + bnslr; +#ifdef __PIC__ + b __syscall_error@plt +#else + b __syscall_error +#endif + +.size syscall,.-syscall -- cgit v1.2.3