public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gnulib: import sys_wait
@ 2021-06-13  5:25 Mike Frysinger
  2021-06-14 12:18 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Mike Frysinger @ 2021-06-13  5:25 UTC (permalink / raw)
  To: gdb-patches

A few sims use this to emulate process syscalls.
---
 gnulib/Makefile.in               |   4 +
 gnulib/aclocal.m4                |   1 +
 gnulib/config.in                 |   3 +
 gnulib/configure                 |  99 +++++++++++++++++++++++
 gnulib/import/Makefile.am        |  29 +++++++
 gnulib/import/Makefile.in        |  35 +++++++--
 gnulib/import/m4/gnulib-cache.m4 |   2 +
 gnulib/import/m4/gnulib-comp.m4  |   5 ++
 gnulib/import/m4/sys_wait_h.m4   |  36 +++++++++
 gnulib/import/sys_wait.in.h      | 131 +++++++++++++++++++++++++++++++
 gnulib/update-gnulib.sh          |   1 +
 11 files changed, 340 insertions(+), 6 deletions(-)
 create mode 100644 gnulib/import/m4/sys_wait_h.m4
 create mode 100644 gnulib/import/sys_wait.in.h

diff --git a/gnulib/Makefile.in b/gnulib/Makefile.in
index e1b9b34a794e..af264c3c12de 100644
--- a/gnulib/Makefile.in
+++ b/gnulib/Makefile.in
@@ -265,6 +265,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/import/m4/sys_time_h.m4 \
 	$(top_srcdir)/import/m4/sys_types_h.m4 \
 	$(top_srcdir)/import/m4/sys_uio_h.m4 \
+	$(top_srcdir)/import/m4/sys_wait_h.m4 \
 	$(top_srcdir)/import/m4/tempname.m4 \
 	$(top_srcdir)/import/m4/threadlib.m4 \
 	$(top_srcdir)/import/m4/time_h.m4 \
@@ -813,6 +814,7 @@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
 GNULIB_VSCANF = @GNULIB_VSCANF@
 GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
 GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
 GNULIB_WCPCPY = @GNULIB_WCPCPY@
 GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
 GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
@@ -1307,6 +1309,7 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
 NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@
 NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@
 NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
 NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
 NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
 NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
@@ -1338,6 +1341,7 @@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
 NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@
 NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@
 NEXT_SYS_UIO_H = @NEXT_SYS_UIO_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
 NEXT_TIME_H = @NEXT_TIME_H@
 NEXT_UNISTD_H = @NEXT_UNISTD_H@
 NEXT_WCHAR_H = @NEXT_WCHAR_H@
diff --git a/gnulib/aclocal.m4 b/gnulib/aclocal.m4
index 83780b641ac4..c03dc8bcafa7 100644
--- a/gnulib/aclocal.m4
+++ b/gnulib/aclocal.m4
@@ -1338,6 +1338,7 @@ m4_include([import/m4/sys_stat_h.m4])
 m4_include([import/m4/sys_time_h.m4])
 m4_include([import/m4/sys_types_h.m4])
 m4_include([import/m4/sys_uio_h.m4])
+m4_include([import/m4/sys_wait_h.m4])
 m4_include([import/m4/tempname.m4])
 m4_include([import/m4/threadlib.m4])
 m4_include([import/m4/time_h.m4])
diff --git a/gnulib/config.in b/gnulib/config.in
index a90ddd611823..db04597320eb 100644
--- a/gnulib/config.in
+++ b/gnulib/config.in
@@ -901,6 +901,9 @@
 /* Define to 1 if you have the <sys/uio.h> header file. */
 #undef HAVE_SYS_UIO_H
 
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#undef HAVE_SYS_WAIT_H
+
 /* Define to 1 if you have the `thrd_create' function. */
 #undef HAVE_THRD_CREATE
 
diff --git a/gnulib/configure b/gnulib/configure
index 73a38082960a..c212281bca5b 100644
--- a/gnulib/configure
+++ b/gnulib/configure
@@ -732,6 +732,9 @@ GNULIB_NANOSLEEP
 GNULIB_LOCALTIME
 GNULIB_MKTIME
 GNULIB_CTIME
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H
+NEXT_SYS_WAIT_H
+GNULIB_WAITPID
 HAVE_SYS_UIO_H
 NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H
 NEXT_SYS_UIO_H
