All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64
@ 2010-12-04 19:41 Stefan Weil
  2011-01-30 21:27 ` [Qemu-devel] " Stefan Weil
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2010-12-04 19:41 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

QEMU always uses POSIX format specifiers, even with mingw32.

Therefore the old definitions of the PRI*64 macros were wrong.
They should be removed, but as long as the mingw32 system
include inttypes.h provides wrong definitions, too,
we correct them here.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 qemu-common.h |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/qemu-common.h b/qemu-common.h
index de82c2e..c739f45 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -96,10 +96,18 @@ static inline char *realpath(const char *path, char *resolved_path)
     return resolved_path;
 }
 
-#define PRId64 "I64d"
-#define PRIx64 "I64x"
-#define PRIu64 "I64u"
-#define PRIo64 "I64o"
+/* inttypes.h (mingw32) provides wrong definitions, so fix them here. */
+/* TODO: remove this workaround as soon as mingw32 is fixed. */
+
+#undef PRId64
+#undef PRIx64
+#undef PRIu64
+#undef PRIo64
+
+#define PRId64 "lld"
+#define PRIx64 "llx"
+#define PRIu64 "llu"
+#define PRIo64 "llo"
 #endif
 
 /* FIXME: Remove NEED_CPU_H.  */
-- 
1.7.2.3

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

* [Qemu-devel] Re: [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64
  2010-12-04 19:41 [Qemu-devel] [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64 Stefan Weil
@ 2011-01-30 21:27 ` Stefan Weil
  2011-01-30 21:39   ` Blue Swirl
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2011-01-30 21:27 UTC (permalink / raw)
  To: Blue Swirl; +Cc: QEMU Developers

Am 04.12.2010 20:41, schrieb Stefan Weil:
> QEMU always uses POSIX format specifiers, even with mingw32.
>
> Therefore the old definitions of the PRI*64 macros were wrong.
> They should be removed, but as long as the mingw32 system
> include inttypes.h provides wrong definitions, too,
> we correct them here.
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
> qemu-common.h | 16 ++++++++++++----
> 1 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/qemu-common.h b/qemu-common.h
> index de82c2e..c739f45 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -96,10 +96,18 @@ static inline char *realpath(const char *path, 
> char *resolved_path)
> return resolved_path;
> }
>
> -#define PRId64 "I64d"
> -#define PRIx64 "I64x"
> -#define PRIu64 "I64u"
> -#define PRIo64 "I64o"
> +/* inttypes.h (mingw32) provides wrong definitions, so fix them here. */
> +/* TODO: remove this workaround as soon as mingw32 is fixed. */
> +
> +#undef PRId64
> +#undef PRIx64
> +#undef PRIu64
> +#undef PRIo64
> +
> +#define PRId64 "lld"
> +#define PRIx64 "llx"
> +#define PRIu64 "llu"
> +#define PRIo64 "llo"
> #endif
>
> /* FIXME: Remove NEED_CPU_H. */

What about this patch? It is still missing in QEMU git master.

Kind regards,
Stefan

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

* [Qemu-devel] Re: [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64
  2011-01-30 21:27 ` [Qemu-devel] " Stefan Weil
@ 2011-01-30 21:39   ` Blue Swirl
  2011-01-30 21:50     ` Stefan Weil
  0 siblings, 1 reply; 7+ messages in thread
From: Blue Swirl @ 2011-01-30 21:39 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

On Sun, Jan 30, 2011 at 9:27 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Am 04.12.2010 20:41, schrieb Stefan Weil:
>>
>> QEMU always uses POSIX format specifiers, even with mingw32.
>>
>> Therefore the old definitions of the PRI*64 macros were wrong.
>> They should be removed, but as long as the mingw32 system
>> include inttypes.h provides wrong definitions, too,
>> we correct them here.
>>
>> Cc: Blue Swirl <blauwirbel@gmail.com>
>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>> ---
>> qemu-common.h | 16 ++++++++++++----
>> 1 files changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/qemu-common.h b/qemu-common.h
>> index de82c2e..c739f45 100644
>> --- a/qemu-common.h
>> +++ b/qemu-common.h
>> @@ -96,10 +96,18 @@ static inline char *realpath(const char *path, char
>> *resolved_path)
>> return resolved_path;
>> }
>>
>> -#define PRId64 "I64d"
>> -#define PRIx64 "I64x"
>> -#define PRIu64 "I64u"
>> -#define PRIo64 "I64o"
>> +/* inttypes.h (mingw32) provides wrong definitions, so fix them here. */
>> +/* TODO: remove this workaround as soon as mingw32 is fixed. */
>> +
>> +#undef PRId64
>> +#undef PRIx64
>> +#undef PRIu64
>> +#undef PRIo64
>> +
>> +#define PRId64 "lld"
>> +#define PRIx64 "llx"
>> +#define PRIu64 "llu"
>> +#define PRIo64 "llo"
>> #endif
>>
>> /* FIXME: Remove NEED_CPU_H. */
>
> What about this patch? It is still missing in QEMU git master.

