aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-03-23 19:57:40 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2022-04-06 14:31:55 +0200
commite9c4e0a8e54008bd83459777c8b8f5a38ff6fea2 (patch)
tree2bd025c0f97e1b7438eea309dc85449fa5fee88e
parent69242e7e7ea55f2a3f4fa50e367cad849c9cdc36 (diff)
Move fcntl_setfl() to oslib-posix
It is only implemented for POSIX anyway. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220323155743.1585078-30-marcandre.lureau@redhat.com> [Add braces around if statements. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--include/qemu/cutils.h1
-rw-r--r--include/sysemu/os-posix.h2
-rw-r--r--util/cutils.c17
-rw-r--r--util/oslib-posix.c15
4 files changed, 17 insertions, 18 deletions
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 2137e65260..e873bad366 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 58de7c994d..adbe19d3e4 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -96,6 +96,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 1173ce3b88..aaf2ced291 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 577c855612..a069dbff69 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;
+}