@@ -3802,6 +3805,7 @@ as_fn_append ac_func_list " snprintf"
 as_fn_append ac_header_list " strings.h"
 as_fn_append ac_header_list " sys/random.h"
 as_fn_append ac_header_list " sys/uio.h"
+as_fn_append ac_header_list " sys/wait.h"
 as_fn_append ac_func_list " localtime_r"
 as_fn_append ac_header_list " crtdefs.h"
 as_fn_append ac_func_list " iswcntrl"
@@ -6865,6 +6869,7 @@ fi
   # Code from module sys_time:
   # Code from module sys_types:
   # Code from module sys_uio:
+  # Code from module sys_wait:
   # Code from module tempname:
   # Code from module threadlib:
 
@@ -17767,6 +17772,11 @@ $as_echo "$gl_cv_next_sys_types_h" >&6; }
 
 
 
+  GNULIB_WAITPID=0;
+
+
+
+
   GNULIB_CTIME=0;
   GNULIB_MKTIME=0;
   GNULIB_LOCALTIME=0;
@@ -30722,6 +30732,95 @@ $as_echo "$gl_cv_next_sys_uio_h" >&6; }
 
 
 
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_sys_wait_h='<'sys/wait.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <sys/wait.h>" >&5
+$as_echo_n "checking absolute name of <sys/wait.h>... " >&6; }
+if ${gl_cv_next_sys_wait_h+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_sys_wait_h = yes; then
+
+
+
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/wait.h>
+_ACEOF
+                case "$host_os" in
+    aix*) gl_absname_cpp="$ac_cpp -C" ;;
+    *)    gl_absname_cpp="$ac_cpp" ;;
+  esac
+
+  case "$host_os" in
+    mingw*)
+                                          gl_dirsep_regex='[/\\]'
+      ;;
+    *)
+      gl_dirsep_regex='\/'
+      ;;
+  esac
+      gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
+  gl_header_literal_regex=`echo 'sys/wait.h' \
+                           | sed -e "$gl_make_literal_regex_sed"`
+  gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
+      s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
+      s|^/[^/]|//&|
+      p
+      q
+    }'
+
+        gl_cv_absolute_sys_wait_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+  sed -n "$gl_absolute_header_sed"`
+
+           gl_header=$gl_cv_absolute_sys_wait_h
+           gl_cv_next_sys_wait_h='"'$gl_header'"'
+          else
+               gl_cv_next_sys_wait_h='<'sys/wait.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_wait_h" >&5
+$as_echo "$gl_cv_next_sys_wait_h" >&6; }
+     fi
+     NEXT_SYS_WAIT_H=$gl_cv_next_sys_wait_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'sys/wait.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_sys_wait_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H=$gl_next_as_first_directive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
   :
 
 
diff --git a/gnulib/import/Makefile.am b/gnulib/import/Makefile.am
index 1ae25ac28050..dafe63d4c8a6 100644
--- a/gnulib/import/Makefile.am
+++ b/gnulib/import/Makefile.am
@@ -71,6 +71,7 @@
 #  strstr \
 #  strtok_r \
 #  sys_stat \
+#  sys_wait \
 #  time_r \
 #  unistd \
 #  unsetenv \
@@ -2755,6 +2756,34 @@ EXTRA_DIST += sys_uio.in.h
 
 ## end   gnulib module sys_uio
 
+## begin gnulib module sys_wait
+
+BUILT_SOURCES += sys/wait.h
+
+# We need the following in order to create <sys/wait.h> when the system
+# has one that is incomplete.
+sys/wait.h: sys_wait.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+	$(AM_V_at)$(MKDIR_P) sys
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+	      -e 's|@''NEXT_SYS_WAIT_H''@|$(NEXT_SYS_WAIT_H)|g' \
+	      -e 's/@''GNULIB_WAITPID''@/$(GNULIB_WAITPID)/g' \
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+	      < $(srcdir)/sys_wait.in.h; \
+	} > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += sys/wait.h sys/wait.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_wait.in.h
+
+## end   gnulib module sys_wait
+
 ## begin gnulib module tempname
 
 libgnu_a_SOURCES += tempname.c
diff --git a/gnulib/import/Makefile.in b/gnulib/import/Makefile.in
index e9b52a7d4fc3..aae971154094 100644
--- a/gnulib/import/Makefile.in
+++ b/gnulib/import/Makefile.in
@@ -85,6 +85,7 @@
 #  strstr \
 #  strtok_r \
 #  sys_stat \
+#  sys_wait \
 #  time_r \
 #  unistd \
 #  unsetenv \
@@ -329,6 +330,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/import/m4/sys_time_h.m4 \
 	$(top_srcdir)/import/m4/sys_types_h.m4 \
 	$(top_srcdir)/import/m4/sys_uio_h.m4 \
+	$(top_srcdir)/import/m4/sys_wait_h.m4 \
 	$(top_srcdir)/import/m4/tempname.m4 \
 	$(top_srcdir)/import/m4/threadlib.m4 \
 	$(top_srcdir)/import/m4/time_h.m4 \
@@ -915,6 +917,7 @@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
 GNULIB_VSCANF = @GNULIB_VSCANF@
 GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
 GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
 GNULIB_WCPCPY = @GNULIB_WCPCPY@
 GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
 GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
@@ -1409,6 +1412,7 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
 NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@
 NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@
 NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
 NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
 NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
 NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
@@ -1440,6 +1444,7 @@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
 NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@
 NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@
 NEXT_SYS_UIO_H = @NEXT_SYS_UIO_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
 NEXT_TIME_H = @NEXT_TIME_H@
 NEXT_UNISTD_H = @NEXT_UNISTD_H@
 NEXT_WCHAR_H = @NEXT_WCHAR_H@
@@ -1856,8 +1861,8 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h arpa_inet.in.h \
 	string.in.h strings.in.h strnlen.c strstr.c str-two-way.h \
 	strstr.c strtok_r.c sys_random.in.h sys_select.in.h \
 	sys_socket.in.h sys_stat.in.h sys_time.in.h sys_types.in.h \
-	sys_uio.in.h tempname.h time.in.h time_r.c unistd.in.h \
-	unistd--.h unistd-safer.h unsetenv.c \
+	sys_uio.in.h sys_wait.in.h tempname.h time.in.h time_r.c \
+	unistd.in.h unistd--.h unistd-safer.h unsetenv.c \
 	$(top_srcdir)/import/extra/update-copyright verify.h \
 	wchar.in.h wctype.in.h windows-initguard.h windows-mutex.c \
 	windows-mutex.h windows-once.c windows-once.h \
@@ -1870,7 +1875,7 @@ BUILT_SOURCES = $(ALLOCA_H) arpa/inet.h ctype.h dirent.h $(ERRNO_H) \
 	$(STDALIGN_H) $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h \
 	stdlib.h string.h strings.h sys/random.h sys/select.h \
 	sys/socket.h sys/stat.h sys/time.h sys/types.h sys/uio.h \
-	time.h unistd.h wchar.h wctype.h
+	sys/wait.h time.h unistd.h wchar.h wctype.h
 SUFFIXES = 
 MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \
 	arpa/inet.h-t ctype.h ctype.h-t dirent.h dirent.h-t errno.h \
@@ -1884,9 +1889,9 @@ MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \
 	sys/random.h sys/random.h-t sys/select.h sys/select.h-t \
 	sys/socket.h sys/socket.h-t sys/stat.h sys/stat.h-t sys/time.h \
 	sys/time.h-t sys/types.h sys/types.h-t sys/uio.h sys/uio.h-t \
-	time.h time.h-t unistd.h unistd.h-t wchar.h wchar.h-t wctype.h \
-	wctype.h-t
-MOSTLYCLEANDIRS = arpa netinet sys sys sys sys sys
+	sys/wait.h sys/wait.h-t time.h time.h-t unistd.h unistd.h-t \
+	wchar.h wchar.h-t wctype.h wctype.h-t
+MOSTLYCLEANDIRS = arpa netinet sys sys sys sys sys sys
 CLEANFILES = 
 DISTCLEANFILES = 
 MAINTAINERCLEANFILES = 
@@ -3744,6 +3749,24 @@ sys/uio.h: sys_uio.in.h $(top_builddir)/config.status
 	} > $@-t && \
 	mv -f $@-t $@
 
+# We need the following in order to create <sys/wait.h> when the system
+# has one that is incomplete.
+sys/wait.h: sys_wait.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+	$(AM_V_at)$(MKDIR_P) sys
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+	      -e 's|@''NEXT_SYS_WAIT_H''@|$(NEXT_SYS_WAIT_H)|g' \
+	      -e 's/@''GNULIB_WAITPID''@/$(GNULIB_WAITPID)/g' \
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+	      < $(srcdir)/sys_wait.in.h; \
+	} > $@-t && \
+	mv $@-t $@
+
 # We need the following in order to create <time.h> when the system
 # doesn't have one that works with the given compiler.
 time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
diff --git a/gnulib/import/m4/gnulib-cache.m4 b/gnulib/import/m4/gnulib-cache.m4
index 689ebd3e5ba9..53968404dca4 100644
--- a/gnulib/import/m4/gnulib-cache.m4
+++ b/gnulib/import/m4/gnulib-cache.m4
@@ -76,6 +76,7 @@
 #  strstr \
 #  strtok_r \
 #  sys_stat \
+#  sys_wait \
 #  time_r \
 #  unistd \
 #  unsetenv \
@@ -124,6 +125,7 @@ gl_MODULES([
   strstr
   strtok_r
   sys_stat
+  sys_wait
   time_r
   unistd
   unsetenv
diff --git a/gnulib/import/m4/gnulib-comp.m4 b/gnulib/import/m4/gnulib-comp.m4
index 03eff90b6b2d..54ae5bbbcf21 100644
--- a/gnulib/import/m4/gnulib-comp.m4
+++ b/gnulib/import/m4/gnulib-comp.m4
@@ -213,6 +213,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module sys_time:
   # Code from module sys_types:
   # Code from module sys_uio:
+  # Code from module sys_wait:
   # Code from module tempname:
   # Code from module threadlib:
   gl_THREADLIB_EARLY
@@ -777,6 +778,8 @@ AC_DEFUN([gl_INIT],
   AC_PROG_MKDIR_P
   gl_HEADER_SYS_UIO
   AC_PROG_MKDIR_P
+  gl_SYS_WAIT_H
+  AC_PROG_MKDIR_P
   gl_FUNC_GEN_TEMPNAME
   gl_MODULE_INDICATOR([tempname])
   AC_REQUIRE([gl_THREADLIB])
@@ -1184,6 +1187,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/sys_time.in.h
   lib/sys_types.in.h
   lib/sys_uio.in.h
+  lib/sys_wait.in.h
   lib/tempname.c
   lib/tempname.h
   lib/time.in.h
@@ -1365,6 +1369,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/sys_time_h.m4
   m4/sys_types_h.m4
   m4/sys_uio_h.m4
+  m4/sys_wait_h.m4
   m4/tempname.m4
   m4/threadlib.m4
   m4/time_h.m4
diff --git a/gnulib/import/m4/sys_wait_h.m4 b/gnulib/import/m4/sys_wait_h.m4
new file mode 100644
index 000000000000..96e9ba2b1247
--- /dev/null
+++ b/gnulib/import/m4/sys_wait_h.m4
@@ -0,0 +1,36 @@
+# sys_wait_h.m4 serial 6
+dnl Copyright (C) 2008-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SYS_WAIT_H],
+[
+  AC_REQUIRE([gl_SYS_WAIT_H_DEFAULTS])
+
+  dnl <sys/wait.h> is always overridden, because of GNULIB_POSIXCHECK.
+  gl_CHECK_NEXT_HEADERS([sys/wait.h])
+
+  dnl Ensure the type pid_t gets defined.
+  AC_REQUIRE([AC_TYPE_PID_T])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use.
+  gl_WARN_ON_USE_PREPARE([[#include <sys/wait.h>]],
+    [waitpid])
+])
+
+AC_DEFUN([gl_SYS_WAIT_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_WAIT_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_SYS_WAIT_H_DEFAULTS],
+[
+  GNULIB_WAITPID=0; AC_SUBST([GNULIB_WAITPID])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+])
diff --git a/gnulib/import/sys_wait.in.h b/gnulib/import/sys_wait.in.h
new file mode 100644
index 000000000000..25d25a0ae1be
--- /dev/null
+++ b/gnulib/import/sys_wait.in.h
@@ -0,0 +1,131 @@
+/* A POSIX-like <sys/wait.h>.
+   Copyright (C) 2001-2003, 2005-2021 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
+
+
+#ifndef _@GUARD_PREFIX@_SYS_WAIT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#if !(defined _WIN32 && ! defined __CYGWIN__)
+# @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_SYS_WAIT_H
+#define _@GUARD_PREFIX@_SYS_WAIT_H
+
+/* Get pid_t.  */
+#include <sys/types.h>
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+#if !(defined _WIN32 && ! defined __CYGWIN__)
+/* Unix API.  */
+
+/* The following macros apply to an argument x, that is a status of a process,
+   as returned by waitpid().
+   On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and
+   WTERMSIG are bits 7..0, while BeOS uses the opposite.  Therefore programs
+   have to use the abstract macros.  */
+
+/* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
+   is true.  */
+# ifndef WIFSIGNALED
+#  define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f)
+# endif
+# ifndef WIFEXITED
+#  define WIFEXITED(x) (WTERMSIG (x) == 0)
+# endif
+# ifndef WIFSTOPPED
+#  define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f)
+# endif
+
+/* The termination signal. Only to be accessed if WIFSIGNALED(x) is true.  */
+# ifndef WTERMSIG
+#  define WTERMSIG(x) ((x) & 0x7f)
+# endif
+
+/* The exit status. Only to be accessed if WIFEXITED(x) is true.  */
+# ifndef WEXITSTATUS
+#  define WEXITSTATUS(x) (((x) >> 8) & 0xff)
+# endif
+
+/* The stopping signal. Only to be accessed if WIFSTOPPED(x) is true.  */
+# ifndef WSTOPSIG
+#  define WSTOPSIG(x) (((x) >> 8) & 0x7f)
+# endif
+
+/* True if the process dumped core.  Not standardized by POSIX.  */
+# ifndef WCOREDUMP
+#  define WCOREDUMP(x) ((x) & 0x80)
+# endif
+
+#else
+/* Native Windows API.  */
+
+# include <signal.h> /* for SIGTERM */
+
+/* The following macros apply to an argument x, that is a status of a process,
+   as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess().
+   This value is simply an 'int', not composed of bit fields.  */
+
+/* When an unhandled fatal signal terminates a process, the exit code is 3.  */
+# define WIFSIGNALED(x) ((x) == 3)
+# define WIFEXITED(x) ((x) != 3)
+# define WIFSTOPPED(x) 0
+
+/* The signal that terminated a process is not known posthum.  */
+# define WTERMSIG(x) SIGTERM
+
+# define WEXITSTATUS(x) (x)
+
+/* There are no stopping signals.  */
+# define WSTOPSIG(x) 0
+
+/* There are no core dumps.  */
+# define WCOREDUMP(x) 0
+
+#endif
+
+
+/* Declarations of functions.  */
+
+#if @GNULIB_WAITPID@
+# if defined _WIN32 && ! defined __CYGWIN__
+_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
+# endif
+/* Need to cast, because on Cygwin, the second parameter is
+                                                __wait_status_ptr_t statusp.  */
+_GL_CXXALIAS_SYS_CAST (waitpid, pid_t, (pid_t pid, int *statusp, int options));
+_GL_CXXALIASWARN (waitpid);
+#elif defined GNULIB_POSIXCHECK
+# undef waitpid
+# if HAVE_RAW_DECL_WAITPID
+_GL_WARN_ON_USE (waitpid, "waitpid is unportable - "
+                 "use gnulib module sys_wait for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_SYS_WAIT_H */
+#endif /* _@GUARD_PREFIX@_SYS_WAIT_H */
diff --git a/gnulib/update-gnulib.sh b/gnulib/update-gnulib.sh
index 08c43fcfc143..e5c6fd90dd76 100755
--- a/gnulib/update-gnulib.sh
+++ b/gnulib/update-gnulib.sh
@@ -68,6 +68,7 @@ IMPORTED_GNULIB_MODULES="\
     strstr \
     strtok_r \
     sys_stat \
+    sys_wait \
     time_r \
     unistd \
     unsetenv \
-- 
2.31.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-09-08 20:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-13  5:25 [PATCH] gnulib: import sys_wait Mike Frysinger
2021-06-14 12:18 ` Eli Zaretskii
2021-06-14 14:35   ` Mike Frysinger
2021-06-14 14:43     ` Eli Zaretskii
2021-06-14 19:35       ` Mike Frysinger
2021-06-30  7:03 ` Mike Frysinger
2021-08-18 16:19   ` Mike Frysinger
2021-09-04  1:15     ` Mike Frysinger
2021-09-03 20:54 ` Simon Marchi
2021-09-04  7:41   ` Mike Frysinger
2021-09-07 14:51     ` Simon Marchi
2021-09-08  0:55       ` Mike Frysinger
2021-09-08 14:41         ` Simon Marchi
2021-09-08 20:20           ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).