It would appear to suppress quite a few warnings about formats. But on
my version of  inttypes.h there is the following comment:
/* 7.8.1 Macros for format specifiers
 *
 * MS runtime does not yet understand C9x standard "ll"
 * length specifier. It appears to treat "ll" as "l".
 * The non-standard I64 length specifier causes warning in GCC,
 * but understood by MS runtime functions.
 */
So is this change OK after all?

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

* [Qemu-devel] Re: [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64
  2011-01-30 21:39   ` Blue Swirl
@ 2011-01-30 21:50     ` Stefan Weil
  2011-01-30 22:14       ` Blue Swirl
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2011-01-30 21:50 UTC (permalink / raw)
  To: Blue Swirl; +Cc: QEMU Developers

Am 30.01.2011 22:39, schrieb Blue Swirl:
> On Sun, Jan 30, 2011 at 9:27 PM, Stefan Weil <weil@mail.berlios.de> wrote:
>> Am 04.12.2010 20:41, schrieb Stefan Weil:
>>>
>>> QEMU always uses POSIX format specifiers, even with mingw32.
>>>
>>> Therefore the old definitions of the PRI*64 macros were wrong.
>>> They should be removed, but as long as the mingw32 system
>>> include inttypes.h provides wrong definitions, too,
>>> we correct them here.
>>>
>>> Cc: Blue Swirl <blauwirbel@gmail.com>
>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>> ---
>>> qemu-common.h | 16 ++++++++++++----
>>> 1 files changed, 12 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/qemu-common.h b/qemu-common.h
>>> index de82c2e..c739f45 100644
>>> --- a/qemu-common.h
>>> +++ b/qemu-common.h
>>> @@ -96,10 +96,18 @@ static inline char *realpath(const char *path, char
>>> *resolved_path)
>>> return resolved_path;
>>> }
>>>
>>> -#define PRId64 "I64d"
>>> -#define PRIx64 "I64x"
>>> -#define PRIu64 "I64u"
>>> -#define PRIo64 "I64o"
>>> +/* inttypes.h (mingw32) provides wrong definitions, so fix them 
>>> here. */
>>> +/* TODO: remove this workaround as soon as mingw32 is fixed. */
>>> +
>>> +#undef PRId64
>>> +#undef PRIx64
>>> +#undef PRIu64
>>> +#undef PRIo64
>>> +
>>> +#define PRId64 "lld"
>>> +#define PRIx64 "llx"
>>> +#define PRIu64 "llu"
>>> +#define PRIo64 "llo"
>>> #endif
>>>
>>> /* FIXME: Remove NEED_CPU_H. */
>>
>> What about this patch? It is still missing in QEMU git master.
>
> It would appear to suppress quite a few warnings about formats. But on
> my version of inttypes.h there is the following comment:
> /* 7.8.1 Macros for format specifiers
> *
> * MS runtime does not yet understand C9x standard "ll"
> * length specifier. It appears to treat "ll" as "l".
> * The non-standard I64 length specifier causes warning in GCC,
> * but understood by MS runtime functions.
> */
> So is this change OK after all?

Yes, it is. MS runtime indeed does not understand "%lld"
and similar format specifiers.

Mingw does, because it replaces the printf family functions
by inline functions which call __mingw_vfprintf as soon
as __USE_MINGW_ANSI_STDIO is defined. If your MinGW stdio.h
does not use __USE_MINGW_ANSI_STDIO, it is too old.

QEMU defines __USE_MINGW_ANSI_STDIO, and __mingw_vfprintf
understands C9x standard length specifiers.

Stefan

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

* [Qemu-devel] Re: [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64
  2011-01-30 21:50     ` Stefan Weil
@ 2011-01-30 22:14       ` Blue Swirl
  2011-01-31 10:39         ` Mark Cave-Ayland
  2011-01-31 17:25         ` Stefan Weil
  0 siblings, 2 replies; 7+ messages in thread
From: Blue Swirl @ 2011-01-30 22:14 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

On Sun, Jan 30, 2011 at 9:50 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Am 30.01.2011 22:39, schrieb Blue Swirl:
>>
>> On Sun, Jan 30, 2011 at 9:27 PM, Stefan Weil <weil@mail.berlios.de> wrote:
>>>
>>> Am 04.12.2010 20:41, schrieb Stefan Weil:
>>>>
>>>> QEMU always uses POSIX format specifiers, even with mingw32.
>>>>
>>>> Therefore the old definitions of the PRI*64 macros were wrong.
>>>> They should be removed, but as long as the mingw32 system
>>>> include inttypes.h provides wrong definitions, too,
>>>> we correct them here.
>>>>
>>>> Cc: Blue Swirl <blauwirbel@gmail.com>
>>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>>> ---
>>>> qemu-common.h | 16 ++++++++++++----
>>>> 1 files changed, 12 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/qemu-common.h b/qemu-common.h
>>>> index de82c2e..c739f45 100644
>>>> --- a/qemu-common.h
>>>> +++ b/qemu-common.h
>>>> @@ -96,10 +96,18 @@ static inline char *realpath(const char *path, char
>>>> *resolved_path)
>>>> return resolved_path;
>>>> }
>>>>
>>>> -#define PRId64 "I64d"
>>>> -#define PRIx64 "I64x"
>>>> -#define PRIu64 "I64u"
>>>> -#define PRIo64 "I64o"
>>>> +/* inttypes.h (mingw32) provides wrong definitions, so fix them here.
>>>> */
>>>> +/* TODO: remove this workaround as soon as mingw32 is fixed. */
>>>> +
>>>> +#undef PRId64
>>>> +#undef PRIx64
>>>> +#undef PRIu64
>>>> +#undef PRIo64
>>>> +
>>>> +#define PRId64 "lld"
>>>> +#define PRIx64 "llx"
>>>> +#define PRIu64 "llu"
>>>> +#define PRIo64 "llo"
>>>> #endif
>>>>
>>>> /* FIXME: Remove NEED_CPU_H. */
>>>
>>> What about this patch? It is still missing in QEMU git master.
>>
>> It would appear to suppress quite a few warnings about formats. But on
>> my version of inttypes.h there is the following comment:
>> /* 7.8.1 Macros for format specifiers
>> *
>> * MS runtime does not yet understand C9x standard "ll"
>> * length specifier. It appears to treat "ll" as "l".
>> * The non-standard I64 length specifier causes warning in GCC,
>> * but understood by MS runtime functions.
>> */
>> So is this change OK after all?
>
> Yes, it is. MS runtime indeed does not understand "%lld"
> and similar format specifiers.
>
> Mingw does, because it replaces the printf family functions
> by inline functions which call __mingw_vfprintf as soon
> as __USE_MINGW_ANSI_STDIO is defined. If your MinGW stdio.h
> does not use __USE_MINGW_ANSI_STDIO, it is too old.

Well, mine doesn't. The change was introduced in mingw-runtime 3.15,
which was released in September 2008, but Debian still hasn't updated
from 3.13. Maybe other distros are not so lagging and someone who
wishes to build QEMU on Windows is not pampered with distro support
for MinGW anyway. Perhaps a configure time check should be added?

> QEMU defines __USE_MINGW_ANSI_STDIO, and __mingw_vfprintf
> understands C9x standard length specifiers.

BTW, MinGW FAQ page http://www.mingw.org/wiki/FAQ still mentions that
%ll formats are not supported.

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

* Re: [Qemu-devel]  Re: [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64
  2011-01-30 22:14       ` Blue Swirl
@ 2011-01-31 10:39         ` Mark Cave-Ayland
  2011-01-31 17:25         ` Stefan Weil
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Cave-Ayland @ 2011-01-31 10:39 UTC (permalink / raw)
  To: qemu-devel

On 30/01/11 22:14, Blue Swirl wrote:

> Well, mine doesn't. The change was introduced in mingw-runtime 3.15,
> which was released in September 2008, but Debian still hasn't updated
> from 3.13. Maybe other distros are not so lagging and someone who
> wishes to build QEMU on Windows is not pampered with distro support
> for MinGW anyway. Perhaps a configure time check should be added?

FWIW anyone using MingW now should be using the new GCC 4.5 based builds 
with the associated runtime rather than anything that old. I suspect 
most people using MingW for anything serious will be doing this already.

I think adding the configure check would be the best solution here.

>> QEMU defines __USE_MINGW_ANSI_STDIO, and __mingw_vfprintf
>> understands C9x standard length specifiers.

> BTW, MinGW FAQ page http://www.mingw.org/wiki/FAQ still mentions that
> %ll formats are not supported.

Since MingW uses the MSVCRT then by default it won't accept %ll, but my 
understanding is that Stefan is correct, i.e. defining 
__USE_MINGW_ANSI_STDIO causes MingW to use an internal 
standards-compliant implementation instead of the in-built MSVCRT 
version that *does* understand these extras.


HTH,

Mark.

-- 
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063

Sirius Labs: http://www.siriusit.co.uk/labs

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

* [Qemu-devel] Re: [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64
  2011-01-30 22:14       ` Blue Swirl
  2011-01-31 10:39         ` Mark Cave-Ayland
@ 2011-01-31 17:25         ` Stefan Weil
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Weil @ 2011-01-31 17:25 UTC (permalink / raw)
  To: Blue Swirl; +Cc: QEMU Developers

Am 30.01.2011 23:14, schrieb Blue Swirl:
> On Sun, Jan 30, 2011 at 9:50 PM, Stefan Weil <weil@mail.berlios.de> wrote:
>> Am 30.01.2011 22:39, schrieb Blue Swirl:
>>> It would appear to suppress quite a few warnings about formats. But on
>>> my version of inttypes.h there is the following comment:
>>> /* 7.8.1 Macros for format specifiers
>>> *
>>> * MS runtime does not yet understand C9x standard "ll"
>>> * length specifier. It appears to treat "ll" as "l".
>>> * The non-standard I64 length specifier causes warning in GCC,
>>> * but understood by MS runtime functions.
>>> */
>>> So is this change OK after all?
>>
>> Yes, it is. MS runtime indeed does not understand "%lld"
>> and similar format specifiers.
>>
>> Mingw does, because it replaces the printf family functions
>> by inline functions which call __mingw_vfprintf as soon
>> as __USE_MINGW_ANSI_STDIO is defined. If your MinGW stdio.h
>> does not use __USE_MINGW_ANSI_STDIO, it is too old.
>
> Well, mine doesn't. The change was introduced in mingw-runtime 3.15,
> which was released in September 2008, but Debian still hasn't updated
> from 3.13. Maybe other distros are not so lagging and someone who
> wishes to build QEMU on Windows is not pampered with distro support
> for MinGW anyway. Perhaps a configure time check should be added?
>> QEMU defines __USE_MINGW_ANSI_STDIO, and __mingw_vfprintf
>> understands C9x standard length specifiers.
>
> BTW, MinGW FAQ page http://www.mingw.org/wiki/FAQ still mentions that
> %ll formats are not supported.

The FAQ says
"You should use %I64 instead of %ll when using msvcrt".

=> If you don't use msvcrt for printf, you no longer have to use %I64.

Even with latest versions, MinGW's support for ANSI stdio is still
incomplete - inttypes.h is one example, others are missing
GCC atributes and missing ANSI scanf support.

I'll add a page to QEMU's wiki which lists all changes needed.

Regards,
Stefan

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

end of thread, other threads:[~2011-01-31 17:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-04 19:41 [Qemu-devel] [PATCH] mingw32: Fix definitions for PRId64, PRIx64, PRIu64, PRIo64 Stefan Weil
2011-01-30 21:27 ` [Qemu-devel] " Stefan Weil
2011-01-30 21:39   ` Blue Swirl
2011-01-30 21:50     ` Stefan Weil
2011-01-30 22:14       ` Blue Swirl
2011-01-31 10:39         ` Mark Cave-Ayland
2011-01-31 17:25         ` Stefan Weil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.