[Pixman] [PATCH 7/7] Add bswap() macros and use them
Jeff Muizelaar
jmuizelaar at mozilla.com
Sat Apr 24 18:45:15 PDT 2010
On 24-Apr-10, at 4:48 PM, Søren Sandmann wrote:
>
> diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
> index d5767af..c4f5064 100644
> --- a/pixman/pixman-private.h
> +++ b/pixman/pixman-private.h
> @@ -686,6 +686,24 @@ pixman_region16_copy_from_region32
> (pixman_region16_t *dst,
>
> +/* Byte swapping */
> +#if HAVE_BYTESWAP_H
> +# include <byteswap.h>
> +#endif
> +#ifndef bswap_16
> +# define bswap_16(p) \
> + (((((uint16_t)(p)) & 0x00ff) << 8) | \
> + (((uint16_t)(p)) >> 8));
> +#endif
> +#ifndef bswap_32
> +# define bswap_32(p) \
> + (((((uint32_t)(p)) & 0x000000ff) << 24) | \
> + ((((uint32_t)(p)) & 0x0000ff00) << 8) | \
> + ((((uint32_t)(p)) & 0x00ff0000) >> 8) | \
> + ((((uint32_t)(p))) >> 24));
> +#endif
These macros reuse their value which makes them prone to bugs like:
cairo: ce3ad6f41edf86ed6914f4d7f364111eba42ca65
We should either use inline functions or trickier macros.
-Jeff
More information about the Pixman
mailing list