Digest-Luffa
view release on metacpan or search on metacpan
src/sph_types.h view on Meta::CPAN
585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653*
@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
663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695*
@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
706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739*
@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
753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786*
@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
139013911392139313941395139613971398139914001401140214031404140514061407140814091410
((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
142914301431143214331434143514361437143814391440144114421443144414451446144714481449
| ((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
150815091510151115121513151415151516151715181519152015211522152315241525152615271528
((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
15611562156315641565156615671568156915701571157215731574157515761577157815791580
| ((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
166116621663166416651666166716681669167016711672167316741675167616771678167916801681
((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
170817091710171117121713171417151716171717181719172017211722172317241725172617271728
| ((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
180318041805180618071808180918101811181218131814181518161817181818191820182118221823
((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
18581859186018611862186318641865186618671868186918701871187218731874187518761877
| ((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.238 second using v1.01-cache-2.11-cpan-ec4f86ec37b )