Merge pull request #1352 from dgarske/freertos_static

Fix to allow `FREERTOS` and `WOLFSSL_STATIC_MEMORY`
This commit is contained in:
toddouska
2018-02-07 10:06:51 -08:00
committed by GitHub
3 changed files with 25 additions and 18 deletions

View File

@@ -533,7 +533,11 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
} }
#else #else
#ifndef WOLFSSL_NO_MALLOC #ifndef WOLFSSL_NO_MALLOC
res = malloc(size); #ifdef FREERTOS
res = pvPortMalloc(size);
#else
res = malloc(size);
#endif
#else #else
WOLFSSL_MSG("No heap hint found to use and no malloc"); WOLFSSL_MSG("No heap hint found to use and no malloc");
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
@@ -667,7 +671,11 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
} }
#endif #endif
#ifndef WOLFSSL_NO_MALLOC #ifndef WOLFSSL_NO_MALLOC
free(ptr); #ifdef FREERTOS
vPortFree(ptr);
#else
free(ptr);
#endif
#else #else
WOLFSSL_MSG("Error trying to call free when turned off"); WOLFSSL_MSG("Error trying to call free when turned off");
#endif /* WOLFSSL_NO_MALLOC */ #endif /* WOLFSSL_NO_MALLOC */

View File

@@ -543,7 +543,8 @@ extern void uITRON4_free(void *p) ;
#include "FreeRTOS.h" #include "FreeRTOS.h"
/* FreeRTOS pvPortRealloc() only in AVR32_UC3 port */ /* FreeRTOS pvPortRealloc() only in AVR32_UC3 port */
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
!defined(WOLFSSL_STATIC_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s)) #define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p)) #define XFREE(p, h, type) vPortFree((p))
#endif #endif
@@ -574,20 +575,19 @@ extern void uITRON4_free(void *p) ;
#endif #endif
#ifdef FREERTOS_TCP #ifdef FREERTOS_TCP
#if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER) && \
!defined(WOLFSSL_STATIC_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#endif
#if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER) #define WOLFSSL_GENSEED_FORTEST
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#endif
#define WOLFSSL_GENSEED_FORTEST
#define NO_WOLFSSL_DIR
#define NO_WRITEV
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_MAIN_DRIVER
#define NO_WOLFSSL_DIR
#define NO_WRITEV
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_MAIN_DRIVER
#endif #endif
#ifdef WOLFSSL_TIRTOS #ifdef WOLFSSL_TIRTOS

View File

@@ -233,8 +233,7 @@
#elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \ #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \
&& !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \ && !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \
&& !defined(FREESCALE_KSDK_MQX) && !defined(FREESCALE_FREE_RTOS) \ && !defined(FREESCALE_KSDK_MQX) && !defined(FREESCALE_FREE_RTOS) \
&& !defined(WOLFSSL_LEANPSK) && !defined(FREERTOS) && !defined(FREERTOS_TCP)\ && !defined(WOLFSSL_LEANPSK) && !defined(WOLFSSL_uITRON4)
&& !defined(WOLFSSL_uITRON4)
/* default C runtime, can install different routines at runtime via cbs */ /* default C runtime, can install different routines at runtime via cbs */
#include <wolfssl/wolfcrypt/memory.h> #include <wolfssl/wolfcrypt/memory.h>
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
@@ -247,7 +246,7 @@
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t));} #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t));}
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t)) #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t))
#endif /* WOLFSSL_DEBUG_MEMORY */ #endif /* WOLFSSL_DEBUG_MEMORY */
#else #elif !defined(FREERTOS) && !defined(FREERTOS_TCP)
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s), __func__, __LINE__)) #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s), __func__, __LINE__))
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), __func__, __LINE__);} #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), __func__, __LINE__);}