[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULLv2 24/32] slirp: Move g_spawn_async_with_fds_qemu comp
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULLv2 24/32] slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/ |
Date: |
Tue, 5 Feb 2019 18:59:19 +0200 |
Only slirp actually needs it, and will need it along in libslirp.
Signed-off-by: Samuel Thibault <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
include/glib-compat.h | 57 ---------------------------------------
slirp/misc.c | 62 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 57 deletions(-)
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 8a078c5288..1291628e09 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -83,63 +83,6 @@ static inline gboolean g_strv_contains_qemu(const gchar
*const *strv,
}
#define g_strv_contains(a, b) g_strv_contains_qemu(a, b)
-#if !GLIB_CHECK_VERSION(2, 58, 0)
-typedef struct QemuGSpawnFds {
- GSpawnChildSetupFunc child_setup;
- gpointer user_data;
- gint stdin_fd;
- gint stdout_fd;
- gint stderr_fd;
-} QemuGSpawnFds;
-
-static inline void
-qemu_gspawn_fds_setup(gpointer user_data)
-{
- QemuGSpawnFds *q = (QemuGSpawnFds *)user_data;
-
- dup2(q->stdin_fd, 0);
- dup2(q->stdout_fd, 1);
- dup2(q->stderr_fd, 2);
- q->child_setup(q->user_data);
-}
-#endif
-
-static inline gboolean
-g_spawn_async_with_fds_qemu(const gchar *working_directory,
- gchar **argv,
- gchar **envp,
- GSpawnFlags flags,
- GSpawnChildSetupFunc child_setup,
- gpointer user_data,
- GPid *child_pid,
- gint stdin_fd,
- gint stdout_fd,
- gint stderr_fd,
- GError **error)
-{
-#if GLIB_CHECK_VERSION(2, 58, 0)
- return g_spawn_async_with_fds(working_directory, argv, envp, flags,
- child_setup, user_data,
- child_pid, stdin_fd, stdout_fd, stderr_fd,
- error);
-#else
- QemuGSpawnFds setup = {
- .child_setup = child_setup,
- .user_data = user_data,
- .stdin_fd = stdin_fd,
- .stdout_fd = stdout_fd,
- .stderr_fd = stderr_fd,
- };
-
- return g_spawn_async(working_directory, argv, envp, flags,
- qemu_gspawn_fds_setup, &setup,
- child_pid, error);
-#endif
-}
-
-#define g_spawn_async_with_fds(wd, argv, env, f, c, d, p, ifd, ofd, efd, err) \
- g_spawn_async_with_fds_qemu(wd, argv, env, f, c, d, p, ifd, ofd, efd, err)
-
#if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0)
/*
* g_poll has a problem on Windows when using
diff --git a/slirp/misc.c b/slirp/misc.c
index a77cc34b30..c2cb536d25 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -122,6 +122,68 @@ fork_exec_child_setup(gpointer data)
#endif
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+#if !GLIB_CHECK_VERSION(2, 58, 0)
+typedef struct SlirpGSpawnFds {
+ GSpawnChildSetupFunc child_setup;
+ gpointer user_data;
+ gint stdin_fd;
+ gint stdout_fd;
+ gint stderr_fd;
+} SlirpGSpawnFds;
+
+static inline void
+slirp_gspawn_fds_setup(gpointer user_data)
+{
+ SlirpGSpawnFds *q = (SlirpGSpawnFds *)user_data;
+
+ dup2(q->stdin_fd, 0);
+ dup2(q->stdout_fd, 1);
+ dup2(q->stderr_fd, 2);
+ q->child_setup(q->user_data);
+}
+#endif
+
+static inline gboolean
+g_spawn_async_with_fds_slirp(const gchar *working_directory,
+ gchar **argv,
+ gchar **envp,
+ GSpawnFlags flags,
+ GSpawnChildSetupFunc child_setup,
+ gpointer user_data,
+ GPid *child_pid,
+ gint stdin_fd,
+ gint stdout_fd,
+ gint stderr_fd,
+ GError **error)
+{
+#if GLIB_CHECK_VERSION(2, 58, 0)
+ return g_spawn_async_with_fds(working_directory, argv, envp, flags,
+ child_setup, user_data,
+ child_pid, stdin_fd, stdout_fd, stderr_fd,
+ error);
+#else
+ QemuGSpawnFds setup = {
+ .child_setup = child_setup,
+ .user_data = user_data,
+ .stdin_fd = stdin_fd,
+ .stdout_fd = stdout_fd,
+ .stderr_fd = stderr_fd,
+ };
+
+ return g_spawn_async(working_directory, argv, envp, flags,
+ slirp_gspawn_fds_setup, &setup,
+ child_pid, error);
+#endif
+}
+
+#define g_spawn_async_with_fds(wd, argv, env, f, c, d, p, ifd, ofd, efd, err) \
+ g_spawn_async_with_fds_slirp(wd, argv, env, f, c, d, p, ifd, ofd, efd, err)
+
+#pragma GCC diagnostic pop
+
int
fork_exec(struct socket *so, const char *ex)
{
--
2.20.1
- [Qemu-devel] [PULLv2 09/32] slirp: replace trace functions with DEBUG calls, (continued)
- [Qemu-devel] [PULLv2 09/32] slirp: replace trace functions with DEBUG calls, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 10/32] slirp: replace QEMU_PACKED with SLIRP_PACKED, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 21/32] slirp: replace net/eth.h inclusion with own defines, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 08/32] slirp: add callbacks for timer, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 14/32] slirp: replace qemu_notify_event() with a callback, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 19/32] slirp: remove qemu timer.h dependency, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 18/32] slirp: add slirp own version of pstrcpy, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 04/32] slirp: generalize guestfwd with a callback based approach, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 11/32] slirp: replace most qemu socket utilities with slirp own version, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 15/32] slirp: move QEMU state saving to a separate unit, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 24/32] slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/,
Samuel Thibault <=
- [Qemu-devel] [PULLv2 23/32] slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 27/32] slirp: improve send_packet() callback, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 29/32] slirp: remove slirp_instances list, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 22/32] slirp: replace qemu qtailq with slirp own copy, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 20/32] slirp: remove now useless QEMU headers inclusions, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 26/32] slirp: prefer c99 types over BSD kind, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 32/32] slirp: API is extern C, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 28/32] slirp: replace global polling with per-instance & notifier, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 25/32] slirp: replace remaining qemu headers dependency, Samuel Thibault, 2019/02/05
- [Qemu-devel] [PULLv2 30/32] slirp: use polling callbacks, drop glib requirement, Samuel Thibault, 2019/02/05