spawn: improve wrapper support
authorEric Blake <ebb9@byu.net>
Wed, 30 Dec 2009 18:52:31 +0000 (11:52 -0700)
committerEric Blake <ebb9@byu.net>
Thu, 31 Dec 2009 13:08:48 +0000 (06:08 -0700)
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>
ChangeLog
lib/spawn.in.h
m4/spawn_h.m4
modules/spawn

index 2b8207716e3d7b56c97a9cf25d1e25c0979b440c..dff8ae98f86a74e77586bf10eb7800b0c65c0666 100644 (file)
--- 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.
index 61c82aebb7cb1ddcb0dc45813bcd2182ba70b8eb..29b388bbaab8679d9f1fd90f3181b797deaf3a90 100644 (file)
@@ -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 @@ typedef struct
   int _policy;
   int __pad[16];
 } posix_spawnattr_t;
+#endif
 
 
 /* Data structure to contain information about the actions to be
@@ -91,6 +93,7 @@ typedef struct
 #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 @@ typedef struct
   struct __spawn_action *_actions;
   int __pad[16];
 } posix_spawn_file_actions_t;
+#endif
 
 
 /* Flags to be set in the `posix_spawnattr_t'.  */
index dd915fabdb96250801e6669427133b1874a7dfb2..a369c27317c4b0f560313bf15ab29f84dca05486 100644 (file)
@@ -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_DEFUN([gl_SPAWN_H],
   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 @@ AC_DEFUN([gl_SPAWN_H_DEFAULTS],
   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])
 ])
index 616cc454f8157ac2cbab2033032304c94544e6f7..18821520b0888f541976ddcfacae4bae82ef4361 100644 (file)
@@ -48,6 +48,8 @@ spawn.h: spawn.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
              -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)' \