summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2017-01-05 10:04:52 (GMT)
committerBruno Haible <bruno@clisp.org>2017-01-05 10:05:46 (GMT)
commitfd8eabdce96cfaf41234241a8d659958934beddd (patch)
tree18316e4a84787ae4cf7993d2c25e9cb9998b76a7
parent15b8f3046a25096ae479682127992816d6e14032 (diff)
downloadgnulib-fd8eabdce96cfaf41234241a8d659958934beddd.zip
gnulib-fd8eabdce96cfaf41234241a8d659958934beddd.tar.gz
gnulib-fd8eabdce96cfaf41234241a8d659958934beddd.tar.bz2
thread: Fix pth port.
* lib/glthread/thread.h (pth_init): Declare weak. (glthread_create, glthread_sigmask, glthread_join, gl_thread_self, gl_thread_exit): Make sure Pth is initialized before invoking any Pth function.
-rw-r--r--ChangeLog8
-rw-r--r--lib/glthread/thread.h11
2 files changed, 14 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 316a890..e8d0f34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-01-05 Bruno Haible <bruno@clisp.org>
+
+ thread: Fix pth port.
+ * lib/glthread/thread.h (pth_init): Declare weak.
+ (glthread_create, glthread_sigmask, glthread_join, gl_thread_self,
+ gl_thread_exit): Make sure Pth is initialized before invoking any Pth
+ function.
+
2017-01-04 Assaf Gordon <assafgordon@gmail.com>
parse-datetime: fix debug message on lone year number
diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h
index 03e8f57..72bdd9b 100644
--- a/lib/glthread/thread.h
+++ b/lib/glthread/thread.h
@@ -219,6 +219,7 @@ extern "C" {
/* Use weak references to the GNU Pth threads library. */
+# pragma weak pth_init
# pragma weak pth_spawn
# pragma weak pth_sigmask
# pragma weak pth_join
@@ -237,17 +238,17 @@ extern "C" {
typedef pth_t gl_thread_t;
# define glthread_create(THREADP, FUNC, ARG) \
- (pth_in_use () ? ((*(THREADP) = pth_spawn (NULL, FUNC, ARG)) ? 0 : errno) : 0)
+ (pth_in_use () ? (pth_init (), ((*(THREADP) = pth_spawn (NULL, FUNC, ARG)) ? 0 : errno)) : 0)
# define glthread_sigmask(HOW, SET, OSET) \
- (pth_in_use () && !pth_sigmask (HOW, SET, OSET) ? errno : 0)
+ (pth_in_use () ? (pth_init (), (pth_sigmask (HOW, SET, OSET) ? 0 : errno)) : 0)
# define glthread_join(THREAD, RETVALP) \
- (pth_in_use () && !pth_join (THREAD, RETVALP) ? errno : 0)
+ (pth_in_use () ? (pth_init (), (pth_join (THREAD, RETVALP) ? 0 : errno)) : 0)
# define gl_thread_self() \
- (pth_in_use () ? (void *) pth_self () : NULL)
+ (pth_in_use () ? (pth_init (), (void *) pth_self ()) : NULL)
# define gl_thread_self_pointer() \
gl_thread_self ()
# define gl_thread_exit(RETVAL) \
- (pth_in_use () ? pth_exit (RETVAL) : 0)
+ (pth_in_use () ? (pth_init (), pth_exit (RETVAL)) : 0)
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
# ifdef __cplusplus