summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-01-21 19:48:36 -0500
committerJeffrey Walton <noloader@gmail.com>2018-01-21 19:48:36 -0500
commitaee296d663aa9e0cc365d6adc4c2a7b72b122c5f (patch)
treef08473306ba3fa9e7b4633dcdad912b7fc6536b9
parent58f6b7695b5227faa04eee17b71094868746431e (diff)
downloadcryptopp-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.h4
-rw-r--r--misc.cpp6
2 files changed, 9 insertions, 1 deletions
diff --git a/config.h b/config.h
index bbf76717..23444ea3 100644
--- a/config.h
+++ b/config.h
@@ -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
diff --git a/misc.cpp b/misc.cpp
index f844487e..7ebc20df 100644
--- a/misc.cpp
+++ b/misc.cpp
@@ -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)