diff options
Diffstat (limited to 'shared/nm-glib-aux/nm-glib.h')
| -rw-r--r-- | shared/nm-glib-aux/nm-glib.h | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/shared/nm-glib-aux/nm-glib.h b/shared/nm-glib-aux/nm-glib.h index 26d0eacd..4ecba9ff 100644 --- a/shared/nm-glib-aux/nm-glib.h +++ b/shared/nm-glib-aux/nm-glib.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +// SPDX-License-Identifier: LGPL-2.1+ /* * Copyright (C) 2008 - 2018 Red Hat, Inc. */ @@ -193,22 +193,6 @@ __g_test_add_data_func_full (const char *testpath, /*****************************************************************************/ -#if !GLIB_CHECK_VERSION (2, 34, 0) -#define G_DEFINE_QUARK(QN, q_n) \ -GQuark \ -q_n##_quark (void) \ -{ \ - static GQuark q; \ - \ - if G_UNLIKELY (q == 0) \ - q = g_quark_from_static_string (#QN); \ - \ - return q; \ -} -#endif - -/*****************************************************************************/ - static inline gboolean nm_g_hash_table_replace (GHashTable *hash, gpointer key, gpointer value) { @@ -601,4 +585,41 @@ _g_atomic_pointer_compare_and_exchange (volatile void *atomic, /*****************************************************************************/ +#if !GLIB_CHECK_VERSION (2, 58, 0) +static inline gboolean +g_hash_table_steal_extended (GHashTable *hash_table, + gconstpointer lookup_key, + gpointer *stolen_key, + gpointer *stolen_value) +{ + g_assert (stolen_key); + g_assert (stolen_value); + + if (g_hash_table_lookup_extended (hash_table, lookup_key, stolen_key, stolen_value)) { + g_hash_table_steal (hash_table, lookup_key); + return TRUE; + } + *stolen_key = NULL; + *stolen_value = NULL; + return FALSE; +} +#else +#define g_hash_table_steal_extended(hash_table, lookup_key, stolen_key, stolen_value) \ + ({ \ + gpointer *_stolen_key = (stolen_key); \ + gpointer *_stolen_value = (stolen_value); \ + \ + /* we cannot allow NULL arguments, because then we would leak the values in + * the compat implementation. */ \ + g_assert (_stolen_key); \ + g_assert (_stolen_value); \ + \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_hash_table_steal_extended (hash_table, lookup_key, _stolen_key, _stolen_value); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) +#endif + +/*****************************************************************************/ + #endif /* __NM_GLIB_H__ */ |