From 4cc8a22d8845aee4b26074ae320abf5bdd156e79 Mon Sep 17 00:00:00 2001 From: Rich Evans Date: Tue, 3 Feb 2015 11:26:31 +0000 Subject: [PATCH] add initial symbols to config and checks to check_config to allow use of macros to define standard functions --- include/polarssl/check_config.h | 75 +++++++++++++++++++++++++++++++++ include/polarssl/config.h | 17 ++++++++ 2 files changed, 92 insertions(+) diff --git a/include/polarssl/check_config.h b/include/polarssl/check_config.h index 51745c95e..eb2fecd8d 100644 --- a/include/polarssl/check_config.h +++ b/include/polarssl/check_config.h @@ -198,14 +198,65 @@ #error "POLARSSL_PKCS11_C defined, but not all prerequisites" #endif +#if defined(POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS) &&\ + !defined(POLARSSL_PLATFORM_C) +#error "POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS defined, but not prerequisites" +#endif + #if defined(POLARSSL_PLATFORM_EXIT_ALT) && !defined(POLARSSL_PLATFORM_C) #error "POLARSSL_PLATFORM_EXIT_ALT defined, but not all prerequisites" #endif +#if defined(POLARSSL_PLATFORM_EXIT_MACRO) &&\ + ( !defined(POLARSSL_PLATFORM_C) ||\ + !defined(POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS) ) +#error "POLARSSL_PLATFORM_EXIT_MACRO defined, but not all prerequisites" +#endif + +#if defined(POLARSSL_PLATFORM_EXIT_MACRO) &&\ + ( defined(POLARSSL_PLATFORM_STD_EXIT) ||\ + defined(POLARSSL_PLATFORM_EXIT_ALT) ) +#error "POLARSSL_PLATFORM_EXIT_MACRO and POLARSSL_PLATFORM_STD_EXIT/POLARSSL_PLATFORM_EXIT_ALT cannot be defined simultaneously" +#endif + #if defined(POLARSSL_PLATFORM_FPRINTF_ALT) && !defined(POLARSSL_PLATFORM_C) #error "POLARSSL_PLATFORM_FPRINTF_ALT defined, but not all prerequisites" #endif +#if defined(POLARSSL_PLATFORM_FPRINTF_MACRO) &&\ + ( !defined(POLARSSL_PLATFORM_C) ||\ + !defined(POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS) ) +#error "POLARSSL_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites" +#endif + +#if defined(POLARSSL_PLATFORM_FPRINTF_MACRO) &&\ + ( defined(POLARSSL_PLATFORM_STD_FPRINTF) ||\ + defined(POLARSSL_PLATFORM_FPRINTF_ALT) ) +#error "POLARSSL_PLATFORM_FPRINTF_MACRO and POLARSSL_PLATFORM_STD_FPRINTF/POLARSSL_PLATFORM_FPRINTF_ALT cannot be defined simultaneously" +#endif + +#if defined(POLARSSL_PLATFORM_FREE_MACRO) &&\ + ( !defined(POLARSSL_PLATFORM_C) || !defined(POLARSSL_PLATFORM_MEMORY) ||\ + !defined(POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS) ) +#error "POLARSSL_PLATFORM_FREE_MACRO defined, but not all prerequisites" +#endif + +#if defined(POLARSSL_PLATFORM_FREE_MACRO) &&\ + defined(POLARSSL_PLATFORM_STD_FREE) +#error "POLARSSL_PLATFORM_FREE_MACRO and POLARSSL_PLATFORM_STD_FREE cannot be defined simultaneously" +#endif + +#if defined(POLARSSL_PLATFORM_MALLOC_MACRO) &&\ + ( !defined(POLARSSL_PLATFORM_C) || !defined(POLARSSL_PLATFORM_MEMORY) ||\ + !defined(POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS) ) +#error "POLARSSL_PLATFORM_MALLOC_MACRO defined, but not all prerequisites" +#endif + +#if defined(POLARSSL_PLATFORM_MALLOC_MACRO) &&\ + defined(POLARSSL_PLATFORM_STD_MALLOC) +#error "POLARSSL_PLATFORM_MALLOC_MACRO and POLARSSL_PLATFORM_STD_MALLOC cannot be defined simultaneously" +#endif + #if defined(POLARSSL_PLATFORM_MEMORY) && !defined(POLARSSL_PLATFORM_C) #error "POLARSSL_PLATFORM_MEMORY defined, but not all prerequisites" #endif @@ -214,6 +265,18 @@ #error "POLARSSL_PLATFORM_PRINTF_ALT defined, but not all prerequisites" #endif +#if defined(POLARSSL_PLATFORM_PRINTF_MACRO) &&\ + ( !defined(POLARSSL_PLATFORM_C) ||\ + !defined(POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS) ) +#error "POLARSSL_PLATFORM_PRINTF_MACRO defined, but not all prerequisites" +#endif + +#if defined(POLARSSL_PLATFORM_PRINTF_MACRO) &&\ + ( defined(POLARSSL_PLATFORM_STD_PRINTF) ||\ + defined(POLARSSL_PLATFORM_PRINTF_ALT) ) +#error "POLARSSL_PLATFORM_PRINTF_MACRO and POLARSSL_PLATFORM_STD_PRINTF/POLARSSL_PLATFORM_PRINTF_ALT cannot be defined simultaneously" +#endif + #if defined(POLARSSL_PLATFORM_SNPRINTF_ALT) && !defined(POLARSSL_PLATFORM_C) #error "POLARSSL_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites" #endif @@ -223,6 +286,18 @@ #error "POLARSSL_PLATFORM_SNPRINTF_ALT defined but not available on Windows" #endif +#if defined(POLARSSL_PLATFORM_SNPRINTF_MACRO) &&\ + ( !defined(POLARSSL_PLATFORM_C) ||\ + !defined(POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS) ) +#error "POLARSSL_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites" +#endif + +#if defined(POLARSSL_PLATFORM_SNPRINTF_MACRO) &&\ + ( defined(POLARSSL_PLATFORM_STD_SNPRINTF) ||\ + defined(POLARSSL_PLATFORM_SNPRINTF_ALT) ) +#error "POLARSSL_PLATFORM_SNPRINTF_MACRO and POLARSSL_PLATFORM_STD_SNPRINTF/POLARSSL_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously" +#endif + #if defined(POLARSSL_PLATFORM_STD_MEM_HDR) &&\ !defined(POLARSSL_PLATFORM_NO_STD_FUNCTIONS) #error "POLARSSL_PLATFORM_STD_MEM_HDR defined, but not all prerequisites" diff --git a/include/polarssl/config.h b/include/polarssl/config.h index 7db377e09..6f134401e 100644 --- a/include/polarssl/config.h +++ b/include/polarssl/config.h @@ -147,6 +147,16 @@ */ //#define POLARSSL_PLATFORM_NO_STD_FUNCTIONS +/** + * \def POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS + * + * TO-DO: ADD DESCRIPTION & ANY WARNINGS ETC + * + * Requires: POLARSSL_PLATFORM_C + * + */ +//#define POLARSSL_PLATFORM_ENABLE_FUNCTION_MACROS + /** * \def POLARSSL_PLATFORM_XXX_ALT * @@ -2248,6 +2258,13 @@ //#define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ //#define POLARSSL_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ +//#define POLARSSL_PLATFORM_MALLOC_MACRO malloc /**< Default allocator macro to use, can be undefined */ +//#define POLARSSL_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ +//#define POLARSSL_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ +//#define POLARSSL_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ +//#define POLARSSL_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ +//#define POLARSSL_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ + /* SSL Cache options */ //#define SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ //#define SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */