[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/MUSL PATCH 12/19] Use syscall_shim layer instead of musl internal syscalls



wip: This commit updates include/syscall.h by including uk_syscall
from the syscall_shim layer. In this commit, musl does NOT compile.
The compilation error will be fixed in a next patch.

Signed-off-by: Gaulthier Gain <gaulthier.gain@xxxxxxxxx>
---
 include/syscall.h | 84 ++++++++++++-------------------------------------------
 1 file changed, 18 insertions(+), 66 deletions(-)

diff --git a/include/syscall.h b/include/syscall.h
index a6d921d..292f257 100644
--- a/include/syscall.h
+++ b/include/syscall.h
@@ -2,9 +2,7 @@
 #define UK_MUSL_SYSCALL
 
 #include <sys/syscall.h>
-
-#define __SYSCALL_LL_E(x) (x)
-#define __SYSCALL_LL_O(x) (x)
+#include <uk/syscall.h>
 
 #ifndef SYSCALL_RLIM_INFINITY
 #define SYSCALL_RLIM_INFINITY (~0ULL)
@@ -14,58 +12,31 @@
 #define SYSCALL_MMAP2_UNIT 4096ULL
 #endif
 
-#ifndef __SYSCALL_LL_PRW
-#define __SYSCALL_LL_PRW(x) __SYSCALL_LL_O(x)
-#endif
-
-#ifndef __scc
-#define __scc(X) ((long) (X))
-typedef long syscall_arg_t;
-#endif
-
-__attribute__((visibility("hidden")))
-long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),
-       __syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
-                    syscall_arg_t, syscall_arg_t, syscall_arg_t);
+#define syscall_cp(...) syscall(__VA_ARGS__)
+#define __syscall(...) syscall(__VA_ARGS__)
+#define __syscall_cp(...) syscall(__VA_ARGS__)
 
-long syscall(long n, ...);
-long __syscall(long n, ...);
-long __syscall0(long n);
-long __syscall1(long n, long a1);
-long __syscall2(long n, long a1, long a2);
-long __syscall3(long n, long a1, long a2, long a3);
-long __syscall4(long n, long a1, long a2, long a3, long a4);
-long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
-long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
-
-#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
-#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)
-#define __SYSCALL_CONCAT_X(a,b) a##b
-#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b)
-#define __SYSCALL_DISP(b,...) 
__SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
-
-#define socketcall __socketcall
-#define socketcall_cp __socketcall_cp
-
-#define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0)
-#define __syscall_cp1(n,a) (__syscall_cp)(n,__scc(a),0,0,0,0,0)
-#define __syscall_cp2(n,a,b) (__syscall_cp)(n,__scc(a),__scc(b),0,0,0,0)
-#define __syscall_cp3(n,a,b,c) 
(__syscall_cp)(n,__scc(a),__scc(b),__scc(c),0,0,0)
-#define __syscall_cp4(n,a,b,c,d) 
(__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),0,0)
-#define __syscall_cp5(n,a,b,c,d,e) 
(__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),0)
-#define __syscall_cp6(n,a,b,c,d,e,f) 
(__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
-
-#define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__)
-#define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))
+#define __sys_open(...) open(__VA_ARGS__)
+#define sys_open(...) open(__VA_ARGS__)
 
 #ifndef SYSCALL_USE_SOCKETCALL
 #define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_##nm, a, b, c, d, e, f)
 #define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_##nm, a, b, c, d, e, f)
 #else
 #define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_socketcall, __SC_##nm, \
-    ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f }))
+                                                 ((long [6]){ (long)a, 
(long)b, (long)c, (long)d, (long)e, (long)f }))
 #define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_socketcall, __SC_##nm, \
-    ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f }))
+                                                 ((long [6]){ (long)a, 
(long)b, (long)c, (long)d, (long)e, (long)f }))
+#endif
+
+#define socketcall __socketcall
+#define socketcall_cp __socketcall_cp
+
+#if (defined CONFIG_ARCH_X86_64)
+#define __SYSCALL_LL_E(x) (x)
+#define __SYSCALL_LL_O(x) (x)
+#else
+#error "Missing macro for architecture"
 #endif
 
 /* fixup legacy 16-bit junk */
@@ -111,7 +82,6 @@ long __syscall6(long n, long a1, long a2, long a3, long a4, 
long a5, long a6);
 #define SYS_setfsgid SYS_setfsgid32
 #endif
 
-
 /* fixup legacy 32-bit-vs-lfs64 junk */
 
 #ifdef SYS_fcntl64
@@ -217,22 +187,4 @@ long __syscall6(long n, long a1, long a2, long a3, long 
a4, long a5, long a6);
 #define __SC_recvmmsg    19
 #define __SC_sendmmsg    20
 
-#ifdef SYS_open
-#define __sys_open2(x,pn,fl) __syscall2(SYS_open, pn, (fl)|O_LARGEFILE)
-#define __sys_open3(x,pn,fl,mo) __syscall3(SYS_open, pn, (fl)|O_LARGEFILE, mo)
-#define __sys_open_cp2(x,pn,fl) __syscall_cp2(SYS_open, pn, (fl)|O_LARGEFILE)
-#define __sys_open_cp3(x,pn,fl,mo) __syscall_cp3(SYS_open, pn, 
(fl)|O_LARGEFILE, mo)
-#else
-#define __sys_open2(x,pn,fl) __syscall3(SYS_openat, AT_FDCWD, pn, 
(fl)|O_LARGEFILE)
-#define __sys_open3(x,pn,fl,mo) __syscall4(SYS_openat, AT_FDCWD, pn, 
(fl)|O_LARGEFILE, mo)
-#define __sys_open_cp2(x,pn,fl) __syscall_cp3(SYS_openat, AT_FDCWD, pn, 
(fl)|O_LARGEFILE)
-#define __sys_open_cp3(x,pn,fl,mo) __syscall_cp4(SYS_openat, AT_FDCWD, pn, 
(fl)|O_LARGEFILE, mo)
-#endif
-
-#define __sys_open(...) __SYSCALL_DISP(__sys_open,,__VA_ARGS__)
-#define sys_open(...) __syscall_ret(__sys_open(__VA_ARGS__))
-
-#define __sys_open_cp(...) __SYSCALL_DISP(__sys_open_cp,,__VA_ARGS__)
-#define sys_open_cp(...) __syscall_ret(__sys_open_cp(__VA_ARGS__))
-
 #endif
-- 
2.11.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.