1 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 This library is free software; you can redistribute it and/or 4 modify it under the terms of the GNU Lesser General Public 5 License as published by the Free Software Foundation; either 6 version 2.1 of the License, or (at your option) any later version. 7 8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public 14 License along with this library; if not, see <http://www.gnu.org/licenses/>. 15 */ 16 #ifndef GLIB_COMPAT_H 17 #define GLIB_COMPAT_H 18 19 #include <glib-object.h> 20 #include <gio/gio.h> 21 22 #if !GLIB_CHECK_VERSION(2,28,0) 23 #define g_clear_object(object_ptr) \ 24 G_STMT_START { \ 25 /* Only one access, please */ \ 26 gpointer *_p = (gpointer) (object_ptr); \ 27 gpointer _o; \ 28 \ 29 do \ 30 _o = g_atomic_pointer_get (_p); \ 31 while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_p, _o, NULL));\ 32 \ 33 if (_o) \ 34 g_object_unref (_o); \ 35 } G_STMT_END 36 37 GSimpleAsyncResult * 38 g_simple_async_result_new_take_error (GObject *source_object, 39 GAsyncReadyCallback callback, 40 gpointer user_data, 41 GError *error); 42 void 43 g_simple_async_result_take_error(GSimpleAsyncResult *simple, 44 GError *error); 45 void 46 g_simple_async_report_take_gerror_in_idle (GObject *object, 47 GAsyncReadyCallback callback, 48 gpointer user_data, 49 GError *error); 50 51 #endif /* glib 2.28 */ 52 53 #endif /* GLIB_COMPAT_H */ 54