>From 9c42aee8fe88c4dfe6b6e60e1570aac759829b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Fri, 13 Jun 2014 19:56:20 +0100 Subject: [PATCH] pthread: define thread safe macros on some platforms * m4/pthread.m4 (gl_PTHREAD_CHECK): When not using the threadlib module, which otherwise handles this, define macros needed for thread safe access on some platforms. --- ChangeLog | 7 +++++++ m4/pthread.m4 | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd19897..10c43d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-06-13 Pádraig Brady + + pthread: define thread safe macros on some platforms + * m4/pthread.m4 (gl_PTHREAD_CHECK): When not using the + threadlib module, which otherwise handles this, define + macros needed for thread safe access on some platforms. + 2014-06-13 Paul Eggert regex: don't be multithreaded if USE_UNLOCKED_IO. diff --git a/m4/pthread.m4 b/m4/pthread.m4 index 1ed0dd3..9288d59 100644 --- a/m4/pthread.m4 +++ b/m4/pthread.m4 @@ -88,6 +88,30 @@ AC_DEFUN([gl_PTHREAD_CHECK], fi AC_SUBST([LIB_PTHREAD]) + dnl If the threadlib module isn't selected then setup + dnl macros to enable threadsafe operation on some platforms + if test x"$gl_use_threads" = x; then + # For using : + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_LINK_IFELSE test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + esac + fi + AC_REQUIRE([AC_C_RESTRICT]) ]) -- 1.7.7.6