mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Honor --with-thread option to enable pthread
This commit is contained in:
parent
2999eb8846
commit
c7d2247e35
2 changed files with 52 additions and 48 deletions
49
configure.ac
49
configure.ac
|
@ -950,26 +950,7 @@ AS_CASE(["$target_os"],
|
|||
RUBY_APPEND_OPTION(CPPFLAGS, -D__MINGW_USE_VC2005_COMPAT)
|
||||
])
|
||||
|
||||
AS_CASE(["$target_os"],
|
||||
[freebsd*], [
|
||||
AC_CACHE_CHECK([whether pthread should be enabled by default],
|
||||
rb_cv_enable_pthread_default,
|
||||
[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <osreldate.h>
|
||||
#if __FreeBSD_version < 502102
|
||||
#error pthread should be disabled on this platform
|
||||
#endif
|
||||
]])],
|
||||
rb_cv_enable_pthread_default=yes,
|
||||
rb_cv_enable_pthread_default=no)])
|
||||
enable_pthread=$rb_cv_enable_pthread_default
|
||||
],
|
||||
[mingw*], [
|
||||
enable_pthread=no
|
||||
],
|
||||
[
|
||||
enable_pthread=yes
|
||||
])
|
||||
RUBY_THREAD
|
||||
|
||||
dnl Checks for libraries.
|
||||
AS_CASE(["$target_os"],[*bsd*|dragonfly*],[],[ac_cv_func_daemon=no])
|
||||
|
@ -2652,25 +2633,7 @@ AC_DEFINE_UNQUOTED(COROUTINE_H, ["$COROUTINE_H"])
|
|||
AC_SUBST(X_COROUTINE_H, [$COROUTINE_H])
|
||||
AC_SUBST(X_COROUTINE_SRC, [$COROUTINE_SRC])
|
||||
|
||||
AS_IF([test x"$enable_pthread" = xyes], [
|
||||
for pthread_lib in thr pthread pthreads c c_r root; do
|
||||
AC_CHECK_LIB($pthread_lib, pthread_create,
|
||||
rb_with_pthread=yes, rb_with_pthread=no)
|
||||
AS_IF([test "$rb_with_pthread" = "yes"], [break])
|
||||
done
|
||||
AS_IF([test x"$rb_with_pthread" = xyes], [
|
||||
AC_DEFINE(_REENTRANT)
|
||||
AC_DEFINE(_THREAD_SAFE)
|
||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
||||
AC_CHECK_HEADERS(pthread_np.h, [], [], [@%:@include <pthread.h>])
|
||||
AS_CASE(["$pthread_lib:$target_os"],
|
||||
[c:*], [],
|
||||
[root:*], [],
|
||||
[c_r:*|*:openbsd*|*:mirbsd*], [LIBS="-pthread $LIBS"],
|
||||
[LIBS="-l$pthread_lib $LIBS"])
|
||||
], [
|
||||
AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
|
||||
])
|
||||
AS_IF([test "$THREAD_MODEL" = pthread], [
|
||||
AC_CACHE_CHECK([whether pthread_t is scalar type], [rb_cv_scalar_pthread_t], [
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <pthread.h>
|
||||
|
@ -2759,12 +2722,12 @@ AS_IF([test x"$ac_cv_header_ucontext_h" = xyes -o x"$rb_cv_ucontext_in_signal_h"
|
|||
], [
|
||||
AC_DEFINE_UNQUOTED(DEFINE_MCONTEXT_PTR(mc, uc), mcontext_t *mc = &(uc)->uc_mcontext)
|
||||
])
|
||||
AS_IF([test x"$rb_with_pthread" = xyes], [
|
||||
AS_IF([test x"$THREAD_MODEL" = xpthread], [
|
||||
AC_CHECK_FUNCS(getcontext setcontext)
|
||||
])
|
||||
])
|
||||
|
||||
AS_IF([test "$ac_cv_func_fork_works" = "yes" -a "$rb_with_pthread" = "yes"], [
|
||||
AS_IF([test "$ac_cv_func_fork_works" = "yes" -a x"$THREAD_MODEL" = xpthread], [
|
||||
AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
|
||||
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <stdlib.h>
|
||||
|
@ -3893,8 +3856,6 @@ AS_CASE(["$target_os"],
|
|||
|
||||
MINIOBJS="$MINIDLNOBJ"
|
||||
|
||||
RUBY_THREAD
|
||||
|
||||
AC_ARG_ENABLE(debug-env,
|
||||
AS_HELP_STRING([--enable-debug-env], [enable RUBY_DEBUG environment variable]),
|
||||
[AC_SUBST(ENABLE_DEBUG_ENV, yes)])
|
||||
|
@ -4421,7 +4382,7 @@ config_summary "site libraries path" "$rubysitearchprefix"
|
|||
config_summary "vendor path" "$vendordir"
|
||||
config_summary "target OS" "$target_os"
|
||||
config_summary "compiler" "$CC"
|
||||
config_summary "with pthread" "$enable_pthread"
|
||||
config_summary "with thread" "$THREAD_MODEL"
|
||||
config_summary "with coroutine" "$coroutine_type"
|
||||
config_summary "enable shared libs" "$ENABLE_SHARED"
|
||||
config_summary "dynamic library ext" "$DLEXT"
|
||||
|
|
|
@ -5,6 +5,21 @@ AC_ARG_WITH(thread,
|
|||
[THREAD_MODEL=$withval], [
|
||||
THREAD_MODEL=
|
||||
AS_CASE(["$target_os"],
|
||||
[freebsd*], [
|
||||
AC_CACHE_CHECK([whether pthread should be enabled by default],
|
||||
rb_cv_enable_pthread_default,
|
||||
[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
|
||||
@%:@include <osreldate.h>
|
||||
@%:@if __FreeBSD_version < 502102
|
||||
@%:@error pthread should be disabled on this platform
|
||||
@%:@endif
|
||||
]])],
|
||||
rb_cv_enable_pthread_default=yes,
|
||||
rb_cv_enable_pthread_default=no)])
|
||||
AS_IF([test $rb_cv_enable_pthread_default = yes],
|
||||
[THREAD_MODEL=pthread],
|
||||
[THREAD_MODEL=none])
|
||||
],
|
||||
[mingw*], [
|
||||
THREAD_MODEL=win32
|
||||
],
|
||||
|
@ -12,19 +27,47 @@ AC_ARG_WITH(thread,
|
|||
THREAD_MODEL=none
|
||||
],
|
||||
[
|
||||
AS_IF([test "$rb_with_pthread" = "yes"], [
|
||||
THREAD_MODEL=pthread
|
||||
])
|
||||
]
|
||||
)
|
||||
])
|
||||
|
||||
AS_IF([test x"$THREAD_MODEL" = xpthread], [
|
||||
AC_CHECK_HEADERS(pthread.h)
|
||||
AS_IF([test x"$ac_cv_header_pthread_h" = xyes], [], [
|
||||
AC_MSG_WARN("Don't know how to find pthread header on your system -- thread support disabled")
|
||||
THREAD_MODEL=none
|
||||
])
|
||||
])
|
||||
AS_IF([test x"$THREAD_MODEL" = xpthread], [
|
||||
THREAD_MODEL=none
|
||||
for pthread_lib in thr pthread pthreads c c_r root; do
|
||||
AC_CHECK_LIB($pthread_lib, pthread_create,
|
||||
[THREAD_MODEL=pthread; break])
|
||||
done
|
||||
AS_IF([test x"$THREAD_MODEL" = xpthread], [
|
||||
AC_DEFINE(_REENTRANT)
|
||||
AC_DEFINE(_THREAD_SAFE)
|
||||
AC_DEFINE(HAVE_LIBPTHREAD)
|
||||
AC_CHECK_HEADERS(pthread_np.h, [], [], [@%:@include <pthread.h>])
|
||||
AS_CASE(["$pthread_lib:$target_os"],
|
||||
[c:*], [],
|
||||
[root:*], [],
|
||||
[c_r:*|*:openbsd*|*:mirbsd*], [LIBS="-pthread $LIBS"],
|
||||
[LIBS="-l$pthread_lib $LIBS"])
|
||||
], [
|
||||
AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
|
||||
])
|
||||
])
|
||||
|
||||
AS_CASE(["$THREAD_MODEL"],
|
||||
[pthread], [AC_CHECK_HEADERS(pthread.h)],
|
||||
[pthread], [],
|
||||
[win32], [],
|
||||
[none], [],
|
||||
[""], [AC_MSG_ERROR(thread model is missing)],
|
||||
[AC_MSG_ERROR(unknown thread model $THREAD_MODEL)])
|
||||
AC_MSG_CHECKING(thread model)
|
||||
AC_MSG_RESULT($THREAD_MODEL)
|
||||
|
||||
THREAD_IMPL_H=thread_$THREAD_MODEL.h
|
||||
AS_IF([test ! -f "$srcdir/$THREAD_IMPL_H"],
|
||||
|
|
Loading…
Reference in a new issue