mirror of
https://git.code.sf.net/p/mingw-w64/mingw-w64
synced 2024-11-23 18:04:18 +08:00
winpthreads: Inline INIT_RWLOCK into its only callsite
Prevents a warning of `r` being shadowed, and makes the code clearer. Signed-off-by: Antonin Décimo <antonin@tarides.com> Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
d64ea219aa
commit
91d37a4ab7
@ -47,7 +47,11 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_unref(volatile pthread_rwlock_t
|
|||||||
static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_ref(pthread_rwlock_t *rwl, int f )
|
static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_ref(pthread_rwlock_t *rwl, int f )
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
INIT_RWLOCK(rwl);
|
if (STATIC_RWL_INITIALIZER(*rwl)) {
|
||||||
|
r = rwlock_static_init(rwl);
|
||||||
|
if (r != 0 && r != EBUSY)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
pthread_spin_lock(&rwl_global);
|
pthread_spin_lock(&rwl_global);
|
||||||
|
|
||||||
if (!rwl || !*rwl || ((rwlock_t *)*rwl)->valid != LIFE_RWLOCK) r = EINVAL;
|
if (!rwl || !*rwl || ((rwlock_t *)*rwl)->valid != LIFE_RWLOCK) r = EINVAL;
|
||||||
|
@ -26,9 +26,6 @@
|
|||||||
#define LIFE_RWLOCK 0xBAB1F0ED
|
#define LIFE_RWLOCK 0xBAB1F0ED
|
||||||
#define DEAD_RWLOCK 0xDEADB0EF
|
#define DEAD_RWLOCK 0xDEADB0EF
|
||||||
|
|
||||||
#define INIT_RWLOCK(rwl) { int r; \
|
|
||||||
if (STATIC_RWL_INITIALIZER(*rwl)) { if ((r = rwlock_static_init(rwl))) { if (r != EBUSY) return r; }}}
|
|
||||||
|
|
||||||
#define STATIC_RWL_INITIALIZER(x) ((pthread_rwlock_t)(x) == ((pthread_rwlock_t)PTHREAD_RWLOCK_INITIALIZER))
|
#define STATIC_RWL_INITIALIZER(x) ((pthread_rwlock_t)(x) == ((pthread_rwlock_t)PTHREAD_RWLOCK_INITIALIZER))
|
||||||
|
|
||||||
typedef struct rwlock_t rwlock_t;
|
typedef struct rwlock_t rwlock_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user