Skip to content

Commit

Permalink
Fix byteswap.h and 64bit fallback macro
Browse files Browse the repository at this point in the history
Forgot to define bswap macros with GNU byteswap.h
Fixed bswap_64 fallback.
  • Loading branch information
Reini Urban committed Sep 9, 2012
1 parent 775883a commit b0ab7d2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions include/parrot/bswap.h
Expand Up @@ -7,6 +7,11 @@

#ifdef HAS_HEADER_BYTESWAP
# include <byteswap.h> /* GNU */
# define bswap_16(x) __bswap_16(x)
# define bswap_32(x) __bswap_32(x)
# if __WORDSIZE == 64
# define bswap_64(x) __bswap_64(x)
# endif
#else
# ifdef HAS_HEADER_ENDIAN /* linux */
# include <endian.h>
Expand Down Expand Up @@ -75,7 +80,8 @@
# else
# define bswap_64(x) ({ \
unsigned char rb[16]; \
SWAB_16(rb,(const unsigned char *)x); \
const unsigned char *c = &x; \
SWAB_16(rb,c); \
memcpy(x,rb,16); })
# endif
# endif
Expand Down Expand Up @@ -178,11 +184,12 @@ static inline Parrot_UInt4 bswap32(Parrot_UInt4 x)

static inline Parrot_UInt8 bswap64(Parrot_UInt8 x)
{
#ifdef bswap_64
#if defined(bswap_64)
return bswap_64(x);
#else
unsigned char rb[16];
SWAB_16(rb,(const unsigned char *)x);
const unsigned char *c = &x;
SWAB_16(rb, c);
return rb;
#endif
}
Expand Down

0 comments on commit b0ab7d2

Please sign in to comment.