From c5c9eb474140d45679ec5181bd73eb084b2d09ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Thu, 27 May 2021 23:31:30 +0200 Subject: [PATCH] Move preprocessor logic to build_info.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- configs/config-ccm-psk-tls1_2.h | 6 ----- configs/config-no-entropy.h | 7 ------ configs/config-suite-b.h | 7 ------ configs/config-symmetric-only.h | 9 -------- configs/config-thread.h | 7 ------ include/mbedtls/build_info.h | 19 ++++++++++++++++ include/mbedtls/config.h | 24 -------------------- tests/configs/config-wrapper-malloc-0-null.h | 5 ---- 8 files changed, 19 insertions(+), 65 deletions(-) diff --git a/configs/config-ccm-psk-tls1_2.h b/configs/config-ccm-psk-tls1_2.h index a82950190..51bb96291 100644 --- a/configs/config-ccm-psk-tls1_2.h +++ b/configs/config-ccm-psk-tls1_2.h @@ -29,8 +29,6 @@ * * See README.txt for usage instructions. */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H /* System support */ //#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */ @@ -85,7 +83,3 @@ */ #define MBEDTLS_SSL_IN_CONTENT_LEN 1024 #define MBEDTLS_SSL_OUT_CONTENT_LEN 1024 - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/configs/config-no-entropy.h b/configs/config-no-entropy.h index 7ca33c381..edba4a078 100644 --- a/configs/config-no-entropy.h +++ b/configs/config-no-entropy.h @@ -29,9 +29,6 @@ * See README.txt for usage instructions. */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - /* System support */ #define MBEDTLS_HAVE_ASM #define MBEDTLS_HAVE_TIME @@ -86,7 +83,3 @@ /* Miscellaneous options */ #define MBEDTLS_AES_ROM_TABLES - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/configs/config-suite-b.h b/configs/config-suite-b.h index b62bdfabd..c70773d63 100644 --- a/configs/config-suite-b.h +++ b/configs/config-suite-b.h @@ -33,9 +33,6 @@ * See README.txt for usage instructions. */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - /* System support */ #define MBEDTLS_HAVE_ASM #define MBEDTLS_HAVE_TIME @@ -113,7 +110,3 @@ */ #define MBEDTLS_SSL_IN_CONTENT_LEN 1024 #define MBEDTLS_SSL_OUT_CONTENT_LEN 1024 - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/configs/config-symmetric-only.h b/configs/config-symmetric-only.h index 5b1006327..6aff42f1c 100644 --- a/configs/config-symmetric-only.h +++ b/configs/config-symmetric-only.h @@ -20,9 +20,6 @@ * limitations under the License. */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - /* System support */ //#define MBEDTLS_HAVE_ASM #define MBEDTLS_HAVE_TIME @@ -90,9 +87,3 @@ //#define MBEDTLS_THREADING_C #define MBEDTLS_TIMING_C #define MBEDTLS_VERSION_C - -#include "mbedtls/config_psa.h" - -#include "check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/configs/config-thread.h b/configs/config-thread.h index c1937de80..be889a187 100644 --- a/configs/config-thread.h +++ b/configs/config-thread.h @@ -32,9 +32,6 @@ * See README.txt for usage instructions. */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - /* System support */ #define MBEDTLS_HAVE_ASM @@ -89,7 +86,3 @@ /* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */ #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/include/mbedtls/build_info.h b/include/mbedtls/build_info.h index 8e6b0b83f..ad6d394c3 100644 --- a/include/mbedtls/build_info.h +++ b/include/mbedtls/build_info.h @@ -26,10 +26,29 @@ #ifndef MBEDTLS_BUILD_INFO_H #define MBEDTLS_BUILD_INFO_H +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else #include MBEDTLS_CONFIG_FILE #endif +/* Target and application specific configurations + * + * Allow user to override any previous default. + * + */ +#if defined(MBEDTLS_USER_CONFIG_FILE) +#include MBEDTLS_USER_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PSA_CRYPTO_CONFIG) +#include "mbedtls/config_psa.h" +#endif + +#include "mbedtls/check_config.h" + #endif /* MBEDTLS_BUILD_INFO_H */ diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index 47605f9e2..f874ae235 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -24,13 +24,6 @@ * limitations under the License. */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif - /** * \name SECTION: System support * @@ -3263,20 +3256,3 @@ //#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED /* \} name SECTION: Customisation configuration options */ - -/* Target and application specific configurations - * - * Allow user to override any previous default. - * - */ -#if defined(MBEDTLS_USER_CONFIG_FILE) -#include MBEDTLS_USER_CONFIG_FILE -#endif - -#if defined(MBEDTLS_PSA_CRYPTO_CONFIG) -#include "mbedtls/config_psa.h" -#endif - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/tests/configs/config-wrapper-malloc-0-null.h b/tests/configs/config-wrapper-malloc-0-null.h index 69a9578c6..4c4f3bfcd 100644 --- a/tests/configs/config-wrapper-malloc-0-null.h +++ b/tests/configs/config-wrapper-malloc-0-null.h @@ -18,9 +18,6 @@ * limitations under the License. */ -#ifndef MBEDTLS_CONFIG_H -/* Don't #define MBEDTLS_CONFIG_H, let config.h do it. */ - #include "mbedtls/config.h" #include @@ -33,5 +30,3 @@ static inline void *custom_calloc( size_t nmemb, size_t size ) #define MBEDTLS_PLATFORM_MEMORY #define MBEDTLS_PLATFORM_STD_CALLOC custom_calloc - -#endif /* MBEDTLS_CONFIG_H */