qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 29/32] Move fcntl_setfl() to oslib-posix


From: marcandre . lureau
Subject: [PATCH 29/32] Move fcntl_setfl() to oslib-posix
Date: Wed, 23 Mar 2022 19:57:40 +0400

From: Marc-André Lureau <marcandre.lureau@redhat.com>

It is only implemented for POSIX anyway.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qemu/cutils.h     |  1 -
 include/sysemu/os-posix.h |  2 ++
 util/cutils.c             | 17 -----------------
 util/oslib-posix.c        | 15 +++++++++++++++
 4 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 2137e6526087..e873bad36674 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -131,7 +131,6 @@ const char *qemu_strchrnul(const char *s, int c);
 time_t mktimegm(struct tm *tm);
 int qemu_fdatasync(int fd);
 int qemu_msync(void *addr, size_t length, int fd);
-int fcntl_setfl(int fd, int flag);
 int qemu_parse_fd(const char *param);
 int qemu_strtoi(const char *nptr, const char **endptr, int base,
                 int *result);
diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index a49c6848ff1a..e9deb9b0c4b6 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -99,6 +99,8 @@ static inline void qemu_funlockfile(FILE *f)
     funlockfile(f);
 }
 
+int fcntl_setfl(int fd, int flag);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/util/cutils.c b/util/cutils.c
index 1173ce3b88f3..aaf2ced29142 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -199,23 +199,6 @@ int qemu_msync(void *addr, size_t length, int fd)
 #endif /* CONFIG_POSIX */
 }
 
-#ifndef _WIN32
-/* Sets a specific flag */
-int fcntl_setfl(int fd, int flag)
-{
-    int flags;
-
-    flags = fcntl(fd, F_GETFL);
-    if (flags == -1)
-        return -errno;
-
-    if (fcntl(fd, F_SETFL, flags | flag) == -1)
-        return -errno;
-
-    return 0;
-}
-#endif
-
 static int64_t suffix_mul(char suffix, int64_t unit)
 {
     switch (qemu_toupper(suffix)) {
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 577c855612cb..fae25be3e779 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -936,3 +936,18 @@ size_t qemu_get_host_physmem(void)
 #endif
     return 0;
 }
+
+/* Sets a specific flag */
+int fcntl_setfl(int fd, int flag)
+{
+    int flags;
+
+    flags = fcntl(fd, F_GETFL);
+    if (flags == -1)
+        return -errno;
+
+    if (fcntl(fd, F_SETFL, flags | flag) == -1)
+        return -errno;
+
+    return 0;
+}
-- 
2.35.1.273.ge6ebfd0e8cbb




reply via email to

[Prev in Thread] Current Thread [Next in Thread]