mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-12 02:10:19 +01:00
shared: also reimplement g_atomic_pointer_set() macro
It's not strictly necessary, because contrary to g_atomic_pointer_get() and g_atomic_pointer_compare_and_exchange(), glib's variant for the setter is mostly fine. Still, reimplement it, because we use typeof() eagerly and can thus add more static checks than glib. (cherry picked from commit7c60e984b6) (cherry picked from commit6ded463f36) (cherry picked from commit976b358be6) (cherry picked from commit296a770a85) (cherry picked from commit32c81a29d5)
This commit is contained in:
parent
9654d6fa61
commit
4862953355
1 changed files with 19 additions and 0 deletions
|
|
@ -601,6 +601,25 @@ _g_atomic_pointer_get (void **atomic)
|
|||
(typeof (*_atomic)) _g_atomic_pointer_get ((void **) _atomic); \
|
||||
})
|
||||
|
||||
/* Reimplement g_atomic_pointer_set() macro too. Our variant does more type
|
||||
* checks. */
|
||||
static inline void
|
||||
_g_atomic_pointer_set (void **atomic, void *newval)
|
||||
{
|
||||
return g_atomic_pointer_set (atomic, newval);
|
||||
}
|
||||
#undef g_atomic_pointer_set
|
||||
#define g_atomic_pointer_set(atomic, newval) \
|
||||
({ \
|
||||
typeof (*atomic) *const _atomic = (atomic); \
|
||||
typeof (*_atomic) const _newval = (newval); \
|
||||
_nm_unused gconstpointer const _val_type_check = _newval; \
|
||||
\
|
||||
(void) (0 ? (gpointer) * (_atomic) : NULL); \
|
||||
\
|
||||
_g_atomic_pointer_set ((void **) _atomic, (void *) _newval); \
|
||||
})
|
||||
|
||||
/* Glib implements g_atomic_pointer_compare_and_exchange() as a macro.
|
||||
* For one, to inline the atomic operation and also to perform some type checks
|
||||
* on the arguments.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue