I looked into this some more, and found some problems:
* On Solaris we also need to define _POSIX_PTHREAD_SEMANTICS to prefer POSIX to pre-POSIX semantics for a few functions; see <http://docs.oracle.com/cd/E19683-01/806-6867/compile-fig-5/index.html>. The extensions module does this, so a simple fix is to depend on the extensions module. Almost everybody uses extensions anyway so I don't view this as being a big issue. (Maybe threadlib should also depend on extensions, instead its calls to AC_USE_SYSTEM_EXTENSIONS and AC_GNU_SOURCE?)
* The patch uses $host_os so it should AC_REQUIRE([AC_CANONICAL_HOST]). But why bother? AC_CANONICAL_HOST is expensive and not every project needs it. Instead, just define the symbols on all platforms; that's what 'extensions' does.
* This new behavior should be done in gl_EARLY, as _REENTRANT and _THREAD_SAFE affect the visibility of many other symbols.
So, how about the attached patch instead? (I haven't tested it.)
From 615308a8efa422d3697ff84afb73c6e8f92b738d Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Sat, 14 Jun 2014 10:05:34 -0700 Subject: [PATCH] pthread: port to hosts like AIX that need macros like _THREAD_SAFE * modules/pthread (Depends-on): Add 'extensions'. (configure.ac-early): New section. --- ChangeLog | 6 ++++++ modules/pthread | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index cd19897..0ae08ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-06-14 Paul Eggert <egg...@cs.ucla.edu> + + pthread: port to hosts like AIX that need macros like _THREAD_SAFE + * modules/pthread (Depends-on): Add 'extensions'. + (configure.ac-early): New section. + 2014-06-13 Paul Eggert <egg...@cs.ucla.edu> regex: don't be multithreaded if USE_UNLOCKED_IO. diff --git a/modules/pthread b/modules/pthread index e583929..3fb3920 100644 --- a/modules/pthread +++ b/modules/pthread @@ -7,10 +7,15 @@ lib/pthread.in.h m4/pthread.m4 Depends-on: +extensions extern-inline sched time +configure.ac-early: +AC_DEFINE([_REENTRANT], 1, [For thread-safety on OSF/1, Solaris.]) +AC_DEFINE([_THREAD_SAFE], 1, [For thread-safety on AIX, FreeBSD.]) + configure.ac: gl_PTHREAD_CHECK gl_MODULE_INDICATOR([pthread]) -- 1.9.3