diff --git a/ChangeLog b/ChangeLog index cba56d4aa..8fbdabf4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -45,6 +45,10 @@ Features speed and RAM (heap only for now) usage. * New script memory.sh helps measuring the ROM and RAM requirements of two reduced configurations (PSK-CCM and NSA suite B). + * Add config flags POLARSSL_DEPRECATED_WARNING (off by default) to produce + warnings on use of deprecated functions (with GCC and Clang only). + * Add config flags POLARSSL_DEPRECATED_REMOVED (off by default) to produce + errors on use of deprecated functions. Bugfix * Fix hardclock() (only used in the benchmarking program) with some diff --git a/include/mbedtls/check_config.h b/include/mbedtls/check_config.h index 5369d88e7..de88ae29a 100644 --- a/include/mbedtls/check_config.h +++ b/include/mbedtls/check_config.h @@ -30,6 +30,11 @@ #ifndef POLARSSL_CHECK_CONFIG_H #define POLARSSL_CHECK_CONFIG_H +#if defined(POLARSSL_DEPRECATED_WARNING) && \ + !defined(__GCC__) && !defined(__clang__) +#error "POLARSSL_DEPRECATED_WARNING only works with GCC and Clang" +#endif + #if defined(POLARSSL_AESNI_C) && !defined(POLARSSL_HAVE_ASM) #error "POLARSSL_AESNI_C defined, but not all prerequisites" #endif diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index bee898cec..8b2a858e4 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -179,6 +179,34 @@ //#define POLARSSL_PLATFORM_FPRINTF_ALT //#define POLARSSL_PLATFORM_PRINTF_ALT //#define POLARSSL_PLATFORM_SNPRINTF_ALT + +/** + * \def POLARSSL_DEPRECATED_WARNING + * + * Mark deprecated functions so that they generate a warning if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * This only works with GCC and Clang. With other compilers, you may want to + * use POLARSSL_DEPRECATED_REMOVED + * + * Uncomment to get warnings on using deprecated functions. + */ +//#define POLARSSL_DEPRECATED_WARNING + +/** + * \def POLARSSL_DEPRECATED_REMOVED + * + * Remove deprecated functions so that they generate an error if used. + * Functions deprecated in one version will usually be removed in the next + * version. You can enable this to help you prepare the transition to a new + * major version by making sure your code is not using these functions. + * + * Uncomment to get errors on using deprecated functions. + */ +//#define POLARSSL_DEPRECATED_REMOVED + /* \} name SECTION: System support */ /** diff --git a/library/version_features.c b/library/version_features.c index a1c260e20..747fc9204 100644 --- a/library/version_features.c +++ b/library/version_features.c @@ -78,6 +78,12 @@ static const char *features[] = { #if defined(POLARSSL_PLATFORM_SNPRINTF_ALT) "POLARSSL_PLATFORM_SNPRINTF_ALT", #endif /* POLARSSL_PLATFORM_SNPRINTF_ALT */ +#if defined(POLARSSL_DEPRECATED_WARNING) + "POLARSSL_DEPRECATED_WARNING", +#endif /* POLARSSL_DEPRECATED_WARNING */ +#if defined(POLARSSL_DEPRECATED_REMOVED) + "POLARSSL_DEPRECATED_REMOVED", +#endif /* POLARSSL_DEPRECATED_REMOVED */ #if defined(POLARSSL_TIMING_ALT) "POLARSSL_TIMING_ALT", #endif /* POLARSSL_TIMING_ALT */ diff --git a/tests/scripts/generate_code.pl b/tests/scripts/generate_code.pl index 6d5d0055c..5b7f2893e 100755 --- a/tests/scripts/generate_code.pl +++ b/tests/scripts/generate_code.pl @@ -50,8 +50,9 @@ my %mapping_values; while (@var_req_arr) { my $req = shift @var_req_arr; + $req =~ s/(!?)(.*)/$1defined($2)/; - $suite_pre_code .= "#ifdef $req\n"; + $suite_pre_code .= "#if $req\n"; $suite_post_code .= "#endif /* $req */\n"; }