[Pixman] [PATCH 7/7] Add bswap() macros and use them

Alan Coopersmith alan.coopersmith at oracle.com
Mon Apr 26 09:05:08 PDT 2010


> +/* 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

If you want to enter the twisty maze of all the platform #ifdefs, since
this is one area where there has been no standardization, the Solaris
equivalent is <sys/byteorder.h> and the macros are BSWAP_16 & BSWAP_32.
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/sys/byteorder.h#103

The xserver's glx/glxbyteorder.h has variants for a few more platforms
(I thought I'd added Solaris in there at some point, but don't see it
 there now - the BSD & MacOS variants are there though.)

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the Pixman mailing list