Fix query_config macro expansion for windows

This commit is contained in:
Andres Amaya Garcia 2018-12-05 10:47:31 +00:00
parent c46ea38f90
commit c500ad8cc0
3 changed files with 309 additions and 307 deletions

File diff suppressed because it is too large Load Diff

View File

@ -106,13 +106,14 @@
#include <string.h> #include <string.h>
/* Helper macros to convert a macro or its expansion into a string */ /*
#if defined(_MSC_VER) * Helper macros to convert a macro or its expansion into a string
#define MACRO_EXPANSION_TO_STR(macro) strlen( #macro ) > 0 ? #macro "\n" : "" * WARNING: This does not work for expanding function-like macros. However,
#else * Mbed TLS does not currently have configuration options used in this fashion.
*/
#define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro) #define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro)
#define MACRO_NAME_TO_STR(macro) strlen( #macro ) > 0 ? #macro "\n" : "" #define MACRO_NAME_TO_STR(macro) \
#endif /* _MSC_VER */ mbedtls_printf( "%s", strlen( #macro "" ) > 0 ? #macro "\n" : "" )
int query_config( const char *config ) int query_config( const char *config )
{ {

View File

@ -39,7 +39,7 @@ while (my $line = <CONFIG_FILE>) {
$config_check .= "#if defined($name)\n"; $config_check .= "#if defined($name)\n";
$config_check .= " if( strcmp( \"$name\", config ) == 0 )\n"; $config_check .= " if( strcmp( \"$name\", config ) == 0 )\n";
$config_check .= " {\n"; $config_check .= " {\n";
$config_check .= " mbedtls_printf( \"%s\", MACRO_EXPANSION_TO_STR( $name ) );\n"; $config_check .= " MACRO_EXPANSION_TO_STR( $name );\n";
$config_check .= " return( 0 );\n"; $config_check .= " return( 0 );\n";
$config_check .= " }\n"; $config_check .= " }\n";
$config_check .= "#endif /* $name */\n"; $config_check .= "#endif /* $name */\n";