changeset 17705:cc3765e7c7ab

pthread: define thread-safe macros on some platforms * m4/pthread.m4 (gl_PTHREAD_CHECK): Define macros needed for thread-safe operation on some platforms.
author Pádraig Brady <P@draigBrady.com>
date Fri, 13 Jun 2014 19:56:20 +0100
parents 208ef1a25d09
children c4d4dc68512b
files ChangeLog m4/pthread.m4
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-14  Pádraig Brady  <P@draigBrady.com>
+
+	pthread: define thread-safe macros on some platforms
+	* m4/pthread.m4 (gl_PTHREAD_CHECK): Define macros needed
+	for thread-safe operation on some platforms.
+
 2014-06-13  Paul Eggert  <eggert@cs.ucla.edu>
 
 	regex: don't be multithreaded if USE_UNLOCKED_IO.
--- a/m4/pthread.m4
+++ b/m4/pthread.m4
@@ -88,6 +88,20 @@
    fi
    AC_SUBST([LIB_PTHREAD])
 
+   dnl Some systems optimize for single-threaded programs by default, and
+   dnl need special flags to disable these optimizations. For example, the
+   dnl definition of 'errno' in <errno.h>.
+   case "$host_os" in
+     aix* | freebsd*)
+       AC_DEFINE([_THREAD_SAFE], 1,
+         [Define on some systems, to enable only thread-safe operations.])
+     ;;
+     osf* | solaris*)
+       AC_DEFINE([_REENTRANT], 1,
+         [Define on some systems, to enable only thread-safe operations.])
+     ;;
+   esac
+
    AC_REQUIRE([AC_C_RESTRICT])
 ])