From 0bf941c9b25503047be6d01b134f9fe2597423fd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 28 May 2008 10:43:22 -0400 Subject: [PATCH] Add support for byteswap macros bswap_16 and bswap_32 --- configure.in | 2 +- src/cairo-wideint-type-private.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 2ec8f5619..b1a65f989 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/src/cairo-wideint-type-private.h b/src/cairo-wideint-type-private.h index 23e50dfad..aa76766a3 100644 --- a/src/cairo-wideint-type-private.h +++ b/src/cairo-wideint-type-private.h @@ -78,6 +78,22 @@ #error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.) #endif +#if HAVE_BYTESWAP_H +# include +#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