aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/build-data/buildh.in2
-rw-r--r--src/lib/alloc/locking_allocator/locking_allocator.cpp12
2 files changed, 12 insertions, 2 deletions
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in
index 2bf6cd7e6..6172af247 100644
--- a/src/build-data/buildh.in
+++ b/src/build-data/buildh.in
@@ -36,7 +36,7 @@
#define BOTAN_DEFAULT_BUFFER_SIZE 1024
/* Maximum size to allocate out of the mlock pool */
-#define BOTAN_MLOCK_ALLOCATOR_MAX_ALLOCATION 4096
+#define BOTAN_MLOCK_ALLOCATOR_MAX_ALLOCATION 128
/* Multiplier on a block cipher's native parallelism */
#define BOTAN_BLOCK_CIPHER_PAR_MULT 4
diff --git a/src/lib/alloc/locking_allocator/locking_allocator.cpp b/src/lib/alloc/locking_allocator/locking_allocator.cpp
index 84ccc73a8..8e3f7e142 100644
--- a/src/lib/alloc/locking_allocator/locking_allocator.cpp
+++ b/src/lib/alloc/locking_allocator/locking_allocator.cpp
@@ -17,6 +17,12 @@ namespace Botan {
namespace {
+/**
+* Requests for objects of sizeof(T) will be aligned at
+* sizeof(T)*ALIGNMENT_MULTIPLE bytes.
+*/
+const size_t ALIGNMENT_MULTIPLE = 2;
+
size_t mlock_limit()
{
/*
@@ -74,7 +80,7 @@ void* mlock_allocator::allocate(size_t num_elems, size_t elem_size)
return nullptr;
const size_t n = num_elems * elem_size;
- const size_t alignment = elem_size;
+ const size_t alignment = ALIGNMENT_MULTIPLE * elem_size;
if(n / elem_size != num_elems)
return nullptr; // overflow!
@@ -216,6 +222,10 @@ mlock_allocator::mlock_allocator() :
#define MAP_NOCORE 0
#endif
+#if !defined(MAP_ANONYMOUS)
+ #define MAP_ANONYMOUS MAP_ANON
+#endif
+
if(m_poolsize)
{
m_pool = static_cast<byte*>(