qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/4] targphys.h: Define PRI*PLX format specifier


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 1/4] targphys.h: Define PRI*PLX format specifier macros
Date: Mon, 25 Jun 2012 07:31:00 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

On 06/25/2012 06:45 AM, Peter Maydell wrote:
> Define a set of PRI*PLX format specifier macros for working
> with target_phys_addr_t types. These follow the standard pattern
> for such macros, and are more flexible than TARGET_FMT_plx, which
> does not allow specification of field widths.
> 
> Suggested-by: Andreas Färber <address@hidden>
> Signed-off-by: Peter Maydell <address@hidden>
> ---
>  targphys.h |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/targphys.h b/targphys.h
> index 95648d6..d5b5636 100644
> --- a/targphys.h
> +++ b/targphys.h
> @@ -11,10 +11,26 @@
>  typedef uint32_t target_phys_addr_t;
>  #define TARGET_PHYS_ADDR_MAX UINT32_MAX
>  #define TARGET_FMT_plx "%08x"
> +/* Format strings for printing target_phys_addr_t types.
> + * These are recommended over the less flexible TARGET_FMT_plx,
> + * which is retained for the benefit of existing code.
> + */
> +#define PRIdPLX PRId32

This risks collisions with future POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html#tag_13_20

    Macro names beginning with PRI or SCN followed by any lowercase
letter or 'X' may be added to the macros defined in the <inttypes.h> header.

The correct way to do this is to first undefine any potential conflicts,
per this text in
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_01

    If any header in the following table is included, macros with the
prefixes shown may be defined. After the last inclusion of a given
header, an application may use identifiers with the corresponding
prefixes for its own purpose, provided their use is preceded by a #undef
of the corresponding macro.
...
    <inttypes.h> PRI[Xa-z], SCN[Xa-z]

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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