Move CRYPTOPP_POSIX_MEMALIGN_AVAILABLE preference down

This should result in fewer surprises
This commit is contained in:
Jeffrey Walton 2018-01-30 22:03:34 -05:00
parent 7141d026c1
commit a876d82445
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 7 additions and 11 deletions

View File

@ -694,14 +694,12 @@ NAMESPACE_END
// posix_memalign see https://forum.kde.org/viewtopic.php?p=66274
#if defined(_MSC_VER)
#define CRYPTOPP_MM_MALLOC_AVAILABLE
#elif defined(__APPLE__)
#define CRYPTOPP_APPLE_MALLOC_AVAILABLE
#elif (defined(_GNU_SOURCE) || ((_XOPEN_SOURCE + 0) >= 600)) && (_POSIX_ADVISORY_INFO > 0)
#define CRYPTOPP_POSIX_MEMALIGN_AVAILABLE
#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
#define CRYPTOPP_MEMALIGN_AVAILABLE
#elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
#elif (defined(_GNU_SOURCE) || ((_XOPEN_SOURCE + 0) >= 600)) && (_POSIX_ADVISORY_INFO > 0)
#define CRYPTOPP_POSIX_MEMALIGN_AVAILABLE
#else
#define CRYPTOPP_NO_ALIGNED_ALLOC
#endif

View File

@ -285,16 +285,14 @@ void CallNewHandler()
void * AlignedAllocate(size_t size)
{
byte *p;
#if defined(CRYPTOPP_APPLE_ALLOC_AVAILABLE)
while ((p = (byte *)malloc(size)) == NULLPTR)
#elif defined(CRYPTOPP_MM_MALLOC_AVAILABLE)
#if defined(CRYPTOPP_MM_MALLOC_AVAILABLE)
while ((p = (byte *)_mm_malloc(size, 16)) == NULLPTR)
#elif defined(CRYPTOPP_POSIX_MEMALIGN_AVAILABLE)
while (posix_memalign(reinterpret_cast<void**>(&p), 16, size) != 0)
#elif defined(CRYPTOPP_MEMALIGN_AVAILABLE)
while ((p = (byte *)memalign(16, size)) == NULLPTR)
#elif defined(CRYPTOPP_MALLOC_ALIGNMENT_IS_16)
while ((p = (byte *)malloc(size)) == NULLPTR)
#elif defined(CRYPTOPP_POSIX_MEMALIGN_AVAILABLE)
while (posix_memalign(reinterpret_cast<void**>(&p), 16, size) != 0)
#else
while ((p = (byte *)malloc(size + 16)) == NULLPTR)
#endif