diff options
Diffstat (limited to 'sse/blake2-impl.h')
-rw-r--r-- | sse/blake2-impl.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sse/blake2-impl.h b/sse/blake2-impl.h index 03df0b5..ad9089e 100644 --- a/sse/blake2-impl.h +++ b/sse/blake2-impl.h @@ -64,6 +64,30 @@ static BLAKE2_INLINE uint64_t load64( const void *src ) #endif } +static BLAKE2_INLINE uint16_t load16( const void *src ) +{ +#if defined(NATIVE_LITTLE_ENDIAN) + uint16_t w; + memcpy(&w, src, sizeof w); + return w; +#else + const uint8_t *p = ( const uint8_t * )src; + return (( uint16_t )( p[0] ) << 0) | + (( uint16_t )( p[1] ) << 8) ; +#endif +} + +static BLAKE2_INLINE void store16( void *dst, uint16_t w ) +{ +#if defined(NATIVE_LITTLE_ENDIAN) + memcpy(dst, &w, sizeof w); +#else + uint8_t *p = ( uint8_t * )dst; + *p++ = ( uint8_t )w; w >>= 8; + *p++ = ( uint8_t )w; +#endif +} + static BLAKE2_INLINE void store32( void *dst, uint32_t w ) { #if defined(NATIVE_LITTLE_ENDIAN) |