[PATCH] stdlib: Define WCOREDUMP in stdlib.h [BZ #32551]

Samuel Zeter samuelzeter@gmail.com
Thu May 22 01:36:49 GMT 2025


POSIX:2024 specifies that <stdlib.h> defines the WCOREDUMP macro in
the same way as <sys/wait.h>.
---
 stdlib/Makefile        |  1 +
 stdlib/stdlib.h        |  1 +
 stdlib/tst-wcoredump.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 stdlib/tst-wcoredump.c

diff --git a/stdlib/Makefile b/stdlib/Makefile
index 1c80e497f0..a30a3fc9bf 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -371,6 +371,7 @@ tests := \
   tst-ulabs \
   tst-ullabs \
   tst-unsetenv1 \
+  tst-wcoredump \
   tst-width \
   tst-width-stdint \
   tst-xpg-basename \
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index cd4503c761..a9587a1e9b 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -47,6 +47,7 @@ __BEGIN_DECLS
 # define WIFEXITED(status)	__WIFEXITED (status)
 # define WIFSIGNALED(status)	__WIFSIGNALED (status)
 # define WIFSTOPPED(status)	__WIFSTOPPED (status)
+# define WCOREDUMP(status)	__WCOREDUMP (status)
 # ifdef __WIFCONTINUED
 #  define WIFCONTINUED(status)	__WIFCONTINUED (status)
 # endif
diff --git a/stdlib/tst-wcoredump.c b/stdlib/tst-wcoredump.c
new file mode 100644
index 0000000000..cc6e6c5f60
--- /dev/null
+++ b/stdlib/tst-wcoredump.c
@@ -0,0 +1,30 @@
+/* Define WCOREDUMP in stdlib.h (BZ #32551)
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stdlib.h>
+#include <support/check.h>
+
+int
+do_test (void)
+{
+  TEST_VERIFY(WCOREDUMP(0) == 0);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.49.0



More information about the Libc-alpha mailing list