summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-24 08:20:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-24 08:20:42 +0000
commitac531a8aa8aff6776c0525fc25381d5d4a483753 (patch)
tree9e88e034a12064121d0decf90407d9ba2b86484e /configure.in
parenta0e7746d78b22585b7f3efd3bc7aa298305c567c (diff)
* configure.in (rb_cv_fork_with_pthread): check after check for
pthread library, and define the macro when checked only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in121
1 files changed, 63 insertions, 58 deletions
diff --git a/configure.in b/configure.in
index da8518f440..2b43c6878f 100644
--- a/configure.in
+++ b/configure.in
@@ -766,64 +766,6 @@ AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp(env${setjmp_sigma
AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)])
AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
-
-case $target_os in
-*bsd*|darwin*)
-AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
-[AC_TRY_RUN([
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-
-void *
-thread_func(void *dmy)
-{
- return dmy;
-}
-
-void *use_threads(void)
-{
- pthread_t tid;
- if (pthread_create(&tid, 0, thread_func, 0) != 0) {
- exit(1);
- }
- if (pthread_join(tid, 0) != 0) {
- exit(1);
- }
-}
-
-int
-main(int argc, char *argv[])
-{
- pid_t pid;
- use_threads();
- pid = fork();
-
- if (pid) {
- int loc;
- sleep(1);
- if (waitpid(pid, &loc, WNOHANG) == 0) {
- kill(pid, SIGKILL);
- return 1;
- }
- }
- else {
- use_threads();
- }
-
- return 0;
-}]
- rb_cv_fork_with_pthread=yes,
- rb_cv_fork_with_pthread=no,
- rb_cv_fork_with_pthread=yes)])
- ;;
-esac
-test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
-
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
[use_setreuid=$enableval])
@@ -1161,6 +1103,69 @@ if test x"$ac_cv_header_ucontext_h" = xyes; then
fi
fi
+if test "$ac_cv_func_fork" = "yes" -a "$rb_with_pthread" = "yes"; then
+ AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
+ [AC_TRY_RUN([
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+void *
+thread_func(void *dmy)
+{
+ return dmy;
+}
+
+int
+use_threads(void)
+{
+ pthread_t tid;
+ if (pthread_create(&tid, 0, thread_func, 0) != 0) {
+ return -1;
+ }
+ if (pthread_join(tid, 0) != 0) {
+ return -1;
+ }
+ return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+ pid_t pid;
+ if (use_threads()) return EXIT_FAILURE;
+ pid = fork();
+
+ if (pid) {
+ int loc;
+ sleep(1);
+ if (waitpid(pid, &loc, WNOHANG) == 0) {
+ kill(pid, SIGKILL);
+ return EXIT_FAILURE;
+ }
+ }
+ else {
+ if (use_threads()) return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}]
+ rb_cv_fork_with_pthread=yes,
+ rb_cv_fork_with_pthread=no,
+ rb_cv_fork_with_pthread=yes)])
+ test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
+fi
+
AC_CHECK_FUNCS(backtrace)
AC_ARG_WITH(valgrind,