On 8/5/24 09:44, Stefano Garzarella wrote:
Let's make the code more portable by adding defines from
block/file-posix.c to support O_DIRECT in other systems (e.g. macOS).
vhost-user-server.c is a dependency, let's enable it for any POSIX
system.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
v4:
- moved using of "qemu/bswap.h" API in a separate patch [Phil]
---
meson.build | 2 --
contrib/vhost-user-blk/vhost-user-blk.c | 14 ++++++++++++++
util/meson.build | 4 +++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/contrib/vhost-user-blk/vhost-user-blk.c
b/contrib/vhost-user-blk/vhost-user-blk.c
index 9492146855..a450337685 100644
--- a/contrib/vhost-user-blk/vhost-user-blk.c
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
@@ -25,6 +25,20 @@
#include <sys/ioctl.h>
#endif
+/* OS X does not have O_DSYNC */
+#ifndef O_DSYNC
+#ifdef O_SYNC
+#define O_DSYNC O_SYNC
+#elif defined(O_FSYNC)
+#define O_DSYNC O_FSYNC
+#endif
+#endif
+
+/* Approximate O_DIRECT with O_DSYNC if O_DIRECT isn't available */
+#ifndef O_DIRECT
+#define O_DIRECT O_DSYNC
+#endif
Could we add that in "qemu/osdep.h" instead?