qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH 12/19] block: Update block to compile with Emscripten


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 12/19] block: Update block to compile with Emscripten
Date: Wed, 16 Apr 2025 11:00:54 +0200
User-agent: Mozilla Thunderbird

On 16/4/25 10:14, Kohei Tokunaga wrote:
emscripten exposes copy_file_range declaration but doesn't provide the
implementation in the final link. Define the emscripten-specific stub
function to avoid type conflict with the emscripten's header.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
---
  block/file-posix.c |  6 ++++++
  stubs/emscripten.c | 13 +++++++++++++
  2 files changed, 19 insertions(+)
  create mode 100644 stubs/emscripten.c

diff --git a/block/file-posix.c b/block/file-posix.c
index 56d1972d15..22e0ed5069 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -110,6 +110,10 @@
  #include <sys/diskslice.h>
  #endif
+#ifdef EMSCRIPTEN
+#include <sys/ioctl.h>
+#endif
+
  /* OS X does not have O_DSYNC */
  #ifndef O_DSYNC
  #ifdef O_SYNC
@@ -2010,6 +2014,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
      return handle_aiocb_write_zeroes(aiocb);
  }
+#ifndef EMSCRIPTEN
  #ifndef HAVE_COPY_FILE_RANGE
  static off_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
                               off_t *out_off, size_t len, unsigned int flags)
@@ -2023,6 +2028,7 @@ static off_t copy_file_range(int in_fd, off_t *in_off, 
int out_fd,
  #endif
  }
  #endif
+#endif
/*
   * parse_zone - Fill a zone descriptor
diff --git a/stubs/emscripten.c b/stubs/emscripten.c
new file mode 100644
index 0000000000..2157d6349b
--- /dev/null
+++ b/stubs/emscripten.c
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include "qemu/osdep.h"
+/*
+ * emscripten exposes copy_file_range declaration but doesn't provide the
+ * implementation in the final link. Define the stub here but avoid type
+ * conflict with the emscripten's header.
+ */
+ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
+                             off_t *out_off, size_t len, unsigned int flags)
+{
+    errno = ENOSYS;
+    return -1;
+}

I'd include in this patch this hunk from patch 17:

-- >8 --
diff --git a/stubs/meson.build b/stubs/meson.build
index 63392f5e78..4fd4d362f9 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -89,3 +89,7 @@ if have_system or have_user
   stub_ss.add(files('hotplug-stubs.c'))
   stub_ss.add(files('sysbus.c'))
 endif
+
+if host_os == 'emscripten'
+  stub_ss.add(files('emscripten.c'))
+endif
---



reply via email to

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