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 <[email protected]>
This commit is contained in:
Niels Sascha Reedijk
2023-06-28 07:11:17 +00:00
committed by Adrien Destugues
parent 5cd344f75a
commit 03c3e2083e
3 changed files with 19 additions and 19 deletions
@@ -17,12 +17,12 @@ struct mtx {
struct { struct {
mutex lock; mutex lock;
thread_id owner; thread_id owner;
} mutex; } mutex_;
recursive_lock recursive; recursive_lock recursive;
struct { struct {
spinlock lock; spinlock lock;
cpu_status state; cpu_status state;
} spinlock; } spinlock_;
} u; } u;
}; };
@@ -50,8 +50,8 @@ static inline void
mtx_lock(struct mtx* mutex) mtx_lock(struct mtx* mutex)
{ {
if (mutex->type == MTX_DEF) { if (mutex->type == MTX_DEF) {
mutex_lock(&mutex->u.mutex.lock); mutex_lock(&mutex->u.mutex_.lock);
mutex->u.mutex.owner = find_thread(NULL); mutex->u.mutex_.owner = find_thread(NULL);
} else if (mutex->type == MTX_RECURSE) { } else if (mutex->type == MTX_RECURSE) {
recursive_lock_lock(&mutex->u.recursive); recursive_lock_lock(&mutex->u.recursive);
} else if (mutex->type == MTX_SPIN) { } else if (mutex->type == MTX_SPIN) {
@@ -64,9 +64,9 @@ static inline int
mtx_trylock(struct mtx* mutex) mtx_trylock(struct mtx* mutex)
{ {
if (mutex->type == MTX_DEF) { 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; return 0;
mutex->u.mutex.owner = find_thread(NULL); mutex->u.mutex_.owner = find_thread(NULL);
return 1; return 1;
} else if (mutex->type == MTX_RECURSE) { } else if (mutex->type == MTX_RECURSE) {
if (recursive_lock_trylock(&mutex->u.recursive) != B_OK) if (recursive_lock_trylock(&mutex->u.recursive) != B_OK)
@@ -83,8 +83,8 @@ static inline void
mtx_unlock(struct mtx* mutex) mtx_unlock(struct mtx* mutex)
{ {
if (mutex->type == MTX_DEF) { if (mutex->type == MTX_DEF) {
mutex->u.mutex.owner = -1; mutex->u.mutex_.owner = -1;
mutex_unlock(&mutex->u.mutex.lock); mutex_unlock(&mutex->u.mutex_.lock);
} else if (mutex->type == MTX_RECURSE) { } else if (mutex->type == MTX_RECURSE) {
recursive_lock_unlock(&mutex->u.recursive); recursive_lock_unlock(&mutex->u.recursive);
} else if (mutex->type == MTX_SPIN) { } else if (mutex->type == MTX_SPIN) {
@@ -105,7 +105,7 @@ static inline int
mtx_owned(struct mtx* mutex) mtx_owned(struct mtx* mutex)
{ {
if (mutex->type == MTX_DEF) 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 (mutex->type == MTX_RECURSE) {
#if KDEBUG #if KDEBUG
return mutex->u.recursive.lock.holder == find_thread(NULL); return mutex->u.recursive.lock.holder == find_thread(NULL);
@@ -114,7 +114,7 @@ mtx_owned(struct mtx* mutex)
#endif #endif
} }
if (mutex->type == MTX_SPIN) if (mutex->type == MTX_SPIN)
return mutex->u.spinlock.lock.lock != 0; return mutex->u.spinlock_.lock.lock != 0;
return 0; return 0;
} }
+9 -9
View File
@@ -24,11 +24,11 @@ mtx_init(struct mtx *mutex, const char *name, const char *type,
MUTEX_FLAG_CLONE_NAME); MUTEX_FLAG_CLONE_NAME);
mutex->type = MTX_RECURSE; mutex->type = MTX_RECURSE;
} else if ((options & MTX_SPIN) != 0) { } else if ((options & MTX_SPIN) != 0) {
B_INITIALIZE_SPINLOCK(&mutex->u.spinlock.lock); B_INITIALIZE_SPINLOCK(&mutex->u.spinlock_.lock);
mutex->type = MTX_SPIN; mutex->type = MTX_SPIN;
} else { } else {
mutex_init_etc(&mutex->u.mutex.lock, name, MUTEX_FLAG_CLONE_NAME); mutex_init_etc(&mutex->u.mutex_.lock, name, MUTEX_FLAG_CLONE_NAME);
mutex->u.mutex.owner = -1; mutex->u.mutex_.owner = -1;
mutex->type = MTX_DEF; mutex->type = MTX_DEF;
} }
} }
@@ -50,9 +50,9 @@ mtx_destroy(struct mtx *mutex)
if ((mutex->type & MTX_RECURSE) != 0) { if ((mutex->type & MTX_RECURSE) != 0) {
recursive_lock_destroy(&mutex->u.recursive); recursive_lock_destroy(&mutex->u.recursive);
} else if ((mutex->type & MTX_SPIN) != 0) { } 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 { } 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")); KASSERT(mutex->type == MTX_SPIN, ("not a spin mutex"));
cpu_status status = disable_interrupts(); cpu_status status = disable_interrupts();
acquire_spinlock(&mutex->u.spinlock.lock); acquire_spinlock(&mutex->u.spinlock_.lock);
mutex->u.spinlock.state = status; mutex->u.spinlock_.state = status;
} }
@@ -73,8 +73,8 @@ mtx_unlock_spin(struct mtx* mutex)
{ {
KASSERT(mutex->type == MTX_SPIN, ("not a spin mutex")); KASSERT(mutex->type == MTX_SPIN, ("not a spin mutex"));
cpu_status status = mutex->u.spinlock.state; cpu_status status = mutex->u.spinlock_.state;
release_spinlock(&mutex->u.spinlock.lock); release_spinlock(&mutex->u.spinlock_.lock);
restore_interrupts(status); restore_interrupts(status);
} }