TT#14008 use temporary variable to avoid stray compiler warning

The glib macro for g_atomic_pointer_get() uses typeof() with an
intermediate variable, resulting in a stray compiler warning if the
argument uses `const` as the intermediate variable also ends up being
const. Use an extra non-const intermediate variable to work around this.

closes #1270

Change-Id: I3bf1404240d3b8571aaf40c38b524f578e0fdbd9
rfuchs/1283
Richard Fuchs 4 years ago
parent 586a8028eb
commit 1755ccfef4

@ -364,14 +364,16 @@ INLINE int bit_array_clear(volatile unsigned int *name, unsigned int bit) {
#if GLIB_SIZEOF_VOID_P >= 8
typedef struct {
volatile void *p;
void *p;
} atomic64;
INLINE uint64_t atomic64_get(const atomic64 *u) {
return (uint64_t) g_atomic_pointer_get(&u->p);
void **p = (void *) &u->p;
return (uint64_t) g_atomic_pointer_get(p);
}
INLINE uint64_t atomic64_get_na(const atomic64 *u) {
return (uint64_t) u->p;
void **p = (void *) &u->p;
return (uint64_t) *p;
}
INLINE void atomic64_set(atomic64 *u, uint64_t a) {
g_atomic_pointer_set(&u->p, (void *) a);
@ -389,7 +391,7 @@ INLINE uint64_t atomic64_get_set(atomic64 *u, uint64_t a) {
uint64_t old;
do {
old = atomic64_get(u);
if (g_atomic_pointer_compare_and_exchange(&u->p, (volatile void *) old, (void *) a))
if (g_atomic_pointer_compare_and_exchange(&u->p, (void *) old, (void *) a))
return old;
} while (1);
}

Loading…
Cancel
Save