diff options
author | Jeffrey Walton <noloader@gmail.com> | 2018-01-21 19:48:36 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2018-01-21 19:48:36 -0500 |
commit | aee296d663aa9e0cc365d6adc4c2a7b72b122c5f (patch) | |
tree | f08473306ba3fa9e7b4633dcdad912b7fc6536b9 | |
parent | 58f6b7695b5227faa04eee17b71094868746431e (diff) | |
download | cryptopp-git-aee296d663aa9e0cc365d6adc4c2a7b72b122c5f.tar.gz |
Fix AIX AlignedAllocate
Well, the IBM docs were not quite correct when they stated "The block is aligned so that it can be used for any type of data". The vector data types are pretty standard, even across different machines from diffent manufacturers
-rw-r--r-- | config.h | 4 | ||||
-rw-r--r-- | misc.cpp | 6 |
2 files changed, 9 insertions, 1 deletions
@@ -695,7 +695,9 @@ NAMESPACE_END #define CRYPTOPP_MM_MALLOC_AVAILABLE
#elif defined(__APPLE__)
#define CRYPTOPP_APPLE_MALLOC_AVAILABLE
-#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(_AIX)
+#elif defined(_AIX)
+ #define CRYPTOPP_POSIX_MEMALIGN_AVAILABLE
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
#define CRYPTOPP_MEMALIGN_AVAILABLE
@@ -22,6 +22,10 @@ #if defined(CRYPTOPP_MEMALIGN_AVAILABLE) || defined(CRYPTOPP_MM_MALLOC_AVAILABLE) || defined(QNX)
# include <malloc.h>
#endif
+// for posix_memalign
+#if defined(CRYPTOPP_POSIX_MEMALIGN_AVAILABLE)
+# include <stdlib.h>
+#endif
NAMESPACE_BEGIN(CryptoPP)
@@ -285,6 +289,8 @@ void * AlignedAllocate(size_t size) while ((p = (byte *)malloc(size)) == NULLPTR)
#elif 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)
|