diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-08 17:28:33 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-08 17:28:33 +0100 |
| commit | 5f59a34ab747dde8ede7357f3431bf06bd6002fe (patch) | |
| tree | 056a4477fd870d454d5be5868cddab829a47f4d2 /lib/glthread/lock.c | |
| parent | 27dae84ed92f1ef0300263091972338d12e78348 (diff) | |
New upstream version 1.4.2upstream/1.4.2upstream
Diffstat (limited to 'lib/glthread/lock.c')
| -rw-r--r-- | lib/glthread/lock.c | 66 |
1 files changed, 17 insertions, 49 deletions
diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c index a2c53dc7..cfb9393c 100644 --- a/lib/glthread/lock.c +++ b/lib/glthread/lock.c @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2025 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 @@ -261,9 +261,7 @@ 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 @@ -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; |
