mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: "Willy Tarreau" <w@1wt.eu>, "Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-kernel@vger.kernel.org,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: [PATCH 10/10] tools/nolibc: move wait() and friends to sys/wait.h
Date: Wed, 16 Apr 2025 14:06:25 +0200	[thread overview]
Message-ID: <20250416-nolibc-split-sys-v1-10-a069a3f1d145@linutronix.de> (raw)
In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de>

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 tools/include/nolibc/Makefile   |  1 +
 tools/include/nolibc/nolibc.h   |  1 +
 tools/include/nolibc/sys.h      | 53 ------------------------------
 tools/include/nolibc/sys/wait.h | 71 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 53 deletions(-)

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index fec0d4eb2119c8ad2bf65d386b8b5799adf0be5c..b5d4479abc3b727b6260b9c6ecd34d2b25906c2b 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -50,6 +50,7 @@ all_files := \
 		sys/syscall.h \
 		sys/time.h \
 		sys/types.h \
+		sys/wait.h \
 		time.h \
 		types.h \
 		unistd.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index d84e8610bf1081bc92d969ab760d8277e25a5174..e8843880e4dfca54dcd3f2aec33dab83cb25c17c 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -101,6 +101,7 @@
 #include "sys/stat.h"
 #include "sys/syscall.h"
 #include "sys/time.h"
+#include "sys/wait.h"
 #include "ctype.h"
 #include "elf.h"
 #include "signal.h"
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index aab0685af84f46298aae37e5a1bfecb07861db33..d07456d6e5727cdcb2d4f49c0de73568207a6331 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -1054,59 +1054,6 @@ int unlink(const char *path)
 }
 
 
-/*
- * pid_t wait(int *status);
- * pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
- * pid_t waitpid(pid_t pid, int *status, int options);
- */
-
-static __attribute__((unused))
-pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage)
-{
-#ifdef __NR_wait4
-	return my_syscall4(__NR_wait4, pid, status, options, rusage);
-#else
-	return __nolibc_enosys(__func__, pid, status, options, rusage);
-#endif
-}
-
-static __attribute__((unused))
-pid_t wait(int *status)
-{
-	return __sysret(sys_wait4(-1, status, 0, NULL));
-}
-
-static __attribute__((unused))
-pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage)
-{
-	return __sysret(sys_wait4(pid, status, options, rusage));
-}
-
-
-static __attribute__((unused))
-pid_t waitpid(pid_t pid, int *status, int options)
-{
-	return __sysret(sys_wait4(pid, status, options, NULL));
-}
-
-
-/*
- * int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
- */
-
-static __attribute__((unused))
-int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage)
-{
-	return my_syscall5(__NR_waitid, which, pid, infop, options, rusage);
-}
-
-static __attribute__((unused))
-int waitid(int which, pid_t pid, siginfo_t *infop, int options)
-{
-	return __sysret(sys_waitid(which, pid, infop, options, NULL));
-}
-
-
 /*
  * ssize_t write(int fd, const void *buf, size_t count);
  */
diff --git a/tools/include/nolibc/sys/wait.h b/tools/include/nolibc/sys/wait.h
new file mode 100644
index 0000000000000000000000000000000000000000..1af366a63f2079af587d74389530dbcc9cfb588a
--- /dev/null
+++ b/tools/include/nolibc/sys/wait.h
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * wait definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+#ifndef _NOLIBC_SYS_WAIT_H
+#define _NOLIBC_SYS_WAIT_H
+
+#include "../arch.h"
+#include "../std.h"
+#include "../types.h"
+
+/*
+ * pid_t wait(int *status);
+ * pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
+ * pid_t waitpid(pid_t pid, int *status, int options);
+ */
+
+static __attribute__((unused))
+pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage)
+{
+#ifdef __NR_wait4
+	return my_syscall4(__NR_wait4, pid, status, options, rusage);
+#else
+	return __nolibc_enosys(__func__, pid, status, options, rusage);
+#endif
+}
+
+static __attribute__((unused))
+pid_t wait(int *status)
+{
+	return __sysret(sys_wait4(-1, status, 0, NULL));
+}
+
+static __attribute__((unused))
+pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage)
+{
+	return __sysret(sys_wait4(pid, status, options, rusage));
+}
+
+
+static __attribute__((unused))
+pid_t waitpid(pid_t pid, int *status, int options)
+{
+	return __sysret(sys_wait4(pid, status, options, NULL));
+}
+
+
+/*
+ * int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
+ */
+
+static __attribute__((unused))
+int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage)
+{
+	return my_syscall5(__NR_waitid, which, pid, infop, options, rusage);
+}
+
+static __attribute__((unused))
+int waitid(int which, pid_t pid, siginfo_t *infop, int options)
+{
+	return __sysret(sys_waitid(which, pid, infop, options, NULL));
+}
+
+
+
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
+#endif /* _NOLIBC_SYS_WAIT_H */

-- 
2.49.0


  parent reply	other threads:[~2025-04-16 12:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 12:06 [PATCH 00/10] tools/nolibc: split out functionality into new headers Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 01/10] tools/nolibc: prepare for headers in subdirectories Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 02/10] tools/nolibc: add elf.h Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 03/10] tools/nolibc: move open() and friends to fcntl.h Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 04/10] tools/nolibc: move getauxval() to sys/auxv.h Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 05/10] tools/nolibc: move mmap() and friends to sys/mman.h Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 06/10] tools/nolibc: move stat() and friends to sys/stat.h Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 07/10] tools/nolibc: move syscall() to sys/syscall.h Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 08/10] tools/nolibc: move gettimeofday() to sys/time.h Thomas Weißschuh
2025-04-16 12:06 ` [PATCH 09/10] tools/nolibc: add sys/types.h shim Thomas Weißschuh
2025-04-16 12:06 ` Thomas Weißschuh [this message]
2025-04-19  9:02 ` [PATCH 00/10] tools/nolibc: split out functionality into new headers Willy Tarreau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250416-nolibc-split-sys-v1-10-a069a3f1d145@linutronix.de \
    --to=thomas.weissschuh@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®