Fix unwanted inlining of factory.h classes on AIX and Power7

Enable aligned allocations under IBM XL C/C++. Based on the AIX malloc man pages, "... the block is aligned so that it can be used for any type of data". Previously CRYPTOPP_NO_ALIGNED_ALLOC was in effect.

Use malloc instead of calloc on OS X. Based on the OS X malloc man pages, "... the allocated memory is aligned such that it can be used for any data type, including AltiVec- and SSE-related types". Additionally, calloc zero'd the memory it allocated which slowed things down on Apple systems.
pull/531/head
Jeffrey Walton 2017-10-13 04:13:39 -04:00
parent 437eda09e0
commit 1315c1fe2f
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 6 additions and 3 deletions

View File

@ -637,7 +637,7 @@ NAMESPACE_END
#define CRYPTOPP_MM_MALLOC_AVAILABLE #define CRYPTOPP_MM_MALLOC_AVAILABLE
#elif defined(__APPLE__) #elif defined(__APPLE__)
#define CRYPTOPP_APPLE_MALLOC_AVAILABLE #define CRYPTOPP_APPLE_MALLOC_AVAILABLE
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(_AIX)
#define CRYPTOPP_MALLOC_ALIGNMENT_IS_16 #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__) #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
#define CRYPTOPP_MEMALIGN_AVAILABLE #define CRYPTOPP_MEMALIGN_AVAILABLE
@ -649,7 +649,10 @@ NAMESPACE_END
#if defined(_MSC_VER) #if defined(_MSC_VER)
# define CRYPTOPP_NOINLINE_DOTDOTDOT # define CRYPTOPP_NOINLINE_DOTDOTDOT
# define CRYPTOPP_NOINLINE __declspec(noinline) # define CRYPTOPP_NOINLINE __declspec(noinline)
#elif defined(__GNUC__) || defined(__xlC__) #elif defined(__xlc__) || defined(__xlC__)
# define CRYPTOPP_NOINLINE_DOTDOTDOT ...
# define CRYPTOPP_NOINLINE __attribute__((noinline))
#elif defined(__GNUC__)
# define CRYPTOPP_NOINLINE_DOTDOTDOT # define CRYPTOPP_NOINLINE_DOTDOTDOT
# define CRYPTOPP_NOINLINE __attribute__((noinline)) # define CRYPTOPP_NOINLINE __attribute__((noinline))
#else #else

View File

@ -282,7 +282,7 @@ void * AlignedAllocate(size_t size)
{ {
byte *p; byte *p;
#if defined(CRYPTOPP_APPLE_ALLOC_AVAILABLE) #if defined(CRYPTOPP_APPLE_ALLOC_AVAILABLE)
while ((p = (byte *)calloc(1, size)) == NULLPTR) while ((p = (byte *)malloc(size)) == NULLPTR)
#elif defined(CRYPTOPP_MM_MALLOC_AVAILABLE) #elif defined(CRYPTOPP_MM_MALLOC_AVAILABLE)
while ((p = (byte *)_mm_malloc(size, 16)) == NULLPTR) while ((p = (byte *)_mm_malloc(size, 16)) == NULLPTR)
#elif defined(CRYPTOPP_MEMALIGN_AVAILABLE) #elif defined(CRYPTOPP_MEMALIGN_AVAILABLE)