Browse Source

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 5 years ago
parent
commit
1755ccfef4
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      include/aux.h

+ 6
- 4
include/aux.h View File

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


Loading…
Cancel
Save