From f771e317ff9f4ad2a2e8bbd4403c3b02ad6f0ddc Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Thu, 19 Nov 2015 21:34:58 +0100 Subject: [PATCH 1/2] move standard includes --- demo/demo.c | 1 + tommath.h | 2 -- tommath_private.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/demo.c b/demo/demo.c index 75d5cf8..a5ac674 100644 --- a/demo/demo.c +++ b/demo/demo.c @@ -1,3 +1,4 @@ +#include #include #ifdef IOWNANATHLON diff --git a/tommath.h b/tommath.h index 556b924..93fa74c 100644 --- a/tommath.h +++ b/tommath.h @@ -16,10 +16,8 @@ #define BN_H_ #include -#include #include #include -#include #include #include diff --git a/tommath_private.h b/tommath_private.h index d154739..5d4ea63 100644 --- a/tommath_private.h +++ b/tommath_private.h @@ -16,6 +16,7 @@ #define TOMMATH_PRIV_H_ #include +#include #ifdef __cplusplus extern "C" { From e6cfefc1ac2a61f88c7f6076d99bbc4f3c41c9bb Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Thu, 19 Nov 2015 21:53:32 +0100 Subject: [PATCH 2/2] more private stuff --- tommath.h | 36 ------------------------------------ tommath_private.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/tommath.h b/tommath.h index 93fa74c..8e784e8 100644 --- a/tommath.h +++ b/tommath.h @@ -22,28 +22,10 @@ #include -#ifndef MIN - #define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#endif - -#ifndef MAX - #define MAX(x,y) (((x) > (y)) ? (x) : (y)) -#endif - #ifdef __cplusplus extern "C" { - -/* C++ compilers don't like assigning void * to mp_digit * */ -#define OPT_CAST(x) (x *) - -#else - -/* C on the other hand doesn't care */ -#define OPT_CAST(x) - #endif - /* detect 64-bit mode if possible */ #if defined(__x86_64__) #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) @@ -114,24 +96,6 @@ extern "C" { #endif #endif -/* define heap macros */ -#ifndef CRYPT - /* default to libc stuff */ - #ifndef XMALLOC - #define XMALLOC malloc - #define XFREE free - #define XREALLOC realloc - #define XCALLOC calloc - #else - /* prototypes for our heap functions */ - extern void *XMALLOC(size_t n); - extern void *XREALLOC(void *p, size_t n); - extern void *XCALLOC(size_t n, size_t s); - extern void XFREE(void *p); - #endif -#endif - - /* otherwise the bits per digit is calculated automatically from the size of a mp_digit */ #ifndef DIGIT_BIT #define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */ diff --git a/tommath_private.h b/tommath_private.h index 5d4ea63..986beac 100644 --- a/tommath_private.h +++ b/tommath_private.h @@ -18,8 +18,36 @@ #include #include +#define MIN(x,y) (((x) < (y)) ? (x) : (y)) + +#define MAX(x,y) (((x) > (y)) ? (x) : (y)) + #ifdef __cplusplus extern "C" { + +/* C++ compilers don't like assigning void * to mp_digit * */ +#define OPT_CAST(x) (x *) + +#else + +/* C on the other hand doesn't care */ +#define OPT_CAST(x) + +#endif + +/* define heap macros */ +#ifndef XMALLOC + /* default to libc stuff */ + #define XMALLOC malloc + #define XFREE free + #define XREALLOC realloc + #define XCALLOC calloc +#else + /* prototypes for our heap functions */ + extern void *XMALLOC(size_t n); + extern void *XREALLOC(void *p, size_t n); + extern void *XCALLOC(size_t n, size_t s); + extern void XFREE(void *p); #endif /* lowlevel functions, do not call! */