diff options
author | Christian Heimes <christian@python.org> | 2016-04-22 13:07:57 +0300 |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2016-04-22 13:07:57 +0300 |
commit | 81a1bcf245f8d4ba1d627327b9069559b72d00b1 (patch) | |
tree | f3bc1c75214caab09bbc34b5a30007e981eef773 /sse/blake2-impl.h | |
parent | 02bf34f3d49c205812c34dfce9123a7c74509605 (diff) |
Make BLAKE2 code C89 and MSVC friendly
This patch makes the BLAKE2 reference implementation compatible with C89
compilers and MSVC.
1) Use C comments (/* */) instead of C++ comments.
2) No declarations after statements. All variables are declared on the
top of a block.
3) Optional inline with BLAKE2_LOCAL_INLINE() macro.
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'sse/blake2-impl.h')
-rw-r--r-- | sse/blake2-impl.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sse/blake2-impl.h b/sse/blake2-impl.h index 1b19ba9..bbe3c0f 100644 --- a/sse/blake2-impl.h +++ b/sse/blake2-impl.h @@ -19,7 +19,7 @@ #include <stdint.h> #include <string.h> -static inline uint32_t load32( const void *src ) +BLAKE2_LOCAL_INLINE(uint32_t) load32( const void *src ) { #if defined(NATIVE_LITTLE_ENDIAN) uint32_t w; @@ -35,7 +35,7 @@ static inline uint32_t load32( const void *src ) #endif } -static inline uint64_t load64( const void *src ) +BLAKE2_LOCAL_INLINE(uint64_t) load64( const void *src ) { #if defined(NATIVE_LITTLE_ENDIAN) uint64_t w; @@ -55,7 +55,7 @@ static inline uint64_t load64( const void *src ) #endif } -static inline void store32( void *dst, uint32_t w ) +BLAKE2_LOCAL_INLINE(void) store32( void *dst, uint32_t w ) { #if defined(NATIVE_LITTLE_ENDIAN) memcpy(dst, &w, sizeof w); @@ -68,7 +68,7 @@ static inline void store32( void *dst, uint32_t w ) #endif } -static inline void store64( void *dst, uint64_t w ) +BLAKE2_LOCAL_INLINE(void) store64( void *dst, uint64_t w ) { #if defined(NATIVE_LITTLE_ENDIAN) memcpy(dst, &w, sizeof w); @@ -85,7 +85,7 @@ static inline void store64( void *dst, uint64_t w ) #endif } -static inline uint64_t load48( const void *src ) +BLAKE2_LOCAL_INLINE(uint64_t) load48( const void *src ) { const uint8_t *p = ( const uint8_t * )src; uint64_t w = *p++; @@ -97,7 +97,7 @@ static inline uint64_t load48( const void *src ) return w; } -static inline void store48( void *dst, uint64_t w ) +BLAKE2_LOCAL_INLINE(void) store48( void *dst, uint64_t w ) { uint8_t *p = ( uint8_t * )dst; *p++ = ( uint8_t )w; w >>= 8; @@ -108,28 +108,28 @@ static inline void store48( void *dst, uint64_t w ) *p++ = ( uint8_t )w; } -static inline uint32_t rotl32( const uint32_t w, const unsigned c ) +BLAKE2_LOCAL_INLINE(uint32_t) rotl32( const uint32_t w, const unsigned c ) { return ( w << c ) | ( w >> ( 32 - c ) ); } -static inline uint64_t rotl64( const uint64_t w, const unsigned c ) +BLAKE2_LOCAL_INLINE(uint64_t) rotl64( const uint64_t w, const unsigned c ) { return ( w << c ) | ( w >> ( 64 - c ) ); } -static inline uint32_t rotr32( const uint32_t w, const unsigned c ) +BLAKE2_LOCAL_INLINE(uint32_t) rotr32( const uint32_t w, const unsigned c ) { return ( w >> c ) | ( w << ( 32 - c ) ); } -static inline uint64_t rotr64( const uint64_t w, const unsigned c ) +BLAKE2_LOCAL_INLINE(uint64_t) rotr64( const uint64_t w, const unsigned c ) { return ( w >> c ) | ( w << ( 64 - c ) ); } /* prevents compiler optimizing out memset() */ -static inline void secure_zero_memory(void *v, size_t n) +BLAKE2_LOCAL_INLINE(void) secure_zero_memory(void *v, size_t n) { static void *(*const volatile memset_v)(void *, int, size_t) = &memset; memset_v(v, 0, n); |