]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
tools/nolibc: move gettimeofday() to sys/time.h
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Wed, 16 Apr 2025 12:06:23 +0000 (14:06 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Sat, 19 Apr 2025 12:22:28 +0000 (14:22 +0200)
This is the location regular userspace expects this definition.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-8-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/include/nolibc/Makefile
tools/include/nolibc/nolibc.h
tools/include/nolibc/sys.h
tools/include/nolibc/sys/time.h [new file with mode: 0644]

index 65c3b90f8ba9213401900a8568469bb2c5770dd6..fd1fc769cbbea7c6af998630020d6d621505f2a1 100644 (file)
@@ -48,6 +48,7 @@ all_files := \
                sys/mman.h \
                sys/stat.h \
                sys/syscall.h \
+               sys/time.h \
                time.h \
                types.h \
                unistd.h \
index cb5705d55d80862b0c942bffb6c38db7626aac86..d84e8610bf1081bc92d969ab760d8277e25a5174 100644 (file)
 #include "sys/mman.h"
 #include "sys/stat.h"
 #include "sys/syscall.h"
+#include "sys/time.h"
 #include "ctype.h"
 #include "elf.h"
 #include "signal.h"
index c76dc80147281041afa1cb443d01897d186f7168..aab0685af84f46298aae37e5a1bfecb07861db33 100644 (file)
@@ -487,27 +487,6 @@ int getpagesize(void)
 }
 
 
-/*
- * int gettimeofday(struct timeval *tv, struct timezone *tz);
- */
-
-static __attribute__((unused))
-int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
-{
-#ifdef __NR_gettimeofday
-       return my_syscall2(__NR_gettimeofday, tv, tz);
-#else
-       return __nolibc_enosys(__func__, tv, tz);
-#endif
-}
-
-static __attribute__((unused))
-int gettimeofday(struct timeval *tv, struct timezone *tz)
-{
-       return __sysret(sys_gettimeofday(tv, tz));
-}
-
-
 /*
  * uid_t getuid(void);
  */
diff --git a/tools/include/nolibc/sys/time.h b/tools/include/nolibc/sys/time.h
new file mode 100644 (file)
index 0000000..1d326c0
--- /dev/null
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * time definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+#ifndef _NOLIBC_SYS_TIME_H
+#define _NOLIBC_SYS_TIME_H
+
+#include "../arch.h"
+#include "../sys.h"
+
+/*
+ * int gettimeofday(struct timeval *tv, struct timezone *tz);
+ */
+
+static __attribute__((unused))
+int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+#ifdef __NR_gettimeofday
+       return my_syscall2(__NR_gettimeofday, tv, tz);
+#else
+       return __nolibc_enosys(__func__, tv, tz);
+#endif
+}
+
+static __attribute__((unused))
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+       return __sysret(sys_gettimeofday(tv, tz));
+}
+
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
+#endif /* _NOLIBC_SYS_TIME_H */