qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] semihosting: add O_BINARY flag in host_open for NT compatibility
@ 2023-01-06 10:20 Evgeny Iakovlev
  2023-01-06 13:51 ` Alex Bennée
  2023-01-06 14:13 ` Peter Maydell
  0 siblings, 2 replies; 10+ messages in thread
From: Evgeny Iakovlev @ 2023-01-06 10:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: bmeng.cn, philmd, alex.bennee

Windows open(2) implementation opens files in text mode by default and
needs a Windows-only O_BINARY flag to open files as binary. QEMU already
knows about that flag in osdep and it is defined to 0 on non-Windows,
so we can just add it to the host_flags for better compatibility.

Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 semihosting/syscalls.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c
index 508a0ad88c..b621d78c2d 100644
--- a/semihosting/syscalls.c
+++ b/semihosting/syscalls.c
@@ -253,7 +253,7 @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
 {
     CPUArchState *env G_GNUC_UNUSED = cs->env_ptr;
     char *p;
-    int ret, host_flags;
+    int ret, host_flags = O_BINARY;
 
     ret = validate_lock_user_string(&p, cs, fname, fname_len);
     if (ret < 0) {
@@ -262,11 +262,11 @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
     }
 
     if (gdb_flags & GDB_O_WRONLY) {
-        host_flags = O_WRONLY;
+        host_flags |= O_WRONLY;
     } else if (gdb_flags & GDB_O_RDWR) {
-        host_flags = O_RDWR;
+        host_flags |= O_RDWR;
     } else {
-        host_flags = O_RDONLY;
+        host_flags |= O_RDONLY;
     }
     if (gdb_flags & GDB_O_CREAT) {
         host_flags |= O_CREAT;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-01-16 16:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-06 10:20 [PATCH v2] semihosting: add O_BINARY flag in host_open for NT compatibility Evgeny Iakovlev
2023-01-06 13:51 ` Alex Bennée
2023-01-06 14:13 ` Peter Maydell
2023-01-06 15:33   ` Alex Bennée
2023-01-06 16:28     ` Peter Maydell
2023-01-06 18:22       ` Evgeny Iakovlev
2023-01-06 18:58         ` Peter Maydell
2023-01-16 15:56           ` eiakovlev
2023-01-16 16:25             ` Alex Bennée
2023-01-16 16:39             ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).