Commit edfb1af5 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r3564: Move mybe{32,64}enc definitions outside of ifdef so we work on 64...

Merge r3564: Move mybe{32,64}enc definitions outside of ifdef so we work on 64 bit BE platforms too.



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@3733 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5153b6ce
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment