diff options
author | Simon McVittie <smcv@collabora.com> | 2017-07-24 12:30:57 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2018-02-07 07:34:35 +0000 |
commit | 3ccad29fba561b4321df7c9926cd4d7544dcaed0 (patch) | |
tree | 61109582209597f7d96f748ee6c3c3a8060ba203 | |
parent | 97d480c09c66ad7860f6c0e0a3d56fdf3a0d56a8 (diff) | |
download | dbus-3ccad29fba561b4321df7c9926cd4d7544dcaed0.tar.gz |
Add a simplified backport of g_steal_pointer()
This will be used in tests later in the branch.
Sadly we can't use GLIB_VERSION_2_44 unless we are willing to have a
hard dependency on GLib 2.44, which would force us to do all our
Travis-CI builds in Docker containers rather than in ye olde base
system, and that adds 50% to the time taken to do builds.
Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Rebase onto 1.13.x branch, fix minor conflicts]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354
(cherry picked from commit d5742550ca566317eaddea0ff7db04098f9f044f)
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | test/test-utils-glib.h | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 413f6580..b5731e82 100644 --- a/configure.ac +++ b/configure.ac @@ -262,7 +262,7 @@ dnl Don't do anything too subtle here, because the CMake build system dnl parses these lines with regular expressions. If necessary, adjust dnl cmake/modules/MacrosAutotools.cmake to compensate. AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_40], [Ignore post-2.40 deprecations]) -AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_40], [Prevent post-2.40 APIs]) +AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [G_ENCODE_VERSION(2,44)], [Prevent post-2.44 APIs]) with_glib=yes diff --git a/test/test-utils-glib.h b/test/test-utils-glib.h index 3952309c..b170e871 100644 --- a/test/test-utils-glib.h +++ b/test/test-utils-glib.h @@ -91,4 +91,19 @@ void test_mkdir (const gchar *path, gint mode); void test_timeout_reset (guint factor); +#if !GLIB_CHECK_VERSION(2, 44, 0) +#define g_steal_pointer(x) backported_g_steal_pointer (x) +/* A simplified version of g_steal_pointer without type-safety. */ +static inline gpointer +backported_g_steal_pointer (gpointer pointer_to_pointer) +{ + gpointer *pp = pointer_to_pointer; + gpointer ret; + + ret = *pp; + *pp = NULL; + return ret; +} +#endif + #endif |