In more complicated situations when single musl file calls syscall() for 2 or more system call types (like stdio/tmpnam.o), we cannot have single macro that will solve it like previous patch did.
In those cases we fallback to statically inlined functions defined for each syscall type. The defined variadic syscall/__syscall macro then delegates to relevant inlined function by concatenating 'inlined_' and syscall number constant name that is a 1st parameter to a macro. Please note that "__attribute__((always_inline))" guarantees that the calls to those functions are indeed inlines and do not incur any extra function call overhead as it was checked by disassembling tmpnam.o. Signed-off-by: Waldemar Kozaczuk <[email protected]> --- Makefile | 3 ++- libc/syscall_to_function.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f6eb21e0..1a1ef54b 100644 --- a/Makefile +++ b/Makefile @@ -1508,7 +1508,8 @@ musl += stdio/swprintf.o musl += stdio/swscanf.o musl += stdio/tempnam.o libc += stdio/tmpfile.o -libc += stdio/tmpnam.o +musl += stdio/tmpnam.o +$(out)/musl/src/stdio/tmpnam.o: CFLAGS += -D__OSV_SYS_inline_tmpnam --include libc/syscall_to_function.h musl += stdio/ungetc.o musl += stdio/ungetwc.o musl += stdio/vasprintf.o diff --git a/libc/syscall_to_function.h b/libc/syscall_to_function.h index 68922cbf..a9f9afed 100644 --- a/libc/syscall_to_function.h +++ b/libc/syscall_to_function.h @@ -14,6 +14,21 @@ #define __syscall(syscall_number, fd, cmd, args) fcntl(fd, cmd, args) #endif +#ifdef __OSV_SYS_inline_tmpnam +#include <time.h> +__attribute__((always_inline)) static inline long inlined_SYS_clock_gettime(clockid_t c, struct timespec *t, int x) +{ + return clock_gettime(c, t); +} + +__attribute__((always_inline)) static inline long inlined_SYS_access(const char *p, int i) +{ + return access(p, i); +} + +#define __syscall(sys_number, ...) (inlined_##sys_number(__VA_ARGS__)) +#endif + /* #define syscall(syscall_number, ...) \ #if syscall_number == SYS_close \ -- 2.25.1 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/20200810050225.13067-2-jwkozaczuk%40gmail.com.
