|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH 07/10] lib/syscall_shim: introduce syscalls macro layer
On 04.06.19 18:28, Yuri Volchkov wrote: To provide a syscall user needs to use macro UK_SYSCALL_PROTO. The syntax is the following: Hum, is UK_SYSCALL_PROTO the right name? I saw that is called UK_SYSCALL_DEFINE() in patch number 8.
Doesn't essentials.h need to be included to have the UK_CONCAT macro populated? + +#define __uk_scc(X) ((long) (X)) +typedef long syscall_arg_t; + +#define __uk_syscall(syscall_nr, ...) \ + UK_CONCAT(uk_syscall_fn_, syscall_nr) (__VA_ARGS__) + +#define __uk_syscall0(n) __uk_syscall(n) +#define __uk_syscall1(n,a) __uk_syscall(n,__uk_scc(a)) +#define __uk_syscall2(n,a,b) __uk_syscall(n,__uk_scc(a),__uk_scc(b)) +#define __uk_syscall3(n,a,b,c) __uk_syscall(n,__uk_scc(a),__uk_scc(b),__uk_scc(c)) +#define __uk_syscall4(n,a,b,c,d) __uk_syscall(n,__uk_scc(a),__uk_scc(b),__uk_scc(c),__uk_scc(d)) +#define __uk_syscall5(n,a,b,c,d,e) __uk_syscall(n,__uk_scc(a),__uk_scc(b),__uk_scc(c),__uk_scc(d),__uk_scc(e)) +#define __uk_syscall6(n,a,b,c,d,e,f) __uk_syscall(n,__uk_scc(a),__uk_scc(b),__uk_scc(c),__uk_scc(d),__uk_scc(e),__uk_scc(f)) +#define __uk_syscall7(n,a,b,c,d,e,f,g) (__uk_syscall)(n,__uk_scc(a),__uk_scc(b),__uk_scc(c),__uk_scc(d),__uk_scc(e),__uk_scc(f),__uk_scc(g)) + + +#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_DEF_NARGS_X(z, a1,a2, b1,b2, c1,c2, d1,d2, e1,e2, f1,f2, g1,g2, nr, ...) nr +#define __SYSCALL_DEF_NARGS(...) __SYSCALL_DEF_NARGS_X(__VA_ARGS__, 7,7, 6,6, 5,5, 4,4, 3,3, 2,2, 1,1,0) + +#define __UK_NAME2SCALL_FN(name) UK_CONCAT(uk_syscall_, name) + +#define UK_ARG_MAP1(m, type, arg) m(type, arg) +#define UK_ARG_MAP2(m, type, arg, ...) m(type, arg), UK_ARG_MAP1(m, __VA_ARGS__) +#define UK_ARG_MAP3(m, type, arg, ...) m(type, arg), UK_ARG_MAP2(m, __VA_ARGS__) +#define UK_ARG_MAP4(m, type, arg, ...) m(type, arg), UK_ARG_MAP3(m, __VA_ARGS__) +#define UK_ARG_MAP5(m, type, arg, ...) m(type, arg), UK_ARG_MAP4(m, __VA_ARGS__) +#define UK_ARG_MAP6(m, type, arg, ...) m(type, arg), UK_ARG_MAP5(m, __VA_ARGS__) +#define UK_ARG_MAP7(m, type, arg, ...) m(type, arg), UK_ARG_MAP6(m, __VA_ARGS__) +#define UK_ARG_MAPx(nr_args, ...) UK_CONCAT(UK_ARG_MAP, nr_args)(__VA_ARGS__) + +#define S_ARG_LONG(type, arg) unsigned long arg +#define S_ARG_ACTUAL(type, arg) type arg +#define S_ARG_CAST(type, arg) (type) arg + + +#ifdef CONFIG_LIBSYSCALL_SHIM +#define __UK_SYSCALL_DEFINE(x, name, ...) \ + static inline long __##name(UK_ARG_MAPx(x, S_ARG_ACTUAL, __VA_ARGS__)); \ + int name(UK_ARG_MAPx(x, S_ARG_LONG, __VA_ARGS__)) \ In this type casting wrapper, shouldn't this `int` be a `long` instead? Hum, since your shim layer is mimicking Linux's userspace sys call wrapper (<sys/syscall.h>), it is expected that a syscall function handles errno and returns -1 in error cases. I suggest that you add a comment to UK_SYSCALL_DEFINE() so that everyone that implements such a system call is not getting confused with what a syscall in the kernel means in terms of return values and arguments. Could you also write that the return type is `long` on such a defined function? This is kind of hidden in the UK_SYSCALL_DEFINE() macro. + + +#ifdef CONFIG_LIBSYSCALL_SHIM +#include <uk/bits/syscall_nrs.h> +#include <uk/bits/syscall_map.h> +#include <uk/bits/provided_syscalls.h> +#include <uk/bits/syscall_stubs.h> + +#define syscall(...) \ + UK_CONCAT(__uk_syscall, __SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__) +#endif + +#endif /* __UK_SYSCALL_H__ */ _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |