From cb0f2c449111a2071a70b26d27ad58c40444832b Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Fri, 23 Dec 2022 13:15:37 +0000 Subject: [PATCH] Tidy-up - move asm #define into build_info.h Signed-off-by: Dave Rodgman --- include/mbedtls/build_info.h | 7 +++++++ include/mbedtls/mbedtls_config.h | 3 +++ library/aesni.c | 6 ------ library/bn_mul.h | 4 ---- library/padlock.c | 6 ------ library/sha256.c | 6 ------ library/sha512.c | 12 ------------ 7 files changed, 10 insertions(+), 34 deletions(-) diff --git a/include/mbedtls/build_info.h b/include/mbedtls/build_info.h index bbfd5d48df..413d5c277e 100644 --- a/include/mbedtls/build_info.h +++ b/include/mbedtls/build_info.h @@ -59,6 +59,13 @@ #define inline __inline #endif +/* Define `asm` for compilers which don't define it. */ +/* *INDENT-OFF* */ +#ifndef asm +#define asm __asm__ +#endif +/* *INDENT-ON* */ + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/mbedtls_config.h" #else diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index 11c3139bd4..2a2c039d76 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -48,8 +48,11 @@ * Requires support for asm() in compiler. * * Used in: + * library/aesni.h * library/aria.c * library/bn_mul.h + * library/constant_time.c + * library/padlock.h * * Required by: * MBEDTLS_AESNI_C diff --git a/library/aesni.c b/library/aesni.c index d4abb4d6cb..f6b304d157 100644 --- a/library/aesni.c +++ b/library/aesni.c @@ -37,12 +37,6 @@ #include -/* *INDENT-OFF* */ -#ifndef asm -#define asm __asm -#endif -/* *INDENT-ON* */ - #if defined(MBEDTLS_HAVE_X86_64) /* diff --git a/library/bn_mul.h b/library/bn_mul.h index 307c2418ff..ab59fbd64f 100644 --- a/library/bn_mul.h +++ b/library/bn_mul.h @@ -83,10 +83,6 @@ /* *INDENT-OFF* */ #if defined(MBEDTLS_HAVE_ASM) -#ifndef asm -#define asm __asm -#endif - /* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */ #if defined(__GNUC__) && \ ( !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000 ) diff --git a/library/padlock.c b/library/padlock.c index b6c6919cd1..f42c40ff93 100644 --- a/library/padlock.c +++ b/library/padlock.c @@ -31,12 +31,6 @@ #include -/* *INDENT-OFF* */ -#ifndef asm -#define asm __asm -#endif -/* *INDENT-ON* */ - #if defined(MBEDTLS_HAVE_X86) /* diff --git a/library/sha256.c b/library/sha256.c index 16fd20d8cd..cb09a71ec1 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -89,12 +89,6 @@ static int mbedtls_a64_crypto_sha256_determine_support(void) #include #include -/* *INDENT-OFF* */ -#ifndef asm -#define asm __asm__ -#endif -/* *INDENT-ON* */ - static jmp_buf return_from_sigill; /* diff --git a/library/sha512.c b/library/sha512.c index 0ea64218b2..efcbed413f 100644 --- a/library/sha512.c +++ b/library/sha512.c @@ -104,12 +104,6 @@ static int mbedtls_a64_crypto_sha512_determine_support(void) #include #include -/* *INDENT-OFF* */ -#ifndef asm -#define asm __asm__ -#endif -/* *INDENT-ON* */ - static jmp_buf return_from_sigill; /* @@ -300,12 +294,6 @@ static const uint64_t K[80] = # define mbedtls_internal_sha512_process_a64_crypto mbedtls_internal_sha512_process #endif -/* *INDENT-OFF* */ -#ifndef asm -#define asm __asm__ -#endif -/* *INDENT-ON* */ - /* Accelerated SHA-512 implementation originally written by Simon Tatham for PuTTY, * under the MIT licence; dual-licensed as Apache 2 with his kind permission. */