diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
| commit | cfd1f17f1a85d95ea12bca8dae42add7dad1ad11 (patch) | |
| tree | 8016486f8ee7157213f2d09ff2491bfa9c94638a /lib/glthread/lock.c | |
| parent | 14e4d584d0121031ec40e6c35869745f1747ff29 (diff) | |
| parent | 1403307d6e2fb4e7b5d97a35f40d1e95134561ab (diff) | |
Merge branch 'release/debian/1.4.2-1'HEADdebian/1.4.2-1master
Diffstat (limited to 'lib/glthread/lock.c')
| -rw-r--r-- | lib/glthread/lock.c | 70 |
1 files changed, 19 insertions, 51 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; |
