summaryrefslogtreecommitdiff
path: root/lib/glthread
diff options
context:
space:
mode:
Diffstat (limited to 'lib/glthread')
-rw-r--r--lib/glthread/lock.c70
-rw-r--r--lib/glthread/lock.h4
-rw-r--r--lib/glthread/once.c2
-rw-r--r--lib/glthread/once.h2
-rw-r--r--lib/glthread/threadlib.c2
5 files changed, 24 insertions, 56 deletions
diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c
index 40b2a5ee..cfb9393c 100644
--- a/lib/glthread/lock.c
+++ b/lib/glthread/lock.c
@@ -1,5 +1,5 @@
/* Locking in multithreaded situations.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2026 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -255,21 +255,19 @@ glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
# 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 */
+ /* glibc with bug https://sourceware.org/PR13701 */
int
glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
{
pthread_rwlockattr_t attributes;
- int err;
-
- err = pthread_rwlockattr_init (&attributes);
+ int err = pthread_rwlockattr_init (&attributes);
if (err != 0)
return err;
/* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that
causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not
do this; see
- http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
+ https://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
err = pthread_rwlockattr_setkind_np (&attributes,
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
if (err == 0)
@@ -286,9 +284,7 @@ glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
int
glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
{
- int err;
-
- err = pthread_rwlock_init (&lock->rwlock, NULL);
+ int err = pthread_rwlock_init (&lock->rwlock, NULL);
if (err != 0)
return err;
lock->initialized = 1;
@@ -300,9 +296,7 @@ glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
{
if (!lock->initialized)
{
- int err;
-
- err = pthread_mutex_lock (&lock->guard);
+ int err = pthread_mutex_lock (&lock->guard);
if (err != 0)
return err;
if (!lock->initialized)
@@ -326,9 +320,7 @@ glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
{
if (!lock->initialized)
{
- int err;
-
- err = pthread_mutex_lock (&lock->guard);
+ int err = pthread_mutex_lock (&lock->guard);
if (err != 0)
return err;
if (!lock->initialized)
@@ -358,11 +350,9 @@ glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
int
glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
{
- int err;
-
if (!lock->initialized)
return EINVAL;
- err = pthread_rwlock_destroy (&lock->rwlock);
+ int err = pthread_rwlock_destroy (&lock->rwlock);
if (err != 0)
return err;
lock->initialized = 0;
@@ -376,9 +366,7 @@ glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
int
glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
{
- int err;
-
- err = pthread_mutex_init (&lock->lock, NULL);
+ int err = pthread_mutex_init (&lock->lock, NULL);
if (err != 0)
return err;
err = pthread_cond_init (&lock->waiting_readers, NULL);
@@ -395,9 +383,7 @@ glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
int
glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
{
- int err;
-
- err = pthread_mutex_lock (&lock->lock);
+ int err = pthread_mutex_lock (&lock->lock);
if (err != 0)
return err;
/* Test whether only readers are currently running, and whether the runcount
@@ -422,9 +408,7 @@ glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
int
glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
{
- int err;
-
- err = pthread_mutex_lock (&lock->lock);
+ int err = pthread_mutex_lock (&lock->lock);
if (err != 0)
return err;
/* Test whether no readers or writers are currently running. */
@@ -449,9 +433,7 @@ glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
int
glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
{
- int err;
-
- err = pthread_mutex_lock (&lock->lock);
+ int err = pthread_mutex_lock (&lock->lock);
if (err != 0)
return err;
if (lock->runcount < 0)
@@ -505,9 +487,7 @@ glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
int
glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
{
- int err;
-
- err = pthread_mutex_destroy (&lock->lock);
+ int err = pthread_mutex_destroy (&lock->lock);
if (err != 0)
return err;
err = pthread_cond_destroy (&lock->waiting_readers);
@@ -531,9 +511,7 @@ int
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
{
pthread_mutexattr_t attributes;
- int err;
-
- err = pthread_mutexattr_init (&attributes);
+ int err = pthread_mutexattr_init (&attributes);
if (err != 0)
return err;
err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
@@ -560,9 +538,7 @@ int
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
{
pthread_mutexattr_t attributes;
- int err;
-
- err = pthread_mutexattr_init (&attributes);
+ int err = pthread_mutexattr_init (&attributes);
if (err != 0)
return err;
err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
@@ -589,9 +565,7 @@ glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
{
if (!lock->initialized)
{
- int err;
-
- err = pthread_mutex_lock (&lock->guard);
+ int err = pthread_mutex_lock (&lock->guard);
if (err != 0)
return err;
if (!lock->initialized)
@@ -621,11 +595,9 @@ glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
int
glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
{
- int err;
-
if (!lock->initialized)
return EINVAL;
- err = pthread_mutex_destroy (&lock->recmutex);
+ int err = pthread_mutex_destroy (&lock->recmutex);
if (err != 0)
return err;
lock->initialized = 0;
@@ -639,9 +611,7 @@ glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
int
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
{
- int err;
-
- err = pthread_mutex_init (&lock->mutex, NULL);
+ int err = pthread_mutex_init (&lock->mutex, NULL);
if (err != 0)
return err;
lock->owner = (pthread_t) 0;
@@ -655,9 +625,7 @@ glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
pthread_t self = pthread_self ();
if (lock->owner != self)
{
- int err;
-
- err = pthread_mutex_lock (&lock->mutex);
+ int err = pthread_mutex_lock (&lock->mutex);
if (err != 0)
return err;
lock->owner = self;
diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h
index 2b9c0f2e..d8190b6c 100644
--- a/lib/glthread/lock.h
+++ b/lib/glthread/lock.h
@@ -1,5 +1,5 @@
/* Locking in multithreaded situations.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2026 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -239,7 +239,7 @@ typedef pthread_rwlock_t gl_rwlock_t;
# endif
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
-# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
+# else /* glibc with bug https://sourceware.org/PR13701 */
# define gl_rwlock_initializer \
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
# define glthread_rwlock_init(LOCK) \
diff --git a/lib/glthread/once.c b/lib/glthread/once.c
index 869ba3ba..b72a4a20 100644
--- a/lib/glthread/once.c
+++ b/lib/glthread/once.c
@@ -1,5 +1,5 @@
/* Once-only initialization in multithreaded situations.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2026 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/glthread/once.h b/lib/glthread/once.h
index 2452f88d..b6d9ab40 100644
--- a/lib/glthread/once.h
+++ b/lib/glthread/once.h
@@ -1,5 +1,5 @@
/* Once-only initialization in multithreaded situations.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2026 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
diff --git a/lib/glthread/threadlib.c b/lib/glthread/threadlib.c
index 7a776768..5c0ba1f4 100644
--- a/lib/glthread/threadlib.c
+++ b/lib/glthread/threadlib.c
@@ -1,5 +1,5 @@
/* Multithreading primitives.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2026 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as