New patches for w32, w64
Here are some small patches needed for the w32 and w64 platforms.
[PATCH 1/3] Fix conversions from pointer to tcg_target_long [PATCH 2/3] w64: Add definition of FMT_pid
[PATCH 3/3] w32: Fix format string regression
Kind regards,
Stefan
PATCH 1/3 Fix conversions from pointer to tcg_target_long
tcg_gen_exit_tb takes a parameter of type tcg_target_long, so the type casts of pointer to long should be replaced by type casts of pointer to tcg_target_long.
These changes are needed for build environments where sizeof(long) != sizeof(void *), especially for w64.
See 4b4a72e55660abf7efe85aca78762dcfea5519ad which fixed the same issue for the other targets.
--- target-s390x/translate.c | 2 +- target-unicore32/translate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
target-s390x/translate.c +1 -1
@@ -830,7 +830,7 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num, target_ulong pc)/* jump to same page: we can use a direct jump */ tcg_gen_goto_tb (tb_num);tcg_gen_movi_i64 (psw_addr, pc); -tcg_gen_exit_tb ((long )tb + tb_num); +tcg_gen_exit_tb ((tcg_target_long )tb + tb_num); }else {/* jump to another page: currently not optimized */ tcg_gen_movi_i64 (psw_addr, pc);
target-unicore32/translate.c +1 -1
@@ -1056,7 +1056,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint32_t dest)if ((tb->pc &TARGET_PAGE_MASK ) == (dest &TARGET_PAGE_MASK )) {tcg_gen_goto_tb (n);gen_set_pc_im (dest); -tcg_gen_exit_tb ((long )tb + n); +tcg_gen_exit_tb ((tcg_target_long )tb + n); }else {gen_set_pc_im (dest);tcg_gen_exit_tb (0 );
Signature · 1 line
1.7.2.5
Re: [Qemu-devel] [PATCH 1/3] Fix conversions from pointer to tcg_target_long
It's good for unicore32 bit.
Thanks & Regards.
Guan Xuetao
Quoted 44 lines · Stefan Weil
tcg_gen_exit_tbtakes a parameter of typetcg_target_long, so the type casts of pointer to long should be replaced by type casts of pointer totcg_target_long.These changes are needed for build environments where sizeof(long) !=
sizeof(void *), especially for w64.See
4b4a72e55660abf7efe85aca78762dcfea5519adwhich fixed the same issue for the other targets.Cc Alexander Graf <[email protected]>Cc Guan Xuetao <[email protected]>Signed-off-by Stefan Weil <[email protected]>--- target-s390x/translate.c | 2 +- target-unicore32/translate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)target-s390x/translate.c +1
-1@@ -830,7 +830,7 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num, target_ulong pc)/* jump to same page: we can use a direct jump */ tcg_gen_goto_tb (tb_num);tcg_gen_movi_i64 (psw_addr, pc); -tcg_gen_exit_tb ((long )tb + tb_num); +tcg_gen_exit_tb ((tcg_target_long )tb + tb_num); }else {/* jump to another page: currently not optimized */ tcg_gen_movi_i64 (psw_addr, pc);target-unicore32/translate.c +1
-1@@ -1056,7 +1056,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint32_t dest)if ((tb->pc &TARGET_PAGE_MASK ) == (dest &TARGET_PAGE_MASK )) {tcg_gen_goto_tb (n);gen_set_pc_im (dest); -tcg_gen_exit_tb ((long )tb + n); +tcg_gen_exit_tb ((tcg_target_long )tb + n); }else {gen_set_pc_im (dest);tcg_gen_exit_tb (0 );
Re: [Qemu-devel] [PATCH 1/3] Fix conversions from pointer to tcg_target_long
In reply to Stefan WeilQuoted 9 lines · Stefan Weil
tcg_gen_exit_tbtakes a parameter of typetcg_target_long, so the type casts of pointer to long should be replaced by type casts of pointer totcg_target_long.These changes are needed for build environments where sizeof(long) !=
sizeof(void *), especially for w64.See
4b4a72e55660abf7efe85aca78762dcfea5519adwhich fixed the same issue for the other targets.
Changes the code to be aligned with the i386 target, so I'm in favor.
Alex
PATCH 2/3 w64: Add definition of FMT_pid
In reply to Stefan WeilFor mingw-w64, pid_t is _pid_t which is __int64, so this platform needs its own definition of FMT_pid.
--- osdep.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
osdep.h +2 -0
@@ -130,6 +130,8 @@ int qemu_madvise(void *addr, size_t len, int advice);#if defined(__HAIKU__) && defined(__i386__)#define FMT_pid "%ld" +#elif defined(WIN64 ) +#define FMT_pid "%" PRId64#else #define FMT_pid "%d"#endif
Signature · 1 line
1.7.2.5
Re: [Qemu-devel] [PATCH 2/3] w64: Add definition of FMT_pid
Am 15.07.2011 um 21:38 schrieb Stefan Weil:
Quoted 4 lines
For mingw-w64,
pid_tis_pid_twhich is__int64, so this platform needs its own definition ofFMT_pid.Signed-off-by Stefan Weil <[email protected]>
Ah, that's probably lld then and thus different from the existing definitions.
Andreas
Quoted 20 lines
---
osdep.h| 2 ++1 files changed, 2 insertions(+), 0 deletions(-)osdep.h +2
-0@@ -130,6 +130,8 @@ int qemu_madvise(void *addr, size_t len, int advice);#if defined(__HAIKU__) && defined(__i386__)#define FMT_pid "%ld" +#elif defined(WIN64 ) +#define FMT_pid "%" PRId64#else #define FMT_pid "%d"#endif
Signature · 1 line
1.7.2.5
PATCH 3/3 w32: Fix format string regression
In reply to Stefan WeilCommit 953ffe0f935f40c0d6061d69e76e0339393b54f8 introduced FMT_pid which is wrong for w32 and w64 getpid():
those getpid() implementations always return an int value.
--- os-win32.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
os-win32.c +1 -1
@@ -258,7 +258,7 @@ int qemu_create_pidfile(const char *filename)if (file ==INVALID_HANDLE_VALUE ) {return -1 ; } - len =snprintf (buffer,sizeof (buffer), FMT_pid"\n" ,getpid ()); + len =snprintf (buffer,sizeof (buffer),"%d\n" ,getpid ()); ret =WriteFileEx (file, (LPCVOID )buffer, (DWORD )len, &overlap,NULL );if (ret ==0 ) {
Signature · 1 line
1.7.2.5
Re: [Qemu-devel] [PATCH 3/3] w32: Fix format string regression
Am 15.07.2011 um 21:38 schrieb Stefan Weil:
Quoted 3 lines
Commit
953ffe0f935f40c0d6061d69e76e0339393b54f8introducedFMT_pidwhich is wrong for w32 and w64getpid():
thosegetpid()implementations always return an int value.
Where is __int64 FMT_pid used then if not for the returned pid?
Andreas
Quoted 23 lines
Signed-off-by Stefan Weil <[email protected]>---
os-win32.c| 2 +-1 files changed, 1 insertions(+), 1 deletions(-)os-win32.c +1
-1@@ -258,7 +258,7 @@ int qemu_create_pidfile(const char *filename)if (file ==INVALID_HANDLE_VALUE ) {return -1 ; } - len =snprintf (buffer,sizeof (buffer), FMT_pid"\n" ,getpid ()); + len =snprintf (buffer,sizeof (buffer),"%d\n" ,getpid ()); ret =WriteFileEx (file, (LPCVOID )buffer, (DWORD )len, &overlap,NULL );if (ret ==0 ) {Signature · 1 line
1.7.2.5
Re: [Qemu-devel] [PATCH 3/3] w32: Fix format string regression
Quoted 5 lines · Andreas Färber
Am 15.07.2011 um 21:38 schrieb Stefan Weil:
Quoted 3 lines
Commit
953ffe0f935f40c0d6061d69e76e0339393b54f8introducedFMT_pidwhich is wrong for w32 and w64getpid():
thosegetpid()implementations always return an int value.
This is not in line with Posix:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpid.html#tag_16_243
Quoted 1 line
Where is
__int64FMT_pidused then if not for the returned pid?
For shutdown_pid which is pid_t:src/qemu/vl.c:1200: fprintf(stderr, " from pid " FMT_pid
"\n", shutdown_pid);
Quoted 8 lines
Andreas
Quoted 6 lines
Signed-off-by Stefan Weil <[email protected]>---
os-win32.c| 2 +-1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 10 lines
os-win32.c int qemu_create_pidfile(const char *filename) · line 261
Quoted 10 lines
os-win32.c +1
-1@@ -258,7 +258,7 @@ int qemu_create_pidfile(const char *filename) if (file == INVALID_HANDLE_VALUE) { return -1; } - len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid()); + len = snprintf(buffer, sizeof(buffer), "%d\n", getpid());
Another way would be to cast the result of getpid to pid_t. Then if the buggy getpid() implementations are fixed one day, there will be no truncation.
Quoted 9 lines
Quoted 7 lines
os-win32.c +0
-1ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len, &overlap, NULL); if (ret == 0) { --1.7.2.5
Re: [Qemu-devel] [PATCH 3/3] w32: Fix format string regression
Am 17.07.2011 11:03, schrieb Blue Swirl:
Quoted 8 lines · Andreas Färber
Quoted 4 lines
Am 15.07.2011 um 21:38 schrieb Stefan Weil:
Quoted 3 lines
Commit
953ffe0f935f40c0d6061d69e76e0339393b54f8introducedFMT_pidwhich is wrong for w32 and w64getpid():
thosegetpid()implementations always return an int value.This is not in line with Posix:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpid.html#tag_16_243
Maybe I should have added that getpid() is a function in a vendor specific API. Microsoft does not claim that getpid() is in line with Posix
(they say it is a deprecated POSIX function, see
http://msdn.microsoft.com/en-us/library/ms235372%28v=vs.80%29.aspx).
Visual Studio uses this declaration:_CRT_NONSTDC_DEPRECATE(_getpid) _CRTIMP int __cdecl getpid(void);
Mingw32 tries to be more POSIX like and uses (with pid_t = int) this declaration:_CRTIMP pid_t __cdecl __MINGW_NOTHROW getpid (void);
Mingw-w64 is closer to the VS declaration:
int __cdecl getpid(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
The replacement for getpid() is _getpid(). It also has a wrong declaration in mingw32. A patch which simply replaces getpid by _getpid is on my todo list, but not urgent, because the current code works when my patch was applied.
Regards,
Stefan
Re: [Qemu-devel] [PATCH 3/3] w32: Fix format string regression
Quoted 28 lines · Stefan Weil
Am 17.07.2011 11:03, schrieb Blue Swirl:
Quoted 6 lines
Quoted 3 lines · Andreas Färber
Am 15.07.2011 um 21:38 schrieb Stefan Weil:
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Commit
953ffe0f935f40c0d6061d69e76e0339393b54f8introducedFMT_pidwhich is wrong for w32 and w64getpid():
thosegetpid()implementations always return an int value.This is not in line with Posix:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpid.html#tag_16_243
Maybe I should have added that
getpid()is a function in a vendor specific API.
Microsoft does not claim thatgetpid()is in line with Posix (they say it is a deprecated POSIX function, see
http://msdn.microsoft.com/en-us/library/ms235372%28v=vs.80%29.aspx).Visual Studio uses this declaration:
_CRT_NONSTDC_DEPRECATE(_getpid)_CRTIMPint__cdeclgetpid(void);Mingw32 tries to be more POSIX like and uses (with
pid_t= int) this declaration:_CRTIMPpid_t__cdecl__MINGW_NOTHROWgetpid (void);
Quoted 7 lines
Mingw-w64 is closer to the VS declaration:
int__cdeclgetpid(void)__MINGW_ATTRIB_DEPRECATED_MSVC2005;The replacement for
getpid()is_getpid(). It also has a wrong declaration in mingw32. A patch which simply replaces getpid by_getpidis on my todo list, but not urgent, because the current code works when my patch was applied.
Since for example GetProcessById uses int, it looks like pid_t is instead wrong.
Am 15.07.2011 21:38, schrieb Stefan Weil:
Quoted 8 lines
Here are some small patches needed for the w32 and w64 platforms.
[PATCH 1/3] Fix conversions from pointer to
tcg_target_long[PATCH 2/3] w64: Add definition ofFMT_pid
[PATCH 3/3] w32: Fix format string regressionKind regards,
Stefan
What about these patches?
Patch 1 was acked by two developers:
http://patchwork.ozlabs.org/patch/104889/
Patch 2 was review by Andreas:
http://patchwork.ozlabs.org/patch/104884/
Patch 3 was discussed a lot:
http://patchwork.ozlabs.org/patch/104885/
At least the first two patches can be applied immediately.
I also think that the third patch is correct and should be applied. It's only MinGW related and fixes a compiler error (regression) there.
Cheers,
Stefan
Quoted 16 lines · Stefan Weil
Am 15.07.2011 21:38, schrieb Stefan Weil:
Quoted 9 lines
Here are some small patches needed for the w32 and w64 platforms.
[PATCH 1/3] Fix conversions from pointer to
tcg_target_long[PATCH 2/3] w64: Add definition ofFMT_pid
[PATCH 3/3] w32: Fix format string regressionKind regards,
StefanWhat about these patches?
Patch 1 was acked by two developers:
http://patchwork.ozlabs.org/patch/104889/
Quoted 7 lines
Patch 2 was review by Andreas:
http://patchwork.ozlabs.org/patch/104884/Patch 3 was discussed a lot:
http://patchwork.ozlabs.org/patch/104885/At least the first two patches can be applied immediately.
Yes.
Quoted 2 lines
I also think that the third patch is correct and should be applied. It's only MinGW related and fixes a compiler error (regression) there.
The interfaces are broken in so many ways that I don't know what is the right fix, maybe introducing qemu_getpid() which always returned pid_t could hide this madness. Then 3/3 would not be needed.
Blue Swirl
AppliedThanks, applied all.
Quoted 9 lines · Stefan Weil
Here are some small patches needed for the w32 and w64 platforms.
[PATCH 1/3] Fix conversions from pointer to
tcg_target_long[PATCH 2/3] w64: Add definition ofFMT_pid
[PATCH 3/3] w32: Fix format string regressionKind regards,
Stefan