Digest-Fugue
view release on metacpan or search on metacpan
src/sph_types.h view on Meta::CPAN
* @param x the 64-bit value to byte-swap
* @return the byte-swapped value
*/
static inline sph_u64 sph_bswap64(sph_u64 x);
/**
* Decode a 16-bit unsigned value from memory, in little-endian convention
* (least significant byte comes first).
*
* @param src the source address
* @return the decoded value
*/
static inline unsigned sph_dec16le(const void *src);
/**
* Encode a 16-bit unsigned value into memory, in little-endian convention
* (least significant byte comes first).
*
* @param dst the destination buffer
* @param val the value to encode
*/
static inline void sph_enc16le(void *dst, unsigned val);
/**
* Decode a 16-bit unsigned value from memory, in big-endian convention
* (most significant byte comes first).
*
* @param src the source address
* @return the decoded value
*/
static inline unsigned sph_dec16be(const void *src);
/**
* Encode a 16-bit unsigned value into memory, in big-endian convention
* (most significant byte comes first).
*
* @param dst the destination buffer
* @param val the value to encode
*/
static inline void sph_enc16be(void *dst, unsigned val);
/**
* Decode a 32-bit unsigned value from memory, in little-endian convention
* (least significant byte comes first).
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u32 sph_dec32le(const void *src);
/**
* Decode a 32-bit unsigned value from memory, in little-endian convention
* (least significant byte comes first). This function assumes that the
* source address is suitably aligned for a direct access, if the platform
* supports such things; it can thus be marginally faster than the generic
* <code>sph_dec32le()</code> function.
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u32 sph_dec32le_aligned(const void *src);
/**
* Encode a 32-bit unsigned value into memory, in little-endian convention
* (least significant byte comes first).
*
* @param dst the destination buffer
* @param val the value to encode
*/
src/sph_types.h view on Meta::CPAN
* @param dst the destination buffer
* @param val the value to encode
*/
static inline void sph_enc32le_aligned(void *dst, sph_u32 val);
/**
* Decode a 32-bit unsigned value from memory, in big-endian convention
* (most significant byte comes first).
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u32 sph_dec32be(const void *src);
/**
* Decode a 32-bit unsigned value from memory, in big-endian convention
* (most significant byte comes first). This function assumes that the
* source address is suitably aligned for a direct access, if the platform
* supports such things; it can thus be marginally faster than the generic
* <code>sph_dec32be()</code> function.
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u32 sph_dec32be_aligned(const void *src);
/**
* Encode a 32-bit unsigned value into memory, in big-endian convention
* (most significant byte comes first).
*
* @param dst the destination buffer
* @param val the value to encode
*/
src/sph_types.h view on Meta::CPAN
* @param val the value to encode
*/
static inline void sph_enc32be_aligned(void *dst, sph_u32 val);
/**
* Decode a 64-bit unsigned value from memory, in little-endian convention
* (least significant byte comes first). This function is defined only
* if a suitable 64-bit type was detected and used for <code>sph_u64</code>.
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u64 sph_dec64le(const void *src);
/**
* Decode a 64-bit unsigned value from memory, in little-endian convention
* (least significant byte comes first). This function assumes that the
* source address is suitably aligned for a direct access, if the platform
* supports such things; it can thus be marginally faster than the generic
* <code>sph_dec64le()</code> function. This function is defined only
* if a suitable 64-bit type was detected and used for <code>sph_u64</code>.
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u64 sph_dec64le_aligned(const void *src);
/**
* Encode a 64-bit unsigned value into memory, in little-endian convention
* (least significant byte comes first). This function is defined only
* if a suitable 64-bit type was detected and used for <code>sph_u64</code>.
*
* @param dst the destination buffer
* @param val the value to encode
src/sph_types.h view on Meta::CPAN
* @param val the value to encode
*/
static inline void sph_enc64le_aligned(void *dst, sph_u64 val);
/**
* Decode a 64-bit unsigned value from memory, in big-endian convention
* (most significant byte comes first). This function is defined only
* if a suitable 64-bit type was detected and used for <code>sph_u64</code>.
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u64 sph_dec64be(const void *src);
/**
* Decode a 64-bit unsigned value from memory, in big-endian convention
* (most significant byte comes first). This function assumes that the
* source address is suitably aligned for a direct access, if the platform
* supports such things; it can thus be marginally faster than the generic
* <code>sph_dec64be()</code> function. This function is defined only
* if a suitable 64-bit type was detected and used for <code>sph_u64</code>.
*
* @param src the source address
* @return the decoded value
*/
static inline sph_u64 sph_dec64be_aligned(const void *src);
/**
* Encode a 64-bit unsigned value into memory, in big-endian convention
* (most significant byte comes first). This function is defined only
* if a suitable 64-bit type was detected and used for <code>sph_u64</code>.
*
* @param dst the destination buffer
* @param val the value to encode
src/sph_types.h view on Meta::CPAN
((unsigned char *)dst)[1] = (val >> 16);
((unsigned char *)dst)[2] = (val >> 8);
((unsigned char *)dst)[3] = val;
#endif
}
/**
* Decode a 32-bit value from the provided buffer (big endian convention).
*
* @param src the source buffer
* @return the decoded value
*/
static SPH_INLINE sph_u32
sph_dec32be(const void *src)
{
#if defined SPH_UPTR
#if SPH_UNALIGNED
#if SPH_LITTLE_ENDIAN
return sph_bswap32(*(const sph_u32 *)src);
#else
return *(const sph_u32 *)src;
src/sph_types.h view on Meta::CPAN
| ((sph_u32)(((const unsigned char *)src)[2]) << 8)
| (sph_u32)(((const unsigned char *)src)[3]);
#endif
}
/**
* Decode a 32-bit value from the provided buffer (big endian convention).
* The source buffer must be properly aligned.
*
* @param src the source buffer (32-bit aligned)
* @return the decoded value
*/
static SPH_INLINE sph_u32
sph_dec32be_aligned(const void *src)
{
#if SPH_LITTLE_ENDIAN
return sph_bswap32(*(const sph_u32 *)src);
#elif SPH_BIG_ENDIAN
return *(const sph_u32 *)src;
#else
return ((sph_u32)(((const unsigned char *)src)[0]) << 24)
src/sph_types.h view on Meta::CPAN
((unsigned char *)dst)[1] = (val >> 8);
((unsigned char *)dst)[2] = (val >> 16);
((unsigned char *)dst)[3] = (val >> 24);
#endif
}
/**
* Decode a 32-bit value from the provided buffer (little endian convention).
*
* @param src the source buffer
* @return the decoded value
*/
static SPH_INLINE sph_u32
sph_dec32le(const void *src)
{
#if defined SPH_UPTR
#if SPH_UNALIGNED
#if SPH_BIG_ENDIAN
return sph_bswap32(*(const sph_u32 *)src);
#else
return *(const sph_u32 *)src;
src/sph_types.h view on Meta::CPAN
| ((sph_u32)(((const unsigned char *)src)[2]) << 16)
| ((sph_u32)(((const unsigned char *)src)[3]) << 24);
#endif
}
/**
* Decode a 32-bit value from the provided buffer (little endian convention).
* The source buffer must be properly aligned.
*
* @param src the source buffer (32-bit aligned)
* @return the decoded value
*/
static SPH_INLINE sph_u32
sph_dec32le_aligned(const void *src)
{
#if SPH_LITTLE_ENDIAN
return *(const sph_u32 *)src;
#elif SPH_BIG_ENDIAN
#if SPH_SPARCV9_GCC && !SPH_NO_ASM
sph_u32 tmp;
src/sph_types.h view on Meta::CPAN
((unsigned char *)dst)[5] = (val >> 16);
((unsigned char *)dst)[6] = (val >> 8);
((unsigned char *)dst)[7] = val;
#endif
}
/**
* Decode a 64-bit value from the provided buffer (big endian convention).
*
* @param src the source buffer
* @return the decoded value
*/
static SPH_INLINE sph_u64
sph_dec64be(const void *src)
{
#if defined SPH_UPTR
#if SPH_UNALIGNED
#if SPH_LITTLE_ENDIAN
return sph_bswap64(*(const sph_u64 *)src);
#else
return *(const sph_u64 *)src;
src/sph_types.h view on Meta::CPAN
| ((sph_u64)(((const unsigned char *)src)[6]) << 8)
| (sph_u64)(((const unsigned char *)src)[7]);
#endif
}
/**
* Decode a 64-bit value from the provided buffer (big endian convention).
* The source buffer must be properly aligned.
*
* @param src the source buffer (64-bit aligned)
* @return the decoded value
*/
static SPH_INLINE sph_u64
sph_dec64be_aligned(const void *src)
{
#if SPH_LITTLE_ENDIAN
return sph_bswap64(*(const sph_u64 *)src);
#elif SPH_BIG_ENDIAN
return *(const sph_u64 *)src;
#else
return ((sph_u64)(((const unsigned char *)src)[0]) << 56)
src/sph_types.h view on Meta::CPAN
((unsigned char *)dst)[5] = (val >> 40);
((unsigned char *)dst)[6] = (val >> 48);
((unsigned char *)dst)[7] = (val >> 56);
#endif
}
/**
* Decode a 64-bit value from the provided buffer (little endian convention).
*
* @param src the source buffer
* @return the decoded value
*/
static SPH_INLINE sph_u64
sph_dec64le(const void *src)
{
#if defined SPH_UPTR
#if SPH_UNALIGNED
#if SPH_BIG_ENDIAN
return sph_bswap64(*(const sph_u64 *)src);
#else
return *(const sph_u64 *)src;
src/sph_types.h view on Meta::CPAN
| ((sph_u64)(((const unsigned char *)src)[6]) << 48)
| ((sph_u64)(((const unsigned char *)src)[7]) << 56);
#endif
}
/**
* Decode a 64-bit value from the provided buffer (little endian convention).
* The source buffer must be properly aligned.
*
* @param src the source buffer (64-bit aligned)
* @return the decoded value
*/
static SPH_INLINE sph_u64
sph_dec64le_aligned(const void *src)
{
#if SPH_LITTLE_ENDIAN
return *(const sph_u64 *)src;
#elif SPH_BIG_ENDIAN
#if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM
sph_u64 tmp;
( run in 0.232 second using v1.01-cache-2.11-cpan-26ccb49234f )