diff --git a/aclocal.m4 b/aclocal.m4 index 0c4c8bf29..43b6b221f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -524,3 +524,43 @@ fi ]) #-----------------------------------------------------------------------------# +# +# Check if the POSIX threads library is pthreads-win32. +# + +AC_DEFUN([MERCURY_HAVE_PTHREADS_WIN32], [ + +AC_MSG_CHECKING([if we are using pthreads-win32]) + +cat > conftest.c << EOF + +#include +#include + +int main(int argc, char **argv) +{ + +#if defined(PTW32_VERSION) + return 0; +#else + return 1; +#endif + +} + +EOF + +echo "$CC -o conftest contest.c" >&AC_FD_CC 2>&1 +if + $CC -o conftest conftest.c +then + mercury_cv_have_pthreads_win32="yes" +else + mercury_cv_have_pthreads_win32="no" +fi + +AC_MSG_RESULT($mercury_cv_have_pthreads_win32) + +]) + +#-----------------------------------------------------------------------------# diff --git a/configure.in b/configure.in index 70b789e52..413ba6b2f 100644 --- a/configure.in +++ b/configure.in @@ -59,6 +59,7 @@ AC_PREREQ(2.58) # Strip out any site or system specific configuration files since their # presence when reconfiguring will result in the command line used to invoke # configure being invalid. + # Also quote any args containing shell metacharacters. # # NOTE: Some macros, e.g. AC_CHECK_PROG, overwrite the argument list, @@ -1222,6 +1223,19 @@ if test "$MR_HAVE_UCONTEXT_H" != 1; then MERCURY_CHECK_FOR_HEADERS(sys/ucontext.h) fi +if test "$MR_HAVE_PTHREAD_H" = 1 +then + case "$host" in + *mingw*) + MERCURY_HAVE_PTHREADS_WIN32 + if test $mercury_cv_have_pthreads_win32 = "yes" + then + AC_DEFINE([MR_PTHREADS_WIN32]) + fi + ;; + esac +fi + #-----------------------------------------------------------------------------# # # Check whether we can set the FP rounding mode diff --git a/runtime/mercury_conf.h.in b/runtime/mercury_conf.h.in index 723697f30..816d61cc9 100644 --- a/runtime/mercury_conf.h.in +++ b/runtime/mercury_conf.h.in @@ -409,9 +409,12 @@ ** MR_THREAD_LOCAL_STORAGE is defined if the thread-local storage extension ** is supported. That is, the compiler extends the C language with the ** `__thread' specifier. +** +** MR_PTHREADS_WIN32 is defined if we are using the pthreads-win32 library. */ #undef MR_DIGITAL_UNIX_PTHREADS #undef MR_THREAD_LOCAL_STORAGE +#undef MR_PTHREADS_WIN32 /* ** The bytecode files represent floats in 64-bit IEEE format.