[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 34/53] Move fcntl_setfl() to oslib-posix
From: |
Paolo Bonzini |
Subject: |
[PULL 34/53] Move fcntl_setfl() to oslib-posix |
Date: |
Tue, 19 Apr 2022 07:50:50 +0200 |
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>
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>
---
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 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;
+}
--
2.35.1
- [PULL 04/53] Replace qemu_gettimeofday() with g_get_real_time(), (continued)
- [PULL 04/53] Replace qemu_gettimeofday() with g_get_real_time(), Paolo Bonzini, 2022/04/19
- [PULL 13/53] osdep: poison {HOST,TARGET}_WORDS_BIGENDIAN, Paolo Bonzini, 2022/04/19
- [PULL 09/53] meson: remove test-qdev-global-props dependency on testqapi, Paolo Bonzini, 2022/04/19
- [PULL 10/53] char: move qemu_openpty_raw from util/ to char/, Paolo Bonzini, 2022/04/19
- [PULL 17/53] qga: replace deprecated g_get_current_time(), Paolo Bonzini, 2022/04/19
- [PULL 12/53] Replace TARGET_WORDS_BIGENDIAN, Paolo Bonzini, 2022/04/19
- [PULL 02/53] qtest: replace gettimeofday with GTimer, Paolo Bonzini, 2022/04/19
- [PULL 15/53] tests: replace free_all() usage with g_auto, Paolo Bonzini, 2022/04/19
- [PULL 31/53] include: move os_*() to os-foo.h, Paolo Bonzini, 2022/04/19
- [PULL 33/53] Move CPU softfloat unions to cpu-float.h, Paolo Bonzini, 2022/04/19
- [PULL 34/53] Move fcntl_setfl() to oslib-posix,
Paolo Bonzini <=
- [PULL 35/53] qga: remove explicit environ argument from exec/spawn, Paolo Bonzini, 2022/04/19
- [PULL 28/53] include: move target page bits declaration to page-vary.h, Paolo Bonzini, 2022/04/19
- [PULL 29/53] include: move progress API to qemu-progress.h, Paolo Bonzini, 2022/04/19
- [PULL 45/53] hyperv: Add definitions for syndbg, Paolo Bonzini, 2022/04/19
- [PULL 46/53] hyperv: Add support to process syndbg commands, Paolo Bonzini, 2022/04/19
- [PULL 36/53] Remove qemu-common.h include from most units, Paolo Bonzini, 2022/04/19
- [PULL 48/53] s390x: follow qdev tree to detect SCSI device on a CCW bus, Paolo Bonzini, 2022/04/19
- [PULL 22/53] include: move qemu_write_full() declaration to osdep.h, Paolo Bonzini, 2022/04/19
- [PULL 18/53] error-report: replace deprecated g_get_current_time() with glib >= 2.62, Paolo Bonzini, 2022/04/19
- [PULL 43/53] thread-posix: optimize qemu_sem_timedwait with zero timeout, Paolo Bonzini, 2022/04/19