diff options
Diffstat (limited to 'libc/sysdeps/linux/arm/bits/syscalls.h')
| -rw-r--r-- | libc/sysdeps/linux/arm/bits/syscalls.h | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/libc/sysdeps/linux/arm/bits/syscalls.h b/libc/sysdeps/linux/arm/bits/syscalls.h index 64c625f6d..2da150624 100644 --- a/libc/sysdeps/linux/arm/bits/syscalls.h +++ b/libc/sysdeps/linux/arm/bits/syscalls.h @@ -4,22 +4,15 @@ # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." #endif -/* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel - * header files. It also defines the traditional `SYS_<name>' macros for older - * programs. */ -#include <bits/sysnum.h> - /* Some of the sneaky macros in the code were taken from glibc-2.3.2/sysdeps/unix/sysv/linux/arm/sysdep.h */ -#ifndef __ASSEMBLER__ - -#include <errno.h> - #define SYS_ify(syscall_name) (__NR_##syscall_name) +#ifdef __ASSEMBLER__ + /* Call a given syscall, with arguments loaded. For EABI, we must save and restore r7 for the syscall number. Unlike the DO_CALL macro in glibc, this macro does not load syscall arguments. */ @@ -34,8 +27,11 @@ #define DO_CALL(syscall_name) \ swi SYS_ify (syscall_name); #endif + #else +#include <errno.h> + #undef _syscall0 #define _syscall0(type,name) \ type name(void) \ @@ -111,27 +107,50 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7) #undef INTERNAL_SYSCALL #if defined(__ARM_EABI__) +#if !defined(__thumb__) #define INTERNAL_SYSCALL(name, err, nr, args...) \ ({unsigned int _sys_result; \ { \ - register int _a1 asm ("r0"), _nr asm ("r7"); \ + register int _a1 __asm__ ("r0"), _nr __asm__ ("r7"); \ LOAD_ARGS_##nr (args) \ _nr = SYS_ify(name); \ - asm volatile ("swi 0x0 @ syscall " #name \ + __asm__ volatile ("swi 0x0 @ syscall " #name \ : "=r" (_a1) \ : "r" (_nr) ASM_ARGS_##nr \ : "memory"); \ _sys_result = _a1; \ } \ (int) _sys_result; }) +#else /* !defined(__thumb__) */ +/* So hide the use of r7 from the compiler, this would be a lot + * easier but for the fact that the syscalls can exceed 255. + * For the moment the LOAD_ARG_7 is sacrificed. + */ +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({ unsigned int _sys_result; \ + { \ + register int _a1 asm ("a1"); \ + LOAD_ARGS_##nr (args) \ + register int _v3 asm ("v3") = (int) (SYS_ify(name)); \ + asm volatile ("push {r7}\n" \ + "\tmov r7, v3\n" \ + "\tswi 0 @ syscall " #name "\n" \ + "\tpop {r7}" \ + : "=r" (_a1) \ + : "r" (_v3) ASM_ARGS_##nr \ + : "memory"); \ + _sys_result = _a1; \ + } \ + (int) _sys_result; }) +#endif /*!defined(__thumb__)*/ #else /* !defined(__ARM_EABI__) */ #if !defined(__thumb__) #define INTERNAL_SYSCALL(name, err, nr, args...) \ ({ unsigned int _sys_result; \ { \ - register int _a1 asm ("a1"); \ + register int _a1 __asm__ ("a1"); \ LOAD_ARGS_##nr (args) \ - asm volatile ("swi %1 @ syscall " #name \ + __asm__ volatile ("swi %1 @ syscall " #name \ : "=r" (_a1) \ : "i" (SYS_ify(name)) ASM_ARGS_##nr \ : "memory"); \ @@ -147,10 +166,10 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7) #define INTERNAL_SYSCALL(name, err, nr, args...) \ ({ unsigned int _sys_result; \ { \ - register int _a1 asm ("a1"); \ + register int _a1 __asm__ ("a1"); \ LOAD_ARGS_##nr (args) \ - register int _r7 asm ("r7") = (int) (SYS_ify(name)); \ - asm volatile ("swi 0 @ syscall " #name \ + register int _r7 __asm__ ("r7") = (int) (SYS_ify(name)); \ + __asm__ volatile ("swi 0 @ syscall " #name \ : "=r" (_a1) \ : "r" (_r7) ASM_ARGS_##nr \ : "memory"); \ @@ -165,10 +184,10 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7) #define INTERNAL_SYSCALL(name, err, nr, args...) \ ({ unsigned int _sys_result; \ { \ - register int _a1 asm ("a1"); \ + register int _a1 __asm__ ("a1"); \ LOAD_ARGS_##nr (args) \ - register int _v3 asm ("v3") = (int) (SYS_ify(name)); \ - asm volatile ("push {r7}\n" \ + register int _v3 __asm__ ("v3") = (int) (SYS_ify(name)); \ + __asm__ volatile ("push {r7}\n" \ "\tmov r7, v3\n" \ "\tswi 0 @ syscall " #name "\n" \ "\tpop {r7}" \ @@ -196,27 +215,27 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7) LOAD_ARGS_0 () #define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1) #define LOAD_ARGS_2(a1, a2) \ - register int _a2 asm ("a2") = (int) (a2); \ + register int _a2 __asm__ ("a2") = (int) (a2); \ LOAD_ARGS_1 (a1) #define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2) #define LOAD_ARGS_3(a1, a2, a3) \ - register int _a3 asm ("a3") = (int) (a3); \ + register int _a3 __asm__ ("a3") = (int) (a3); \ LOAD_ARGS_2 (a1, a2) #define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3) #define LOAD_ARGS_4(a1, a2, a3, a4) \ - register int _a4 asm ("a4") = (int) (a4); \ + register int _a4 __asm__ ("a4") = (int) (a4); \ LOAD_ARGS_3 (a1, a2, a3) #define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4) #define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ - register int _v1 asm ("v1") = (int) (a5); \ + register int _v1 __asm__ ("v1") = (int) (a5); \ LOAD_ARGS_4 (a1, a2, a3, a4) #define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1) #define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ - register int _v2 asm ("v2") = (int) (a6); \ + register int _v2 __asm__ ("v2") = (int) (a6); \ LOAD_ARGS_5 (a1, a2, a3, a4, a5) #define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2) #define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \ - register int _v3 asm ("v3") = (int) (a7); \ + register int _v3 __asm__ ("v3") = (int) (a7); \ LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6) #define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3) |
