summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/powerpc/bits/syscalls.h
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-07-22 17:10:30 +0000
committerEric Andersen <andersen@codepoet.org>2002-07-22 17:10:30 +0000
commit72677cc3d8403da4b35c99617352bde347780222 (patch)
tree7d5d29cc3f49a1b69f90ca9ae6fbf3f61e81b1ce /libc/sysdeps/linux/powerpc/bits/syscalls.h
parent980e7850176c30ba374a706298b2865f387ec2ae (diff)
Rework syscall handling. Rewrite syscall handlers for x86 and ARM.
Prepare to kill the UNIFIED_SYSCALL option and instead have it be a per arch thing that is either enabled or not for that arch. -Erik
Diffstat (limited to 'libc/sysdeps/linux/powerpc/bits/syscalls.h')
-rw-r--r--libc/sysdeps/linux/powerpc/bits/syscalls.h170
1 files changed, 23 insertions, 147 deletions
diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h
index 93c0f3f48..6efff713e 100644
--- a/libc/sysdeps/linux/powerpc/bits/syscalls.h
+++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h
@@ -1,152 +1,20 @@
-#include <asm/unistd.h>
-
-#undef __NR
-#define __NR(n) #n
-
-#undef __syscall_return
-#define __syscall_return(type) \
- return (__sc_err & 0x10000000 ? errno = __sc_ret, __sc_ret = -1 : 0), \
- (type) __sc_ret
-
-#undef __syscall_clobbers
-#define __syscall_clobbers \
- "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
-
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void) \
-{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
-}
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
+#ifndef _SYSCALL_H
+# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
+#endif
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
-}
+#include <features.h>
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1, type2 arg2) \
-{ \
- 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"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __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) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1, type2 arg2, type3 arg3) \
-{ \
- 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"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_5 = (unsigned long) (arg3); \
- __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) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
- 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"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_5 = (unsigned long) (arg3); \
- __sc_6 = (unsigned long) (arg4); \
- __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) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
-}
+/* Do something very evil for now. Until we create our own syscall
+ * macros, short circuit bits/syscall.h and use asm/unistd.h instead */
+#define _BITS_SYSCALL_H
+#include <asm/unistd.h>
-#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) \
+/* 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; \
{ \
@@ -156,12 +24,14 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
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" \
@@ -171,10 +41,16 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
"r" (__sc_4), \
"r" (__sc_5), \
"r" (__sc_6), \
- "r" (__sc_7) \
+ "r" (__sc_7), \
+ "r" (__sc_8) \
: __syscall_clobbers); \
__sc_ret = __sc_3; \
__sc_err = __sc_0; \
} \
__syscall_return (type); \
}
+
+
+
+#endif /* _BITS_SYSCALLS_H */
+