From c6d09edc5c7cf443ad84ddeb5520ea7955ac09cc Mon Sep 17 00:00:00 2001 From: tfheen Date: Fri, 30 Jan 2009 14:40:32 +0000 Subject: [PATCH] Move mybe{32,64}enc definitions outside of ifdef so we work on 64 bit BE platforms too. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3564 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/lib/libvarnish/vsha256.c | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/varnish-cache/lib/libvarnish/vsha256.c b/varnish-cache/lib/libvarnish/vsha256.c index 0857de71..ec750fe5 100644 --- a/varnish-cache/lib/libvarnish/vsha256.c +++ b/varnish-cache/lib/libvarnish/vsha256.c @@ -45,26 +45,6 @@ #include "libvarnish.h" #include "vsha256.h" -#if defined(VBYTE_ORDER) && VBYTE_ORDER == VBIG_ENDIAN - -/* Copy a vector of big-endian uint32_t into a vector of bytes */ -#define be32enc_vect(dst, src, len) \ - memcpy((void *)dst, (const void *)src, (size_t)len) - -/* Copy a vector of bytes into a vector of big-endian uint32_t */ -#define be32dec_vect(dst, src, len) \ - memcpy((void *)dst, (const void *)src, (size_t)len) - -#else /* BYTE_ORDER != BIG_ENDIAN or in doubt... */ - -static __inline uint32_t -mybe32dec(const void *pp) -{ - unsigned char const *p = (unsigned char const *)pp; - - return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); -} - static __inline void mybe32enc(void *pp, uint32_t u) { @@ -85,6 +65,26 @@ mybe64enc(void *pp, uint64_t u) mybe32enc(p + 4, u & 0xffffffff); } +#if defined(VBYTE_ORDER) && VBYTE_ORDER == VBIG_ENDIAN + +/* Copy a vector of big-endian uint32_t into a vector of bytes */ +#define be32enc_vect(dst, src, len) \ + memcpy((void *)dst, (const void *)src, (size_t)len) + +/* Copy a vector of bytes into a vector of big-endian uint32_t */ +#define be32dec_vect(dst, src, len) \ + memcpy((void *)dst, (const void *)src, (size_t)len) + +#else /* BYTE_ORDER != BIG_ENDIAN or in doubt... */ + +static __inline uint32_t +mybe32dec(const void *pp) +{ + unsigned char const *p = (unsigned char const *)pp; + + return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); +} + /* * Encode a length len/4 vector of (uint32_t) into a length len vector of * (unsigned char) in big-endian form. Assumes len is a multiple of 4. -- 2.39.5