mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 07:10:33 +01:00
core: fix build with glib < 2.34
Using g_clear_pointer() didn't trigger G_UNAVAILABLE warnings because it's a macro. Fix the build on older glibs by just pulling in the definition.
This commit is contained in:
parent
8b3d609404
commit
e58d86450d
2 changed files with 20 additions and 0 deletions
|
|
@ -36,6 +36,25 @@ g_type_ensure (GType type)
|
|||
if (G_UNLIKELY (type == (GType)-1))
|
||||
g_error ("can't happen");
|
||||
}
|
||||
|
||||
#define g_clear_pointer(pp, destroy) \
|
||||
G_STMT_START { \
|
||||
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
|
||||
/* Only one access, please */ \
|
||||
gpointer *_pp = (gpointer *) (pp); \
|
||||
gpointer _p; \
|
||||
/* This assignment is needed to avoid a gcc warning */ \
|
||||
GDestroyNotify _destroy = (GDestroyNotify) (destroy); \
|
||||
\
|
||||
(void) (0 ? (gpointer) *(pp) : 0); \
|
||||
do \
|
||||
_p = g_atomic_pointer_get (_pp); \
|
||||
while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_pp, _p, NULL)); \
|
||||
\
|
||||
if (_p) \
|
||||
_destroy (_p); \
|
||||
} G_STMT_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* NM_GLIB_COMPAT_H */
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "nm-config.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue