autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [autoconf] AmigaOS fork()


From: Rüdiger Kuhlmann
Subject: Re: [autoconf] AmigaOS fork()
Date: Fri, 1 Jun 2001 16:50:29 +0200
User-agent: Mutt/1.3.17i

>--[Akim Demaille]--<address@hidden>
> 
> | > don't know enough about vfork and fork to speak intelligently here,
> | > but I seem to understand that using AC_REPLACE_FUNCS would be better
> | > suited then, no?  I mean, from the user point of view, not for the
> | > tests themselves.
> | What do you mean? If you don't have a fork(), you can't replace it.
> | To have a fork() on AmigaOS you'd need to write a new OS.

> I meant that, if I have understood correctly, your proposal is to
> replace vfork with fork or conversely depending upon the broken one.
> I don't like too much the silly #define fork vfork games, so I was
> suggesting to provide functions instead.

No, not really. I changed my mind in this repect, since fork can't always be
replaced by vfork. But I added doc to AC_FUNC_FORK encouraging people to
define themselves a forkvfork function for such a replacable fork. If it
can't be replaced, it'll fail, but it is out of the scope of autoconf to fix
it.

> 
> | > Hm...  Do we really want _two_ macros here?
> | Actually, they're related anyway, so I put them into one macro,
> | obsoleting AC_FUNC_VFORK.

> :)  Yes, that's what I meant.  But you're too fast :)  I was also

Thanks :-) I just want to get the job done - if it is checked in, I'll find
my next toy to work on ;-)

> waiting for the comments from other maintainers.  And I would have
> handled the merge myself, I didn't mean to have you do it.  In
> particular, I was referring to presenting a single macro to the user,
> but _not_ making a huge macro.

More like this? One macro each to test everything, and one to set the proper
flags depending on the result.

