diff options
Diffstat (limited to 'gnulib/import/glthread/lock.c')
-rw-r--r-- | gnulib/import/glthread/lock.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/gnulib/import/glthread/lock.c b/gnulib/import/glthread/lock.c index e471188..10af6f2 100644 --- a/gnulib/import/glthread/lock.c +++ b/gnulib/import/glthread/lock.c @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2019 Free Software Foundation, Inc. + Copyright (C) 2005-2020 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -254,7 +254,7 @@ glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) # if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1))) -# ifdef PTHREAD_RWLOCK_INITIALIZER +# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP # if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ @@ -718,6 +718,26 @@ glthread_once_singlethreaded (pthread_once_t *once_control) return 0; } +# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK) + +int +glthread_once_multithreaded (pthread_once_t *once_control, + void (*init_function) (void)) +{ + int err = pthread_once (once_control, init_function); + if (err == ENOSYS) + { + /* This happens on FreeBSD 11: The pthread_once function in libc returns + ENOSYS. */ + if (glthread_once_singlethreaded (once_control)) + init_function (); + return 0; + } + return err; +} + +# endif + #endif /* ========================================================================= */ |