2 * glibcompat.h - System-dependent definitions
4 * Copyright (C) 2012 Intel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
26 #include <glib-object.h>
28 #if !GLIB_CHECK_VERSION(2,27,2)
30 g_list_free_full(GList *list, GDestroyNotify free_func)
32 g_list_foreach(list, (GFunc)free_func, NULL);
37 #if !GLIB_CHECK_VERSION(2,28,0)
39 g_clear_object_inline(volatile GObject **object_ptr)
41 gpointer * const ptr = (gpointer)object_ptr;
45 old = g_atomic_pointer_get(ptr);
46 } while G_UNLIKELY(!g_atomic_pointer_compare_and_exchange(ptr, old, NULL));
52 #define g_clear_object(obj) g_clear_object_inline((volatile GObject **)(obj))
55 #if GLIB_CHECK_VERSION(2,31,2)
56 #define GStaticMutex GMutex
57 #undef g_static_mutex_init
58 #define g_static_mutex_init(mutex) g_mutex_init(mutex)
59 #undef g_static_mutex_free
60 #define g_static_mutex_free(mutex) g_mutex_clear(mutex)
61 #undef g_static_mutex_lock
62 #define g_static_mutex_lock(mutex) g_mutex_lock(mutex)
63 #undef g_static_mutex_unlock
64 #define g_static_mutex_unlock(mutex) g_mutex_unlock(mutex)
66 #define GStaticRecMutex GRecMutex
67 #undef g_static_rec_mutex_init
68 #define g_static_rec_mutex_init(mutex) g_rec_mutex_init(mutex)
69 #undef g_static_rec_mutex_free
70 #define g_static_rec_mutex_free(mutex) g_rec_mutex_clear(mutex)
71 #undef g_static_rec_mutex_lock
72 #define g_static_rec_mutex_lock(mutex) g_rec_mutex_lock(mutex)
73 #undef g_static_rec_mutex_unlock
74 #define g_static_rec_mutex_unlock(m) g_rec_mutex_unlock(m)
77 #endif /* GLIB_COMPAT_H */