-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc][sys/wait][linux] add missing and clean up existing macros #125572
Conversation
This patch does a few things: - replace macro definitions with an inclusion of the linux/wait.h kernel header. - WNOHANG - WUNTRACED - WEXITED - WCONTINUED - WSTOPPED - P_ALL - P_PID - P_PGID - P_PIDFD - Add missing macro definitions mandated by POSIX. Some are needed to build LLVM. - WCOREDUMP - WIFCONTINUED - WIFSIGNALELD - WIFSTOPPED - WSTOPSIG - Remove glibc style __W* macros. Users should stick with the POSIX macros. We can re-add them if necessary. - __WEXITSTATUS - __WTERMSIG - __WIFEXITED - __WIFSIGNALED - __WIFSTOPPED - __WIFCONTINUED - __WCOREDUMP - __W_EXITCODE - __W_STOPCODE - __W_CONTINUED - __WCOREFLAG Fixes: llvm#124944
@llvm/pr-subscribers-libc Author: Nick Desaulniers (nickdesaulniers) ChangesThis patch does a few things:
Fixes: #124944 Full diff: https://github.com/llvm/llvm-project/pull/125572.diff 1 Files Affected:
diff --git a/libc/include/llvm-libc-macros/linux/sys-wait-macros.h b/libc/include/llvm-libc-macros/linux/sys-wait-macros.h
index c101638fdae340..d01cfa71ba3906 100644
--- a/libc/include/llvm-libc-macros/linux/sys-wait-macros.h
+++ b/libc/include/llvm-libc-macros/linux/sys-wait-macros.h
@@ -9,36 +9,19 @@
#ifndef LLVM_LIBC_MACROS_LINUX_SYS_WAIT_MACROS_H
#define LLVM_LIBC_MACROS_LINUX_SYS_WAIT_MACROS_H
-// Wait flags
-#define WNOHANG 1 // Do not block
-#define WUNTRACED 2 // Report is a child has stopped even if untraced
-#define WEXITED 4 // Report dead child
-#define WCONTINUED 8 // Report if a stopped child has been resumed by SIGCONT
-#define WSTOPPED WUNTRACED
-
-// Wait status info macros
-#define __WEXITSTATUS(status) (((status)&0xff00) >> 8)
-#define __WTERMSIG(status) ((status)&0x7f)
-#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
-
-// Macros for constructing status values.
-#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
-#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
-#define __W_CONTINUED 0xffff
-#define __WCOREFLAG 0x80
-
-#define WEXITSTATUS(status) __WEXITSTATUS(status)
-#define WTERMSIG(status) __WTERMSIG(status)
-#define WIFEXITED(status) __WIFEXITED(status)
-
-#define WCOREFLAG __WCOREFLAG
-#define W_EXITCODE(ret, sig) __W_EXITCODE(ret, sig)
-#define W_STOPCODE(sig) __W_STOPCODE(sig)
-
-// First argument to waitid:
-#define P_ALL 0
-#define P_PID 1
-#define P_PGID 2
-#define P_PIDFD 3
+#include <linux/wait.h>
+
+#define WCOREDUMP(status) ((status) & WCOREFLAG)
+#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
+#define WIFCONTINUED(status) ((status) == 0xffff)
+#define WIFEXITED(status) (WTERMSIG(status) == 0)
+#define WIFSIGNALED(status) ((WTERMSIG(status) + 1) >= 2)
+#define WIFSTOPPED(status) (WTERMSIG(status) == 0x7f)
+#define WSTOPSIG(status) WEXITSTATUS(status)
+#define WTERMSIG(status) ((status) & 0x7f)
+
+#define WCOREFLAG 0x80
+#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
+#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#endif // LLVM_LIBC_MACROS_LINUX_SYS_WAIT_MACROS_H
|
|
||
#define WCOREFLAG 0x80 | ||
#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) | ||
#define W_STOPCODE(sig) ((sig) << 8 | 0x7f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three aren't specified by POSIX. Are they glibc extensions? Perhaps doesn't matter for this PR, but I did choose to retain them in case they're in widespread use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they're in BSD too.
the commit message on the change that added them to bionic was "Fixes for building gdbserver (and gdb) out of the box.".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for the context. Maybe ACSRG can standardize them at some point. Will leave them for now.
ping for review |
(seemed plausible to me, but i'm assuming you want an llvm-libc committer's review...) |
I want you to be an llvm-libc committer and reviewer 😉 . If you expect me to be for bionic, then it's only reciprocal. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/196/builds/4589 Here is the relevant piece of the build log for the reference
|
ack, looking:
|
riscv32 currently doesn't have SYS_wait4, so wait4 is implemented via fallback to SYS_waitid. In llvm#125572, I missed that we had one use of the removed __W_CONTINUED value. Hard code it here. Fixes: llvm#125572
…m#125572) This patch does a few things: - replace macro definitions with an inclusion of the linux/wait.h kernel header. - WNOHANG - WUNTRACED - WEXITED - WCONTINUED - WSTOPPED - P_ALL - P_PID - P_PGID - P_PIDFD - Add missing macro definitions mandated by POSIX. Some are needed to build LLVM. - WCOREDUMP - WIFCONTINUED - WIFSIGNALELD - WIFSTOPPED - WSTOPSIG - Remove glibc style __W* macros. Users should stick with the POSIX macros. We can re-add them if necessary. - __WEXITSTATUS - __WTERMSIG - __WIFEXITED - __WIFSIGNALED - __WIFSTOPPED - __WIFCONTINUED - __WCOREDUMP - __W_EXITCODE - __W_STOPCODE - __W_CONTINUED - __WCOREFLAG Fixes: llvm#124944
…5929) riscv32 currently doesn't have SYS_wait4, so wait4 is implemented via fallback to SYS_waitid. In llvm#125572, I missed that we had one use of the removed __W_CONTINUED value. Hard code it here. Fixes: llvm#125572
This patch does a few things:
header.
LLVM.
can re-add them if necessary.
Fixes: #124944