From ec0a4d45cb0647c60e0c896a7d09516aac2ce2ea Mon Sep 17 00:00:00 2001 From: toddouska Date: Tue, 12 Mar 2013 13:31:14 -0700 Subject: [PATCH] add --enable-memory, build, disable runtime memory cbs, check leanpsk --- configure.ac | 23 +++++++++++++++++++++++ cyassl/ctaocrypt/settings.h | 2 +- cyassl/ctaocrypt/types.h | 10 ++++++++-- src/include.am | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 7dd8c2601..591cc1c97 100644 --- a/configure.ac +++ b/configure.ac @@ -539,6 +539,28 @@ then fi +# MEMORY +AC_ARG_ENABLE([memory], + [ --enable-memory Enable memory callbacks (default: enabled)], + [ ENABLED_MEMORY=$enableval ], + [ ENABLED_MEMORY=yes ] + ) + +if test "$ENABLED_MEMORY" = "no" +then + AM_CFLAGS="$AM_CFLAGS -DNO_CYASSL_MEMORY" +else + # turn off memory cb if leanpsk on + if test "$ENABLED_LEANPSK" = "yes" + then + # but don't turn on NO_CYASSL_MEMORY because using own + ENABLED_MEMORY=no + fi +fi + +AM_CONDITIONAL([BUILD_MEMORY], [test "x$ENABLED_MEMORY" = "xyes"]) + + # RSA AC_ARG_ENABLE([rsa], [ --enable-rsa Enable RSA (default: enabled)], @@ -1169,6 +1191,7 @@ echo " * DH: $ENABLED_DH" echo " * ECC: $ENABLED_ECC" echo " * ASN: $ENABLED_ASN" echo " * CODING: $ENABLED_CODING" +echo " * MEMORY: $ENABLED_MEMORY" echo " * OCSP: $ENABLED_OCSP" echo " * CRL: $ENABLED_CRL" echo " * CRL-MONITOR: $ENABLED_CRL_MONITOR" diff --git a/cyassl/ctaocrypt/settings.h b/cyassl/ctaocrypt/settings.h index a9309638f..c08e6d0c7 100644 --- a/cyassl/ctaocrypt/settings.h +++ b/cyassl/ctaocrypt/settings.h @@ -457,7 +457,7 @@ #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \ - !defined(CYASSL_LEANPSK) + !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY) #define USE_CYASSL_MEMORY #endif diff --git a/cyassl/ctaocrypt/types.h b/cyassl/ctaocrypt/types.h index 2a7a8d02c..6659aac96 100644 --- a/cyassl/ctaocrypt/types.h +++ b/cyassl/ctaocrypt/types.h @@ -149,16 +149,22 @@ enum { /* default to libc stuff */ /* XREALLOC is used once in normal math lib, not in fast math lib */ /* XFREE on some embeded systems doesn't like free(0) so test */ -#ifdef XMALLOC_USER +#if defined(XMALLOC_USER) /* prototypes for user heap override functions */ #include /* for size_t */ extern void *XMALLOC(size_t n, void* heap, int type); extern void *XREALLOC(void *p, size_t n, void* heap, int type); extern void XFREE(void *p, void* heap, int type); +#elif defined(NO_CYASSL_MEMORY) + /* just use plain C stdlib stuff if desired */ + #include + #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s))) + #define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));} + #define XREALLOC(p, n, h, t) realloc((p), (n)) #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \ && !defined(CYASSL_SAFERTOS) && !defined(FREESCALE_MQX) \ && !defined(CYASSL_LEANPSK) - /* default C runtime, can install different routines at runtime */ + /* default C runtime, can install different routines at runtime via cbs */ #include #define XMALLOC(s, h, t) ((void)h, (void)t, CyaSSL_Malloc((s))) #define XFREE(p, h, t) {void* xp = (p); if((xp)) CyaSSL_Free((xp));} diff --git a/src/include.am b/src/include.am index b2e885b33..88e20590e 100644 --- a/src/include.am +++ b/src/include.am @@ -19,7 +19,7 @@ src_libcyassl_la_LIBADD = $(LIBM) src_libcyassl_la_CFLAGS = -DBUILDING_CYASSL $(AM_CFLAGS) src_libcyassl_la_CPPFLAGS = -DBUILDING_CYASSL $(AM_CPPFLAGS) -if !BUILD_LEANPSK +if BUILD_MEMORY src_libcyassl_la_SOURCES += ctaocrypt/src/memory.c endif