chiark / gitweb /
[PATCH] volume-id build fix and update
[elogind.git] / klibc / klibc / arch / x86_64 / include / klibc / archsys.h
index 3bd8b0a5d9862efe8b0029e8c385ee61ca5e8478..2ec72cd397b2cc5178db4151456678ea2361ba96 100644 (file)
@@ -7,9 +7,88 @@
 #ifndef _KLIBC_ARCHSYS_H
 #define _KLIBC_ARCHSYS_H
 
-/* x86-64 seems to miss _syscall6() from its headers */
+/* The x86-64 syscall headers are needlessly inefficient */
 
-#ifndef _syscall6
+#undef _syscall0
+#undef _syscall1
+#undef _syscall2
+#undef _syscall3
+#undef _syscall4
+#undef _syscall5
+#undef _syscall6
+
+#define _syscall0(type,name) \
+type name (void) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+        : "=a" (__res) \
+        : "0" (__NR_##name) \
+        : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type name (type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+        : "=a" (__res) \
+        : "0" (__NR_##name),"D" (arg1) \
+        : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name (type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+        : "=a" (__res) \
+        : "0" (__NR_##name),"D" (arg1),"S" (arg2) \
+        : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name (type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+        : "=a" (__res) \
+        : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+          "d" (arg3) \
+        : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+__asm__ volatile (__syscall \
+        : "=a" (__res) \
+        : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+          "d" (arg3),"r" (__r10) \
+        : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#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) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+register type5 __r8  asm("%r8")  = arg5; \
+__asm__ volatile (__syscall \
+        : "=a" (__res) \
+        : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+          "d" (arg3),"r" (__r10),"r" (__r8) \
+        : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
 
 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
           type5,arg5,type6,arg6) \
@@ -27,6 +106,4 @@ __asm__ volatile (__syscall \
 __syscall_return(type,__res); \
 }
 
-#endif /* _syscall6 missing */
-
 #endif /* _KLIBC_ARCHSYS_H */