Add support for byteswap macros bswap_16 and bswap_32

This commit is contained in:
Behdad Esfahbod 2008-05-28 10:43:22 -04:00
parent 5c732badbc
commit 0bf941c9b2
2 changed files with 17 additions and 1 deletions

View file

@ -745,7 +745,7 @@ CAIROPERF_LIBS=$RT_LIBS
dnl ===========================================================================
dnl Checks for misc headers
AC_CHECK_HEADERS([libgen.h])
AC_CHECK_HEADERS([libgen.h byteswap.h])
dnl ===========================================================================
dnl check compiler flags

View file

@ -78,6 +78,22 @@
#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
#endif
#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
#if !HAVE_UINT64_T