autoconf
[Top][All Lists]
Advanced

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

AmigaOS fork()


From: Rüdiger Kuhlmann
Subject: AmigaOS fork()
Date: Thu, 24 May 2001 02:20:23 +0200
User-agent: Mutt/1.3.17i

<de-lurking>

Hi there!

Since we've autoconf 2.50 now, maybe it's time to come up with some
not-so-important issues. The problem at hand is that under AmigaOS, the
fork() function always returns EONOSYS (IIRC), in other words, there is no
spoon(), due to limitations that can't seriously be overcome. However,
there is a fairly well vfork(), that very often can be used instead.
Hence, it seems reasonable to #define fork to be vfork in this case.
I made a patch for a new AC_FUNC_FORK, to be AC_REQUIRE'd by all
tests using fork(). Another solution would be to use lots of #ifdefs
on __amigaos__ (or AMIGA, whichever you consider more appropriate)
around fork() calls in the tests, but this leaves the question what
to do to supply this information to the make process.

Anyway, here's the patch - I do not consider it final, please tell
me what you think.

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/05/23 23:53:42
@@ -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(),
@@ -1442,6 +1443,39 @@
 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
 
 
+# AC_FUNC_FORK
+# -------------
+AC_DEFUN([AC_FUNC_FORK],
+[AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
+[AC_TRY_RUN([/* By Rüdiger Kuhlmann. */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+/* On AmigaOS, fork() isn't implemented due to missing MP. */
+int main ()
+{
+  if (fork() < 0)
+    exit (1);
+  exit (0);
+}],
+            [ac_cv_func_fork_works=yes],
+            [ac_cv_func_fork_works=no],
+            [AC_CHECK_FUNC(fork)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return __amigaos__;])],
+                   [ac_cv_func_fork_works=no],
+                   [ac_cv_func_fork_works=$ac_cv_func_fork])
+])])
+if test "x$ac_cv_func_fork_works" = xno; then
+  AC_FUNC_VFORK
+  if test "x$ac_cv_func_vfork_works" = xyes; then
+    AC_DEFINE(fork, vfork, [Define as `vfork' if `fork' does not work, but 
`vfork' does.])
+  fi
+fi
+])# AC_FUNC_FORK
+
 # AC_FUNC_VFORK
 # -------------
 AC_DEFUN([AC_FUNC_VFORK],
@@ -1547,6 +1581,8 @@
 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.])
+else
+  AC_DEFINE(HAVE_VFORK, 1, [Define if `vfork' works.])
 fi
 ])# AC_FUNC_VFORK
 
@@ -1577,7 +1613,8 @@
 # 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>
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/05/23 23:53:46
@@ -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(


Thanks, Rüdiger.

-- 
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]