> | Btw, why does AC_FUNC_FNMATCH define HAVE_FNMATCH instead of
> | HAVE_WORKING_FNMATCH?
> Because of (*£&$(*£R history, and backward compatibility.  But you are
> right, let's define the proper name too.

Okay :-)


2001-06-01 Rüdiger Kuhlmann <address@hidden>
 
        * acfunctions.m4: (AC_FUNC_VFORK) renamed to _AC_FUNC_VFORK. Remove
          AC_DEFINEs and don't guess cross-compilation values.
          (_AC_FUNC_FORK) New, check whether fork() isn't just a stub.
          (AC_FUNC_FORK) New, use _AC_FUNC_VFORK and _AC_FUNC_FORK to
          define HAVE_WORKING_FORK, HAVE_WORKING_VFORK; and vfork to fork
          if vfork doesn't work. Guess values if cross-compiling, but warn.
          (AC_FUNC_GETPGRP, AC_FUNC_WAIT3) Use AC_FUNC_FORK and #define fork
          to vfork if necessary.
        * acspecific.m4: (AC_SYS_RESTARTABLE_SYSCALLS) ditto.
        * acfunctions: add AC_FUNC_FORK.
        * doc/autoconf.texi: Document AC_FUNC_FORK. Give example to
          define forkvfork and vfork appropriately.

Index: acfunctions
===================================================================
RCS file: /cvs/autoconf/acfunctions,v
retrieving revision 1.14
diff -u -r1.14 acfunctions
--- acfunctions 2001/05/31 15:44:27     1.14
+++ acfunctions 2001/06/01 14:35:47
@@ -26,6 +26,7 @@
 error          AC_FUNC_ERROR_AT_LINE
 error_at_line  AC_FUNC_ERROR_AT_LINE
 fnmatch                AC_FUNC_FNMATCH
+fork           AC_FUNC_FORK     
 fseeko         AC_FUNC_FSEEKO
 ftello         AC_FUNC_FSEEKO
 getgroups      AC_FUNC_GETGROUPS
@@ -56,7 +57,7 @@
 strftime       AC_FUNC_STRFTIME
 strtod         AC_FUNC_STRTOD
 utime          AC_FUNC_UTIME_NULL
-vfork          AC_FUNC_VFORK
+vfork          AC_FUNC_FORK
 vfprintf       AC_FUNC_VPRINTF
 vprintf                AC_FUNC_VPRINTF
 vsprintf       AC_FUNC_VPRINTF
Index: acfunctions.m4
===================================================================
RCS file: /cvs/autoconf/acfunctions.m4,v
retrieving revision 1.33
diff -u -r1.33 acfunctions.m4
--- acfunctions.m4      2001/04/22 12:50:07     1.33
+++ acfunctions.m4      2001/06/01 14:35:59
@@ -599,7 +599,8 @@
 # AC_FUNC_GETPGRP
 # ---------------
 AC_DEFUN([AC_FUNC_GETPGRP],
-[AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
+[AC_REQUIRE([AC_FUNC_FORK])dnl
+AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
 /*
  * If this system has a BSD-style getpgrp(),
@@ -609,6 +610,9 @@
  */
 #include <stdio.h>
 #include <sys/types.h>
+#if !HAVE_WORKING_FORK
+# define fork vfork
+#endif
 
 int     pid;
 int     pg1, pg2, pg3, pg4;
@@ -1441,13 +1445,78 @@
 # -----------------
 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
 
+
+# AC_FUNC_FORK
+# -------------
+AC_DEFUN([AC_FUNC_FORK],
+  [AC_REQUIRE([AC_TYPE_PID_T])dnl
+  AC_CHECK_HEADERS(unistd.h vfork.h)
+  AC_CHECK_FUNCS(fork vfork)
+  ac_cv_func_fork_works=$ac_cv_func_fork
+  if test "x$ac_cv_func_fork" = xyes; then
+    _AC_FUNC_FORK
+  fi
+  if test "x$ac_cv_func_fork_works" = xcross"; then
+    case "$host" in
+      *-*-amigaos* | *-*-msdosdjgpp*)
+        # Override, as these systems have only a dummy fork() stub
+        ac_cv_func_fork_works=no
+        ;;
+      *)
+        ac_cv_func_fork_works=yes
+        ;;
+    esac
+    AC_MSG_WARN(CROSS: Result $ac_cv_func_fork_works guessed due to 
cross-compiling.)
+  fi
+  ac_cv_func_vfork_works=$ac_cv_func_vfork
+  if test "x$ac_cv_func_vfork" = xyes; then
+    _AC_FUNC_VFORK
+  fi;
+  if test "x$ac_cv_func_fork_works" = xcross"; then
+    ac_cv_func_vfork_works=ac_cv_func_vfork
+    AC_MSG_WARN(CROSS: Result $ac_cv_func_vfork_works guessed due to 
cross-compiling.)
+  fi
+  
+  if test "x${ac_cv_func_fork_works}${ac_cv_func_vfork_works}" = xnono; then
+    AC_MSG_WARN(Neither working `fork' nor `vfork' found.)
+  fi
+  if test "x$ac_cv_func_vfork_works" = xyes; then
+    AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define if `vfork' works.])
+  else
+    AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
+  fi
+  if test "x$ac_cv_func_fork_works" = xyes; then
+    AC_DEFINE(HAVE_WORKING_FORK, 1, [Define if `fork' works.])
+  endif
+])# AC_FUNC_FORK
+
 
-# AC_FUNC_VFORK
+# _AC_FUNC_FORK
 # -------------
-AC_DEFUN([AC_FUNC_VFORK],
-[AC_REQUIRE([AC_TYPE_PID_T])dnl
-AC_CHECK_HEADERS(unistd.h vfork.h)
-AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
+AC_DEFUN([_AC_FUNC_FORK],
+  [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
+    [AC_RUN_IFELSE([/* By Rüdiger Kuhlmann. */
+      #include <sys/types.h>
+      #if HAVE_UNISTD_H
+      # include <unistd.h>
+      #endif
+      /* Some systems only have a dummy stub for fork() */
+      int main ()
+      {
+        if (fork() < 0)
+          exit (1);
+        exit (0);
+      }],
+    [ac_cv_func_fork_works=yes],
+    [ac_cv_func_fork_works=no],
+    [ac_cv_func_fork_works=cross])])]
+)# _AC_FUNC_FORK
+
+
+# _AC_FUNC_VFORK
+# -------------
+AC_DEFUN([_AC_FUNC_VFORK],
+[AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
 [AC_TRY_RUN([/* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
 #include <sys/types.h>
@@ -1543,17 +1612,17 @@
 }],
             [ac_cv_func_vfork_works=yes],
             [ac_cv_func_vfork_works=no],
-            [AC_CHECK_FUNC(vfork)
-ac_cv_func_vfork_works=$ac_cv_func_vfork])])
-if test "x$ac_cv_func_vfork_works" = xno; then
-  AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
-fi
-])# AC_FUNC_VFORK
+            [ac_cv_func_vfork_works=cross])])
+])# _AC_FUNC_VFORK
+
 
+# AU::AC_FUNC_VFORK
+# ------------
+AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
 
 # AU::AC_VFORK
 # ------------
-AU_ALIAS([AC_VFORK], [AC_FUNC_VFORK])
+AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
 
 
 # AC_FUNC_VPRINTF
@@ -1577,12 +1646,16 @@
 # AC_FUNC_WAIT3
 # -------------
 AC_DEFUN([AC_FUNC_WAIT3],
-[AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
+[AC_REQUIRE([AC_FUNC_FORK])dnl
+AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
 [AC_TRY_RUN(
 [#include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <stdio.h>
+#if !HAVE_WORKING_FORK
+# define fork vfork
+#endif
 /* HP-UX has wait3 but does not fill in rusage at all.  */
 int
 main ()
Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.338
diff -u -r1.338 acspecific.m4
--- acspecific.m4       2001/04/15 16:20:30     1.338
+++ acspecific.m4       2001/06/01 14:35:59
@@ -495,6 +495,7 @@
 # interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'.
 AC_DEFUN([AC_SYS_RESTARTABLE_SYSCALLS],
 [AC_REQUIRE([AC_HEADER_SYS_WAIT])dnl
+AC_REQUIRE([AC_FUNC_FORK])dnl
 AC_CHECK_HEADERS(unistd.h)
 AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -509,6 +510,9 @@
 #endif
 #if HAVE_SYS_WAIT_H
 # include <sys/wait.h>
+#endif
+#if !HAVE_WORKING_FORK
+# define fork vfork
 #endif
 
 /* Some platforms explicitly require an extern "C" signal handler
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.453
diff -u -r1.453 autoconf.texi
--- doc/autoconf.texi   2001/06/01 13:44:45     1.453
+++ doc/autoconf.texi   2001/06/01 14:36:04
@@ -3226,6 +3226,44 @@
 SunOS 5.4), define @code{HAVE_FNMATCH}.
 @end defmac
 
address@hidden AC_FUNC_FORK
address@hidden FUNC_FORK
address@hidden HAVE_VFORK_H
address@hidden HAVE_WORKING_FORK
address@hidden HAVE_WORKING_VFORK
address@hidden vfork
+This macro checks for the @code{fork} and @code{vfork} functions. If a
+working @code{fork} is found, define @code{HAVE_WORKING_FORK}. This macro
+only checks whether @code{fork} is just a stub.
+
+If @file{vfork.h} is found, define @code{HAVE_VFORK_H}. If a working
address@hidden is not found, define @code{vfork} to be @code{fork}, and define
address@hidden  This macro checks for several known errors in
+implementations of @code{vfork} and considers the system to not have a
+working @code{vfork} if it detects any of them.  It is not considered to be
+an implementation error if a child's invocation of @code{signal} modifies
+the parent's signal handler, since child processes rarely change their
+signal handlers.
+
+Typically, use
address@hidden
address@hidden
+#if HAVE_WORKING_FORK
+# define forkvfork fork
+#else
+# define forkvfork vfork
+#endif
+#if !HAVE_WORKING_VFORK
+# define vfork fork
+#endif
address@hidden group
address@hidden example
+and do not rely on @code{vfork} being defined to @code{fork} in later
+versions. This will give you a @code{forkvfork} function for calls
+to @code{fork} that can be replaced by calls to @code{vfork} if the
+former is just a stub.
address@hidden defmac
+
 @defmac AC_FUNC_FSEEKO
 @maindex FUNC_FSEEKO
 @cvindex _LARGEFILE_SOURCE
@@ -3456,19 +3494,6 @@
 the present, define @code{HAVE_UTIME_NULL}.
 @end defmac
 
address@hidden AC_FUNC_VFORK
address@hidden FUNC_VFORK
address@hidden HAVE_VFORK_H
address@hidden vfork
-If @file{vfork.h} is found, define @code{HAVE_VFORK_H}.  If a working
address@hidden is not found, define @code{vfork} to be @code{fork}.  This
-macro checks for several known errors in implementations of @code{vfork}
-and considers the system to not have a working @code{vfork} if it
-detects any of them.  It is not considered to be an implementation error
-if a child's invocation of @code{signal} modifies the parent's signal
-handler, since child processes rarely change their signal handlers.
address@hidden defmac
-
 @defmac AC_FUNC_VPRINTF
 @maindex FUNC_VPRINTF
 @cvindex HAVE_VPRINTF
@@ -9446,6 +9471,11 @@
 @defmac AC_FUNC_CHECK
 @maindex FUNC_CHECK
 @code{AC_CHECK_FUNC}
address@hidden defmac
+
address@hidden AC_FUNC_VFORK
address@hidden FUNC_VFORK
address@hidden
 @end defmac
 
 @defmac AC_GCC_TRADITIONAL


-- 
A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.
                -- Mahatma Ghandi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]