[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: what does regex depend on sys_wait?
From: |
Paul Eggert |
Subject: |
Re: what does regex depend on sys_wait? |
Date: |
Tue, 28 Sep 2010 09:42:13 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 |
On 09/28/10 09:34, Eric Blake wrote:
> However, in thinking about it a bit more, a compromise would be to also
> modify tests/test-stdlib.c to check for the presence of whether the
> gnulib sys_wait module is in use, and skip validation of the
> status-related macros if it is not. Then, stdlib can drop the sys_wait
> dependency, and if you care about the macros, it's not that much harder
> to additionally request the sys_wait module.
That would be fine, yes. The point is that we shouldn't be letting
the tail (mingw and sys/wait) wag the dog. Another possibility
would be this patch -- would you prefer that?
diff --git a/ChangeLog b/ChangeLog
index f23c1c4..8e56261 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2010-09-28 Paul Eggert <address@hidden>
+
+ stdlib: don't depend on sys_wait
+
+ See the thread rooted here:
+ http://lists.gnu.org/archive/html/bug-gnulib/2010-09/msg00454.html
+ * lib/stdlib.in.h [!defined WEXITSTATUS]: #include "sys_waitdefs.h",
+ not <sys/wait.h>, for the benefit of mingw.
+ * lib/sys_waitdefs.h: New file, containing much of what used to
+ be in sys_wait.in.h.
+ * lib/sys_wait.in.h: Include it.
+ * modules/sys_wait (Files): Add lib/sys_waitdefs.h.
+ * modules/stdlib (Files): Likewise.
+ (Depends-on): Remove sys_wait.
+
2010-09-26 Bruno Haible <address@hidden>
sys_wait: Implement WSTOPSIG.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index f4309ed..a700e79 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -40,7 +40,7 @@
/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
#ifndef WEXITSTATUS
-# include <sys/wait.h>
+# include "sys_waitdefs.h"
#endif
/* Solaris declares getloadavg() in <sys/loadavg.h>. */
diff --git a/lib/sys_wait.in.h b/lib/sys_wait.in.h
index 0006112..d85337a 100644
--- a/lib/sys_wait.in.h
+++ b/lib/sys_wait.in.h
@@ -30,85 +30,16 @@
#ifndef _GL_SYS_WAIT_H
#define _GL_SYS_WAIT_H
-#if !((defined _WIN32 || 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
-
-# ifdef __cplusplus
-extern "C" {
-# endif
+#include "sys_waitdefs.h"
-/* Declarations of functions. */
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# ifdef __cplusplus
-}
-# endif
-
-#else
/* Native Windows API. */
# include <process.h> /* for _cwait, WAIT_CHILD */
-# include <signal.h> /* for SIGTERM */
# define waitpid(pid,statusp,options) _cwait (statusp, pid, WAIT_CHILD)
-/* 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
#endif /* _GL_SYS_WAIT_H */
diff --git a/lib/sys_waitdefs.h b/lib/sys_waitdefs.h
new file mode 100644
index 0000000..74aaeee
--- /dev/null
+++ b/lib/sys_waitdefs.h
@@ -0,0 +1,84 @@
+/* <sys/wait.h> and <stdlib.h> definitions.
+ Copyright (C) 2010 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 2, 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, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#if !((defined _WIN32 || 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
diff --git a/modules/stdlib b/modules/stdlib
index f822aa3..807be35 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -3,6 +3,7 @@ A GNU-like <stdlib.h>.
Files:
lib/stdlib.in.h
+lib/sys_waitdefs.h
m4/stdlib_h.m4
Depends-on:
@@ -11,7 +12,6 @@ c++defs
include_next
stddef
stdint
-sys_wait
unistd
warn-on-use
diff --git a/modules/sys_wait b/modules/sys_wait
index 376b08c..02368b8 100644
--- a/modules/sys_wait
+++ b/modules/sys_wait
@@ -3,6 +3,7 @@ A <sys/wait.h> for systems with missing declarations.
Files:
lib/sys_wait.in.h
+lib/sys_waitdefs.h
m4/sys_wait_h.m4
Depends-on:
- what does regex depend on sys_wait?, Sam Steingold, 2010/09/27
- Re: what does regex depend on sys_wait?, Eric Blake, 2010/09/27
- Re: what does regex depend on sys_wait?, Paul Eggert, 2010/09/27
- Re: what does regex depend on sys_wait?, Bruno Haible, 2010/09/27
- Re: what does regex depend on sys_wait?, Jim Meyering, 2010/09/28
- Re: what does regex depend on sys_wait?, Paul Eggert, 2010/09/28
- Re: what does regex depend on sys_wait?, Eric Blake, 2010/09/28
- Re: what does regex depend on sys_wait?, Eric Blake, 2010/09/28
- Re: what does regex depend on sys_wait?,
Paul Eggert <=
- Re: what does regex depend on sys_wait?, Eric Blake, 2010/09/28
- Re: what does regex depend on sys_wait?, Bruno Haible, 2010/09/28
- Re: what does regex depend on sys_wait?, Paul Eggert, 2010/09/28
- Re: what does regex depend on sys_wait?, Eric Blake, 2010/09/28
- Re: what does regex depend on sys_wait?, Paul Eggert, 2010/09/28
- Re: what does regex depend on sys_wait?, Bruno Haible, 2010/09/28
- Re: what does regex depend on sys_wait?, Eric Blake, 2010/09/28
- Re: what does regex depend on sys_wait?, Bruno Haible, 2010/09/28