summaryrefslogtreecommitdiff
path: root/glnx-backports.h
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-11-08 11:05:12 +0000
committerSimon McVittie <smcv@collabora.com>2022-11-08 11:17:41 +0000
commitea18312ed03e0077740e327966a8e0e5810d7f5b (patch)
tree25f3c4e0e0dd4244b87ddcff3715e465287f5a79 /glnx-backports.h
parent4e44fd9c174e4196a86fb6d954722feaff612c88 (diff)
downloadlibglnx-ea18312ed03e0077740e327966a8e0e5810d7f5b.tar.gz
backports: Add g_steal_fd, from GLib >= 2.70
This is essentially the same as glnx_steal_fd, so make glnx_steal_fd an alias for it. The unit test is taken from GLib, slightly modified to avoid g_close() and also test the old name glnx_steal_fd(). Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'glnx-backports.h')
-rw-r--r--glnx-backports.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/glnx-backports.h b/glnx-backports.h
index f99f08f..ad70ed9 100644
--- a/glnx-backports.h
+++ b/glnx-backports.h
@@ -118,6 +118,17 @@ _glnx_memdup2 (gconstpointer mem,
(((a) > (b) ? (a) - (b) : (b) - (a)) < (epsilon))
#endif
+#if !GLIB_CHECK_VERSION(2, 70, 0)
+#define g_steal_fd _glnx_steal_fd
+static inline int
+_glnx_steal_fd (int *fdp)
+{
+ int fd = *fdp;
+ *fdp = -1;
+ return fd;
+}
+#endif
+
#if !GLIB_CHECK_VERSION(2, 74, 0)
#define G_APPLICATION_DEFAULT_FLAGS ((GApplicationFlags) 0)
#define G_CONNECT_DEFAULT ((GConnectFlags) 0)