Skip to contentSkip to conversation

First batch of misc changes for 2.5 (2015-09-09)

GIT PULL Applied Paolo Bonzini 2 participants 6 messages Sep 14, 2015

lore
Share & tools
lore
#0 lore raw

The following changes since commit 090d0bfd948343d522cd20bc634105b5cfe2483b:

s390: fix softmmu compilation (2015-08-28 16:05:24 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 47d4be12c3997343e436c6cca89aefbbbeb70863:

cutils: work around platform differences in strto{l,ul,ll,ull} (2015-09-10 10:02:00 +0200)

----------------------------------------------------------------
* Support for jemalloc
* qemu_mutex_lock_iothread "No such process" fix
* cutils: qemu_strto* wrappers
* iohandler.c simplification
* Many other fixes and misc patches.

And some MTTCG work (with Emilio's fixes squashed):
* Signal-free TCG kick
* Removing spinlock in favor of QemuMutex
* User-mode emulation multi-threading fixes/docs

----------------------------------------------------------------
Alexandre Derumier (1):
configure: Add support for jemalloc

Andrey Smetanin (1):
Added generic panic handler qemu_system_guest_panicked()

Aníbal Limón (1):
cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init

Carlos L. Torres (5):
cutils: Add qemu_strtol() wrapper
cutils: Add qemu_strtoul() wrapper
cutils: Add qemu_strtoll() wrapper
cutils: Add qemu_strtoull() wrapper
qmp: Add example usage of strto*l() qemu wrapper

Dr. David Alan Gilbert (1):
Move RAMBlock and ram_list to ram_addr.h

Emilio G. Cota (7):
qemu-thread: handle spurious futex_wait wakeups
seqlock: add missing 'inline' to seqlock_read_retry
seqlock: read sequence number atomically
rcu: init rcu_registry_lock after fork
rcu: fix comment with s/rcu_gp_lock/rcu_registry_lock/
linux-user: call rcu_(un)register_thread on pthread_(exit|create)
translate-all: remove obsolete comment about l1_map

Fam Zheng (1):
iohandler: Use aio API

Gonglei (1):
vhost-scsi: fix wrong vhost-scsi firmware path

KONRAD Frederic (3):
cpus: remove tcg_halt_cond and tcg_cpu_thread globals replace spinlock by QemuMutex.
remove unused spinlock.

Michael Marineau (1):
Makefile.target: include top level build dir in vpath

Michael S. Tsirkin (1):
scripts/dump-guest-memory.py: fix after RAMBlock change

Paolo Bonzini (19):
i8257: rewrite DMA_schedule to avoid hooking into the CPU loop
i8257: remove cpu_request_exit irq
tcg: introduce tcg_current_cpu
remove qemu/tls.h
tcg: assign cpu->current_tb in a simpler place
tcg: synchronize cpu->exit_request and cpu->tcg_exit_req accesses
tcg: synchronize exit_request and tcg_current_cpu accesses use qemu_cpu_kick instead of cpu_exit or qemu_cpu_kick_thread
tcg: signal-free qemu_cpu_kick
CODING_STYLE: update mixed declaration rules
checkpatch: adapt some tests to QEMU
checkpatch: remove tests that are not relevant outside the kernel add macro file for coccinelle
cpus: protect work list with work_mutex
tcg: add memory barriers in page_find_alloc accesses
tcg: comment on which functions have to be called with mmap_lock held
exec: make mmap_lock/mmap_unlock globally available
cpu-exec: fix lock hierarchy for user-mode emulation
cutils: work around platform differences in strto{l,ul,ll,ull}

Peter Crosthwaite (1):
configure: factor out adding disas configure

Peter Lieven (1):
block/iscsi: validate block size returned from target

 CODING_STYLE                 |   13 +-
 Makefile.target              |    2 +-
 block/iscsi.c                |    4 +
 bsd-user/qemu.h              |    2 -
 configure                    |   93 ++--
 cpu-exec.c                   |  119 ++--
 cpus.c                       |  130 ++---
 exec.c                       |    2 +-
 gdbstub.c                    |    2 +-
 hw/block/fdc.c               |    2 +-
 hw/dma/i82374.c              |    5 +-
 hw/dma/i8257.c               |   31 +-
 hw/i386/pc.c                 |   13 +-
 hw/isa/i82378.c              |    3 +-
 hw/mips/mips_fulong2e.c      |   13 +-
 hw/mips/mips_jazz.c          |   13 +-
 hw/mips/mips_malta.c         |   13 +-
 hw/misc/pvpanic.c            |    3 +-
 hw/ppc/prep.c                |   11 -
 hw/ppc/spapr_rtas.c          |    2 +-
 hw/scsi/vhost-scsi.c         |    2 +-
 hw/sparc/sun4m.c             |    4 +-
 hw/sparc64/sun4u.c           |    4 +-
 include/exec/cpu-all.h       |   41 --
 include/exec/exec-all.h      |   15 +-
 include/exec/ram_addr.h      |   40 ++
 include/exec/spinlock.h      |   49 --
 include/hw/isa/isa.h         |    4 +-
 include/qemu-common.h        |    8 +
 include/qemu/main-loop.h     |    3 +-
 include/qemu/rcu.h           |    2 +-
 include/qemu/seqlock.h       |    8 +-
 include/qemu/tls.h           |   52 --
 include/qom/cpu.h            |   14 +-
 include/sysemu/sysemu.h      |    1 +
 iohandler.c                  |  111 +---
 linux-user/main.c            |    6 +-
 linux-user/qemu.h            |    2 -
 linux-user/syscall.c         |    2 +
 main-loop.c                  |    5 +-
 qmp.c                        |   14 +-
 qom/cpu.c                    |    3 +
 scripts/checkpatch.pl        |  540 +++---------------
 scripts/cocci-macro-file.h   |  119 ++++
 scripts/dump-guest-memory.py |    2 +-
 target-i386/cpu.h            |    3 +
 target-i386/mem_helper.c     |   25 +-
 target-i386/translate.c      |    2 +
 target-s390x/kvm.c           |   11 +-
 tcg/tcg.h                    |    4 +
 tests/test-cutils.c          | 1255 ++++++++++++++++++++++++++++++++++++++++++
 translate-all.c              |   85 ++-
 util/cutils.c                |  150 +++++
 util/qemu-thread-posix.c     |   11 +-
 util/rcu.c                   |    7 +-
 vl.c                         |    6 +
 56 files changed, 2046 insertions(+), 1040 deletions(-)
 delete mode 100644 include/exec/spinlock.h
 delete mode 100644 include/qemu/tls.h
 create mode 100644 scripts/cocci-macro-file.h
Signature · 1 line
2.5.0
#1 lore raw

[Qemu-devel] [PULL 44/44] cutils: work around platform differences in strto{l, ul, ll, ull}

Linux returns 0 if no conversion was made, while OS X and presumably the BSDs return EINVAL. The OS X convention rejects more invalid inputs, so convert to it and adjust the test case.

Windows returns 1 from strtoul and strtoull (instead of -1) for negative out-of-range input; fix it up.

---
 tests/test-cutils.c | 57 +++++++++++++++--------------------------------------
 util/cutils.c       | 24 +++++++++++++++++-----
 2 files changed, 35 insertions(+), 46 deletions(-)
tests/test-cutils.c +16 -41
index a7a15a5..0046c61 100644
@@ -264,9 +264,7 @@ static void test_qemu_strtol_empty(void)
 
     err = qemu_strtol(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_whitespace(void)
@@ -279,9 +277,7 @@ static void test_qemu_strtol_whitespace(void)
 
     err = qemu_strtol(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_invalid(void)
@@ -294,9 +290,7 @@ static void test_qemu_strtol_invalid(void)
 
     err = qemu_strtol(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_trailing(void)
@@ -478,8 +472,7 @@ static void test_qemu_strtol_full_empty(void)
 
     err =  qemu_strtol(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_full_negative(void)
@@ -555,9 +548,7 @@ static void test_qemu_strtoul_empty(void)
 
     err = qemu_strtoul(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoul_whitespace(void)
@@ -570,9 +561,7 @@ static void test_qemu_strtoul_whitespace(void)
 
     err = qemu_strtoul(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoul_invalid(void)
@@ -585,8 +574,7 @@ static void test_qemu_strtoul_invalid(void)
 
     err = qemu_strtoul(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoul_trailing(void)
@@ -765,8 +753,7 @@ static void test_qemu_strtoul_full_empty(void)
 
     err = qemu_strtoul(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 static void test_qemu_strtoul_full_negative(void)
 {
@@ -840,9 +827,7 @@ static void test_qemu_strtoll_empty(void)
 
     err = qemu_strtoll(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_whitespace(void)
@@ -855,9 +840,7 @@ static void test_qemu_strtoll_whitespace(void)
 
     err = qemu_strtoll(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_invalid(void)
@@ -870,8 +853,7 @@ static void test_qemu_strtoll_invalid(void)
 
     err = qemu_strtoll(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_trailing(void)
@@ -1050,8 +1032,7 @@ static void test_qemu_strtoll_full_empty(void)
 
     err = qemu_strtoll(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_full_negative(void)
@@ -1128,9 +1109,7 @@ static void test_qemu_strtoull_empty(void)
 
     err = qemu_strtoull(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_whitespace(void)
@@ -1143,9 +1122,7 @@ static void test_qemu_strtoull_whitespace(void)
 
     err = qemu_strtoull(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_invalid(void)
@@ -1158,8 +1135,7 @@ static void test_qemu_strtoull_invalid(void)
 
     err = qemu_strtoull(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_trailing(void)
@@ -1338,8 +1314,7 @@ static void test_qemu_strtoull_full_empty(void)
 
     err = qemu_strtoull(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_full_negative(void)
util/cutils.c +19 -5
index 67c50e5..84ceaff 100644
@@ -361,9 +361,15 @@ int64_t strtosz(const char *nptr, char **end)
 /**
  * Helper function for qemu_strto*l() functions.
  */
-static int check_strtox_error(const char **next, char *endptr,
+static int check_strtox_error(const char *p, char *endptr, const char **next,
                               int err)
 {
+    /* If no conversion was performed, prefer BSD behavior over glibc
+     * behavior.
+     */
+    if (err == 0 && endptr == p) {
+        err = EINVAL;
+    }
     if (!next && *endptr) {
         return -EINVAL;
     }
@@ -412,7 +418,7 @@ int qemu_strtol(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtol(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
@@ -443,7 +449,11 @@ int qemu_strtoul(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtoul(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        /* Windows returns 1 for negative out-of-range values.  */
+        if (errno == ERANGE) {
+            *result = -1;
+        }
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
@@ -466,7 +476,7 @@ int qemu_strtoll(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtoll(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
@@ -489,7 +499,11 @@ int qemu_strtoull(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtoull(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        /* Windows returns 1 for negative out-of-range values.  */
+        if (errno == ERANGE) {
+            *result = -1;
+        }
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
Signature · 1 line
2.5.0
#2 lore raw

Re: [Qemu-devel] [PULL 44/44] cutils: work around platform differences in strto{l, ul, ll, ull}

Quoted 256 lines · Paolo Bonzini

Linux returns 0 if no conversion was made, while OS X and presumably the BSDs return EINVAL. The OS X convention rejects more invalid inputs, so convert to it and adjust the test case.

Windows returns 1 from strtoul and strtoull (instead of -1) for negative out-of-range input; fix it up.

---
 tests/test-cutils.c | 57 +++++++++++++++--------------------------------------
 util/cutils.c       | 24 +++++++++++++++++-----
 2 files changed, 35 insertions(+), 46 deletions(-)
tests/test-cutils.c +16 -41
index a7a15a5..0046c61 100644
@@ -264,9 +264,7 @@ static void test_qemu_strtol_empty(void)
 
     err = qemu_strtol(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_whitespace(void)
@@ -279,9 +277,7 @@ static void test_qemu_strtol_whitespace(void)
 
     err = qemu_strtol(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_invalid(void)
@@ -294,9 +290,7 @@ static void test_qemu_strtol_invalid(void)
 
     err = qemu_strtol(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_trailing(void)
@@ -478,8 +472,7 @@ static void test_qemu_strtol_full_empty(void)
 
     err =  qemu_strtol(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtol_full_negative(void)
@@ -555,9 +548,7 @@ static void test_qemu_strtoul_empty(void)
 
     err = qemu_strtoul(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoul_whitespace(void)
@@ -570,9 +561,7 @@ static void test_qemu_strtoul_whitespace(void)
 
     err = qemu_strtoul(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoul_invalid(void)
@@ -585,8 +574,7 @@ static void test_qemu_strtoul_invalid(void)
 
     err = qemu_strtoul(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoul_trailing(void)
@@ -765,8 +753,7 @@ static void test_qemu_strtoul_full_empty(void)
 
     err = qemu_strtoul(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 static void test_qemu_strtoul_full_negative(void)
 {
@@ -840,9 +827,7 @@ static void test_qemu_strtoll_empty(void)
 
     err = qemu_strtoll(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_whitespace(void)
@@ -855,9 +840,7 @@ static void test_qemu_strtoll_whitespace(void)
 
     err = qemu_strtoll(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_invalid(void)
@@ -870,8 +853,7 @@ static void test_qemu_strtoll_invalid(void)
 
     err = qemu_strtoll(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_trailing(void)
@@ -1050,8 +1032,7 @@ static void test_qemu_strtoll_full_empty(void)
 
     err = qemu_strtoll(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoll_full_negative(void)
@@ -1128,9 +1109,7 @@ static void test_qemu_strtoull_empty(void)
 
     err = qemu_strtoull(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_whitespace(void)
@@ -1143,9 +1122,7 @@ static void test_qemu_strtoull_whitespace(void)
 
     err = qemu_strtoull(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_invalid(void)
@@ -1158,8 +1135,7 @@ static void test_qemu_strtoull_invalid(void)
 
     err = qemu_strtoull(str, &endptr, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert(endptr == str);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_trailing(void)
@@ -1338,8 +1314,7 @@ static void test_qemu_strtoull_full_empty(void)
 
     err = qemu_strtoull(str, NULL, 0, &res);
 
-    g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 0);
+    g_assert_cmpint(err, ==, -EINVAL);
 }
 
 static void test_qemu_strtoull_full_negative(void)
util/cutils.c +19 -6
index 67c50e5..84ceaff 100644
@@ -361,9 +361,15 @@ int64_t strtosz(const char *nptr, char **end)
 /**
  * Helper function for qemu_strto*l() functions.
  */
-static int check_strtox_error(const char **next, char *endptr,
+static int check_strtox_error(const char *p, char *endptr, const char **next,
                               int err)
 {
+    /* If no conversion was performed, prefer BSD behavior over glibc
+     * behavior.
+     */
+    if (err == 0 && endptr == p) {
+        err = EINVAL;
+    }
     if (!next && *endptr) {
         return -EINVAL;
     }
@@ -412,7 +418,7 @@ int qemu_strtol(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtol(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
@@ -443,7 +449,11 @@ int qemu_strtoul(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtoul(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        /* Windows returns 1 for negative out-of-range values.  */
+        if (errno == ERANGE) {
+            *result = -1;
+        }
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
@@ -466,7 +476,7 @@ int qemu_strtoll(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtoll(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
@@ -489,7 +499,11 @@ int qemu_strtoull(const char *nptr, const char **endptr, int base,
     } else {
         errno = 0;
         *result = strtoull(nptr, &p, base);
-        err = check_strtox_error(endptr, p, errno);
+        /* Windows returns 1 for negative out-of-range values.  */
+        if (errno == ERANGE) {
+            *result = -1;
+        }
+        err = check_strtox_error(nptr, p, endptr, errno);
     }
     return err;
 }
--

2.5.0

Signature · 2 lines
12345678901234567890123456789012345678901234567890123456789012345678901234567890
         1         2         3         4         5         6         7         8
#3 lore raw

Re: [Qemu-devel] [PULL 44/44] cutils: work around platform differences in strto{l, ul, ll, ull}

Quoted 3 lines · Peter Maydell
Quoted 2 lines · Paolo Bonzini

Windows returns 1 from strtoul and strtoull (instead of -1) for negative out-of-range input; fix it up.

No problem with this patch, just wanted to say 'wat?' at this.

(and then fumbled a blank reply with my mail client, oh well)

-- PMM

#4 lore raw

Re: [Qemu-devel] [PULL 44/44] cutils: work around platform differences in strto{l, ul, ll, ull}

Quoted 3 lines · Peter Maydell
Quoted 2 lines
Quoted 2 lines

Windows returns 1 from strtoul and strtoull (instead of -1) for

Quoted 1 line
Quoted 1 line

negative out-of-range input; fix it up.

No problem with this patch, just wanted to say 'wat?' at this.

Indeed. I only tested with Wine, but it cannot be a mistake:
http://marc.info/?l=wine-patches&m=138011287312090&w=2

There are even test cases. :-)

Paolo

#5 lore raw
In reply to Paolo Bonzini
Quoted 19 lines · Paolo Bonzini

The following changes since commit 090d0bfd948343d522cd20bc634105b5cfe2483b:

s390: fix softmmu compilation (2015-08-28 16:05:24 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 47d4be12c3997343e436c6cca89aefbbbeb70863:

cutils: work around platform differences in strto{l,ul,ll,ull} (2015-09-10 10:02:00 +0200)

----------------------------------------------------------------
* Support for jemalloc
* qemu_mutex_lock_iothread "No such process" fix
* cutils: qemu_strto* wrappers
* iohandler.c simplification
* Many other fixes and misc patches.

Quoted 5 lines

And some MTTCG work (with Emilio's fixes squashed):
* Signal-free TCG kick
* Removing spinlock in favor of QemuMutex
* User-mode emulation multi-threading fixes/docs

Applied, thanks.

-- PMM