[m-rev.] diff: have configure check for the use of pthreads-win32

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Dec 9 17:12:25 AEDT 2010


The following is needed in order to integrate the remainder of Sergey
Khorev's pthreads-win32 patch.  I'm comitting this bit now so that it
can be available on all the machines I am testing on.

--------------

Branches: main, 10.04

Have configure check for the use of the pthreads-win32 library on MinGW.  (In
the future we may also want to do this in the case where Cygwin is being used
to cross-compile a native Windows version of Mercury, although this change
doesn't handle that case.)

runtime/mercury_conf.h.in:
 	Add a new configuration macro that is defined if the threads
 	library is pthreads-win32.

configure.in:
 	If POSIX threads are available and we are on MinGW check if we are
 	using pthreads-win32 (which should be the case sice AFAIK there
 	isn't a readily available alternative).

aclocal.m4:
 	Add a new macro that checks if the threads library is
 	pthreads-win32.

Julien.

Index: aclocal.m4
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.36
diff -u -r1.36 aclocal.m4
--- aclocal.m4	30 Sep 2010 07:23:30 -0000	1.36
+++ aclocal.m4	9 Dec 2010 05:55:46 -0000
@@ -524,3 +524,43 @@
  ])

  #-----------------------------------------------------------------------------#
+#
+# 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 <pthread.h>
+#include <stdio.h>
+
+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)
+
+])
+
+#-----------------------------------------------------------------------------#
Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.570
diff -u -r1.570 configure.in
--- configure.in	7 Dec 2010 03:42:47 -0000	1.570
+++ configure.in	9 Dec 2010 05:55:46 -0000
@@ -59,6 +59,7 @@
  # 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 @@
      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
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.70
diff -u -r1.70 mercury_conf.h.in
--- runtime/mercury_conf.h.in	6 Dec 2010 03:56:17 -0000	1.70
+++ runtime/mercury_conf.h.in	9 Dec 2010 05:55:46 -0000
@@ -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.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list