[Spice-devel] [PATCH 1/3] protocol: Add macros to help convert QXLPHYSICAL to/from pointers
Frediano Ziglio
fziglio at redhat.com
Wed Dec 30 03:57:13 PST 2015
>
> On 32 bit systems the QXLPHYSICAL integer size deos not match the size
> of a pointer so special care must be taken in the conversions to avoid
> compiler errors with -Werror.
>
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
> ---
> spice/qxl_dev.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
> index 9e753c4..01cfe81 100644
> --- a/spice/qxl_dev.h
> +++ b/spice/qxl_dev.h
> @@ -101,8 +101,10 @@ enum {
> QXL_IO_RANGE_SIZE
> };
>
> -typedef uint64_t QXLPHYSICAL;
> typedef int32_t QXLFIXED; //fixed 28.4
> +typedef uint64_t QXLPHYSICAL;
> +#define PTR_TO_QXLPHYSICAL(ptr) ((QXLPHYSICAL)(intptr_t)ptr)
> +#define QXLPHYSICAL_TO_PTR(ptrtype, phy) ((ptrtype)(intptr_t)phy)
>
> typedef struct SPICE_ATTR_PACKED QXLPointFix {
> QXLFIXED x;
> --
> 2.6.4
Due to operator precedence would be better to enclose parameters inside brackets,
like
#define PTR_TO_QXLPHYSICAL(ptr) ((QXLPHYSICAL)(intptr_t)(ptr))
#define QXLPHYSICAL_TO_PTR(ptrtype, phy) ((ptrtype)(intptr_t)(phy))
Why did you change type definition order? I think macro definitions can
be separate from type definition by a space (empty line).
Frediano
More information about the Spice-devel
mailing list