[m-rev.] [PATCH 1/4] Fix detection of pthreads-win32.

Peter Wang novalazy at gmail.com
Thu Mar 20 10:47:55 AEDT 2014


The check for the pthreads-win32 implementation did not work because it
compiled a test program that was designed to be run, but did not run it.
Running a test program is undesirable for cross-compilation anyway.

m4/mercury.m4:
	Replace MERCURY_HAVE_PTHREADS_WIN32 test with one based only on
	successful compilation.
---
 m4/mercury.m4 | 40 ++++++++++++----------------------------
 1 file changed, 12 insertions(+), 28 deletions(-)

diff --git a/m4/mercury.m4 b/m4/mercury.m4
index 7ca48ca..12282d7 100644
--- a/m4/mercury.m4
+++ b/m4/mercury.m4
@@ -774,38 +774,22 @@ fi
 #
 
 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_TRY_COMPILE([#include <pthread.h>],
+    [
+        #ifndef PTW32_VERSION
+            #error I suppose not
+        #endif
+        int self_id(void)
+        {
+            return (int) pthread_self().p;
+        }
+    ],
+    [mercury_cv_have_pthreads_win32=yes],
+    [mercury_cv_have_pthreads_win32=no])
 
 AC_MSG_RESULT($mercury_cv_have_pthreads_win32)
-
 ])
 
 #-----------------------------------------------------------------------------#
-- 
1.8.4




More information about the reviews mailing list