On Fri, 12 Aug 2022 at 12:44, <tugy@chinatelecom.cn> wrote:
From: Guoyi Tu <tugy@chinatelecom.cn>
qemu_socketpair() will create a pair of connected sockets
with FD_CLOEXEC set
Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
---
include/qemu/sockets.h | 3 +++
util/osdep.c | 24 ++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 038faa157f..52cf2855df 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -14,6 +14,9 @@ int inet_aton(const char *cp, struct in_addr *ia);
/* misc helpers */
bool fd_is_socket(int fd);
int qemu_socket(int domain, int type, int protocol);
+#ifndef WIN32
+int qemu_socketpair(int domain, int type, int protocol, int sv[2]);
Any new function declaration in a header file needs a
doc-comment documenting what it does, please.
+#endif
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int socket_set_cork(int fd, int v);
int socket_set_nodelay(int fd);
diff --git a/util/osdep.c b/util/osdep.c
index 60fcbbaebe..4b1ab623c7 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -481,6 +481,30 @@ int qemu_socket(int domain, int type, int protocol)
return ret;
}
+#ifndef _WIN32
If this function only exists and is usable on posix
hosts, put it in util/oslib-posix.c rather than having
it here with a win32 ifdef.