[m-rev.] for review: pthread_mutexattr_setpshared

Peter Wang novalazy at gmail.com
Thu Oct 28 17:45:30 AEDT 2010


Branches: main, 10.04

Do not assume that pthread_mutexattr_setpshared() is available everywhere
that pthread.h is available.  It is used to synchronise processes in the
`mmc --make --jobs' implementation.

configure.in:
runtime/mercury_conf.h.in:
        Define MR_HAVE_PTHREAD_MUTEXATTR_SETPSHARED if
        `pthread_mutexattr_setpshared' is found.

compiler/make.util.m:
        Only use pthread_mutexattr_setpshared() if it was found.

diff --git a/compiler/make.util.m b/compiler/make.util.m
index 12f709c..3f925bc 100644
--- a/compiler/make.util.m
+++ b/compiler/make.util.m
@@ -572,7 +572,8 @@ typedef struct MC_JobCtl MC_JobCtl;
   ** POSIX mutexes; the functions fail when you try to create them.
   ** System V semaphores do work however.
   */
-  #if !defined(__APPLE__) && defined(MR_HAVE_PTHREAD_H)
+  #if !defined(__APPLE__) && defined(MR_HAVE_PTHREAD_H) && \
+        defined(MR_HAVE_PTHREAD_MUTEXATTR_SETPSHARED)
     #include <pthread.h>
 
     #define MC_HAVE_JOBCTL_IPC 1
diff --git a/configure.in b/configure.in
index a40711e..8dcea44 100644
--- a/configure.in
+++ b/configure.in
@@ -2996,6 +2996,12 @@ AC_SUBST(LD_LIBFLAGS_FOR_THREADS)
 AC_SUBST(ENABLE_BOEHM_THREAD_LOCAL_ALLOC)
 AC_SUBST(ENABLE_BOEHM_PARALLEL_MARK)
 
+save_LIBS="$LIBS"
+LIBS="$THREAD_LIBS"
+mercury_check_for_functions \
+        pthread_mutexattr_setpshared
+LIBS="$save_LIBS"
+
 #-----------------------------------------------------------------------------#
 
 AC_MSG_CHECKING(whether we can use thread-local storage class extension)
diff --git a/runtime/mercury_conf.h.in b/runtime/mercury_conf.h.in
index 811c58b..7739b37 100644
--- a/runtime/mercury_conf.h.in
+++ b/runtime/mercury_conf.h.in
@@ -273,6 +273,8 @@
 **	MR_HAVE_SCHED_SETAFFINITY we have the sched_setaffinity() function.
 **	MR_HAVE_SCHED_GETCPU	we have the sched_getcpu() function (glibc specific).
 **	MR_HAVE_SCHED_YIELD	we have the sched_yield() function.
+**	MR_HAVE_PTHREAD_MUTEXATTR_SETPSHARED we have the
+**				pthread_mutexattr_setpshared() function.
 */
 #undef	MR_HAVE_GETPID
 #undef	MR_HAVE_SETPGID
@@ -337,6 +339,7 @@
 #undef	MR_HAVE_SCHED_SETAFFINITY
 #undef	MR_HAVE_SCHED_GETCPU
 #undef	MR_HAVE_SCHED_YIELD
+#undef	MR_HAVE_PTHREAD_MUTEXATTR_SETPSHARED
 
 /*
 ** We use mprotect() and signals to catch stack and heap overflows.

--------------------------------------------------------------------------
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