mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 12:15:41 +01:00
Use static inline function unconditionally
No need to play tricks with macros and functions depending on whether SHA256_SMALLER is enabled or not, with a static inline function all common compilers (tested with arm-gcc, armcc5, arm-clang) will Do The Right Thing depending on whether we told them to optimize for size or speed.
This commit is contained in:
parent
100c057d0d
commit
c7abba3796
@ -56,7 +56,7 @@
|
||||
#if !defined(MBEDTLS_SHA256_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
* 32-bit integer manipulation (big endian)
|
||||
*/
|
||||
#ifndef GET_UINT32_BE
|
||||
#define GET_UINT32_BE(n,b,i) \
|
||||
@ -68,24 +68,15 @@ do { \
|
||||
} while( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef PUT_UINT32_BE
|
||||
#define PUT_UINT32_BE(n,b,i) \
|
||||
do { \
|
||||
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
|
||||
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
|
||||
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
|
||||
(b)[(i) + 3] = (unsigned char) ( (n) ); \
|
||||
} while( 0 )
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_SMALLER)
|
||||
static void sha256_put_uint32_be( uint32_t n, unsigned char *b, uint8_t i )
|
||||
static inline void sha256_put_uint32_be( uint32_t n,
|
||||
unsigned char *b,
|
||||
uint8_t i )
|
||||
{
|
||||
PUT_UINT32_BE(n, b, i);
|
||||
b[i ] = (unsigned char) ( n >> 24 );
|
||||
b[i + 1] = (unsigned char) ( n >> 16 );
|
||||
b[i + 2] = (unsigned char) ( n >> 8 );
|
||||
b[i + 3] = (unsigned char) ( n );
|
||||
}
|
||||
#else
|
||||
#define sha256_put_uint32_be PUT_UINT32_BE
|
||||
#endif
|
||||
|
||||
void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user