freebsd_compat: fix GCC warning

The C++ standard in rule 3.3.7[basic.scope.class] determines how the compiler
should handle cases where a member shares the name of a type. It is up to the
compiler whether this requires a diagnostic warning. GCC 13 emits a warning
(changes-meaning). This fixes the issuing of this warning.

Change-Id: I9c58c0dd6298055959154f78d47ad9088e8225dc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6651
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Niels Sascha Reedijk 2023-06-24 21:28:59 +01:00 committed by Adrien Destugues
parent 5cd344f75a
commit 03c3e2083e
3 changed files with 19 additions and 19 deletions

View File

@ -17,12 +17,12 @@ struct mtx {
struct {
mutex lock;
thread_id owner;
} mutex;
} mutex_;
recursive_lock recursive;
struct {
spinlock lock;
cpu_status state;
} spinlock;
} spinlock_;
} u;
};

View File

@ -50,8 +50,8 @@ static inline void
mtx_lock(struct mtx* mutex)
{
if (mutex->type == MTX_DEF) {
mutex_lock(&mutex->u.mutex.lock);
mutex->u.mutex.owner = find_thread(NULL);
mutex_lock(&mutex->u.mutex_.lock);
mutex->u.mutex_.owner = find_thread(NULL);
} else if (mutex->type == MTX_RECURSE) {
recursive_lock_lock(&mutex->u.recursive);
} else if (mutex->type == MTX_SPIN) {
@ -64,9 +64,9 @@ static inline int
mtx_trylock(struct mtx* mutex)
{
if (mutex->type == MTX_DEF) {
if (mutex_trylock(&mutex->u.mutex.lock) != B_OK)
if (mutex_trylock(&mutex->u.mutex_.lock) != B_OK)
return 0;
mutex->u.mutex.owner = find_thread(NULL);
mutex->u.mutex_.owner = find_thread(NULL);
return 1;
} else if (mutex->type == MTX_RECURSE) {
if (recursive_lock_trylock(&mutex->u.recursive) != B_OK)
@ -83,8 +83,8 @@ static inline void
mtx_unlock(struct mtx* mutex)
{
if (mutex->type == MTX_DEF) {
mutex->u.mutex.owner = -1;
mutex_unlock(&mutex->u.mutex.lock);
mutex->u.mutex_.owner = -1;
mutex_unlock(&mutex->u.mutex_.lock);
} else if (mutex->type == MTX_RECURSE) {
recursive_lock_unlock(&mutex->u.recursive);
} else if (mutex->type == MTX_SPIN) {
@ -105,7 +105,7 @@ static inline int
mtx_owned(struct mtx* mutex)
{
if (mutex->type == MTX_DEF)
return mutex->u.mutex.owner == find_thread(NULL);
return mutex->u.mutex_.owner == find_thread(NULL);
if (mutex->type == MTX_RECURSE) {
#if KDEBUG
return mutex->u.recursive.lock.holder == find_thread(NULL);
@ -114,7 +114,7 @@ mtx_owned(struct mtx* mutex)
#endif
}
if (mutex->type == MTX_SPIN)
return mutex->u.spinlock.lock.lock != 0;
return mutex->u.spinlock_.lock.lock != 0;
return 0;
}

View File

@ -24,11 +24,11 @@ mtx_init(struct mtx *mutex, const char *name, const char *type,
MUTEX_FLAG_CLONE_NAME);
mutex->type = MTX_RECURSE;
} else if ((options & MTX_SPIN) != 0) {
B_INITIALIZE_SPINLOCK(&mutex->u.spinlock.lock);
B_INITIALIZE_SPINLOCK(&mutex->u.spinlock_.lock);
mutex->type = MTX_SPIN;
} else {
mutex_init_etc(&mutex->u.mutex.lock, name, MUTEX_FLAG_CLONE_NAME);
mutex->u.mutex.owner = -1;
mutex_init_etc(&mutex->u.mutex_.lock, name, MUTEX_FLAG_CLONE_NAME);
mutex->u.mutex_.owner = -1;
mutex->type = MTX_DEF;
}
}
@ -50,9 +50,9 @@ mtx_destroy(struct mtx *mutex)
if ((mutex->type & MTX_RECURSE) != 0) {
recursive_lock_destroy(&mutex->u.recursive);
} else if ((mutex->type & MTX_SPIN) != 0) {
KASSERT(!B_SPINLOCK_IS_LOCKED(&mutex->u.spinlock.lock), ("spin mutex is locked"));
KASSERT(!B_SPINLOCK_IS_LOCKED(&mutex->u.spinlock_.lock), ("spin mutex is locked"));
} else {
mutex_destroy(&mutex->u.mutex.lock);
mutex_destroy(&mutex->u.mutex_.lock);
}
}
@ -63,8 +63,8 @@ mtx_lock_spin(struct mtx* mutex)
KASSERT(mutex->type == MTX_SPIN, ("not a spin mutex"));
cpu_status status = disable_interrupts();
acquire_spinlock(&mutex->u.spinlock.lock);
mutex->u.spinlock.state = status;
acquire_spinlock(&mutex->u.spinlock_.lock);
mutex->u.spinlock_.state = status;
}
@ -73,8 +73,8 @@ mtx_unlock_spin(struct mtx* mutex)
{
KASSERT(mutex->type == MTX_SPIN, ("not a spin mutex"));
cpu_status status = mutex->u.spinlock.state;
release_spinlock(&mutex->u.spinlock.lock);
cpu_status status = mutex->u.spinlock_.state;
release_spinlock(&mutex->u.spinlock_.lock);
restore_interrupts(status);
}