changeset 12534:df55cbe78453

spawn: improve wrapper support Avoid type conflicts if overriding system header. * m4/spawn_h.m4 (gl_SPAWN_H): Check for type existence. (gl_SPAWN_H_DEFAULTS): New defaults. * modules/spawn (Makefile.am): Substitute them. * lib/spawn.in.h: (posix_spawnattr_t, posix_spawn_file_actions_t): Only declare if missing or broken. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Wed, 30 Dec 2009 11:52:31 -0700
parents 57ab00b8ee20
children 8c827f8e5f04
files ChangeLog lib/spawn.in.h m4/spawn_h.m4 modules/spawn
diffstat 4 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-12-31  Eric Blake  <ebb9@byu.net>
 
+	spawn: improve wrapper support
+	* m4/spawn_h.m4 (gl_SPAWN_H): Check for type existence.
+	(gl_SPAWN_H_DEFAULTS): New defaults.
+	* modules/spawn (Makefile.am): Substitute them.
+	* lib/spawn.in.h: (posix_spawnattr_t, posix_spawn_file_actions_t):
+	Only declare if missing or broken.
+
 	sys_times, sys_utsname: use include_next
 	* m4/sys_times_h.m4 (gl_SYS_TIMES_H): Support wrapping an existing
 	header.
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -74,6 +74,7 @@
 #if @REPLACE_POSIX_SPAWN@
 # define posix_spawnattr_t rpl_posix_spawnattr_t
 #endif
+#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@
 typedef struct
 {
   short int _flags;
@@ -84,6 +85,7 @@
   int _policy;
   int __pad[16];
 } posix_spawnattr_t;
+#endif
 
 
 /* Data structure to contain information about the actions to be
@@ -91,6 +93,7 @@
 #if @REPLACE_POSIX_SPAWN@
 # define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t
 #endif
+#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@
 typedef struct
 {
   int _allocated;
@@ -98,6 +101,7 @@
   struct __spawn_action *_actions;
   int __pad[16];
 } posix_spawn_file_actions_t;
+#endif
 
 
 /* Flags to be set in the `posix_spawnattr_t'.  */
--- a/m4/spawn_h.m4
+++ b/m4/spawn_h.m4
@@ -1,4 +1,4 @@
-# spawn_h.m4 serial 3
+# spawn_h.m4 serial 4
 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,8 +19,17 @@
   AC_CHECK_HEADERS_ONCE([spawn.h])
   if test $ac_cv_header_spawn_h = yes; then
     HAVE_SPAWN_H=1
+    AC_CHECK_TYPES([posix_spawnattr_t], [], [HAVE_POSIX_SPAWNATTR_T=0], [[
+#include <spawn.h>
+      ]])
+    AC_CHECK_TYPES([posix_spawn_file_actions_t], [],
+      [HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0], [[
+#include <spawn.h>
+      ]])
   else
     HAVE_SPAWN_H=0
+    HAVE_POSIX_SPAWNATTR_T=0
+    HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0
     gl_REPLACE_SPAWN_H
   fi
   AC_SUBST([HAVE_SPAWN_H])
@@ -66,7 +75,10 @@
   GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0;        AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK])
   GNULIB_POSIX_SPAWNATTR_DESTROY=0;           AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_POSIX_SPAWN=1;     AC_SUBST([HAVE_POSIX_SPAWN])
-  REPLACE_POSIX_SPAWN=0;  AC_SUBST([REPLACE_POSIX_SPAWN])
-  SPAWN_H='';             AC_SUBST([SPAWN_H])
+  HAVE_POSIX_SPAWN=1;        AC_SUBST([HAVE_POSIX_SPAWN])
+  HAVE_POSIX_SPAWNATTR_T=1;  AC_SUBST([HAVE_POSIX_SPAWNATTR_T])
+  HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1;
+                             AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T])
+  REPLACE_POSIX_SPAWN=0;     AC_SUBST([REPLACE_POSIX_SPAWN])
+  SPAWN_H='';                AC_SUBST([SPAWN_H])
 ])
--- a/modules/spawn
+++ b/modules/spawn
@@ -48,6 +48,8 @@
 	      -e 's|@''GNULIB_POSIX_SPAWNATTR_SETSIGMASK''@|$(GNULIB_POSIX_SPAWNATTR_SETSIGMASK)|g' \
 	      -e 's|@''GNULIB_POSIX_SPAWNATTR_DESTROY''@|$(GNULIB_POSIX_SPAWNATTR_DESTROY)|g' \
 	      -e 's|@''HAVE_POSIX_SPAWN''@|$(HAVE_POSIX_SPAWN)|g' \
+	      -e 's|@''HAVE_POSIX_SPAWNATTR_T''@|$(HAVE_POSIX_SPAWNATTR_T)|g' \
+	      -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_T''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_T)|g' \
 	      -e 's|@''REPLACE_POSIX_SPAWN''@|$(REPLACE_POSIX_SPAWN)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \