aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/alloc/system_alloc/defalloc.cpp2
-rw-r--r--src/utils/info.txt1
-rw-r--r--src/utils/mlock.cpp2
-rw-r--r--src/utils/mlock.h32
-rw-r--r--src/utils/util.cpp18
-rw-r--r--src/utils/util.h18
6 files changed, 47 insertions, 26 deletions
diff --git a/src/alloc/system_alloc/defalloc.cpp b/src/alloc/system_alloc/defalloc.cpp
index 8791c74e4..b1b338d71 100644
--- a/src/alloc/system_alloc/defalloc.cpp
+++ b/src/alloc/system_alloc/defalloc.cpp
@@ -7,7 +7,7 @@
#include <botan/defalloc.h>
#include <botan/libstate.h>
-#include <botan/util.h>
+#include <botan/mlock.h>
#include <cstdlib>
#include <cstring>
diff --git a/src/utils/info.txt b/src/utils/info.txt
index ab50b88ad..bf9778369 100644
--- a/src/utils/info.txt
+++ b/src/utils/info.txt
@@ -17,6 +17,7 @@ exceptn.cpp
exceptn.h
loadstor.h
mem_ops.h
+mlock.h
mlock.cpp
parsing.cpp
parsing.h
diff --git a/src/utils/mlock.cpp b/src/utils/mlock.cpp
index 9bb062da5..6453d8a30 100644
--- a/src/utils/mlock.cpp
+++ b/src/utils/mlock.cpp
@@ -5,7 +5,7 @@
* Distributed under the terms of the Botan license
*/
-#include <botan/util.h>
+#include <botan/mlock.h>
#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
#include <sys/types.h>
diff --git a/src/utils/mlock.h b/src/utils/mlock.h
new file mode 100644
index 000000000..0811e8190
--- /dev/null
+++ b/src/utils/mlock.h
@@ -0,0 +1,32 @@
+/*
+* Memory Locking Functions
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_MLOCK_H__
+#define BOTAN_MLOCK_H__
+
+#include <botan/types.h>
+
+namespace Botan {
+
+/**
+* Lock memory into RAM if possible
+* @param addr the start of the memory block
+* @param length the length of the memory block in bytes
+* @returns true if successful, false otherwise
+*/
+BOTAN_DLL bool lock_mem(void* addr, u32bit length);
+
+/**
+* Unlock memory locked with lock_mem()
+* @param addr the start of the memory block
+* @param length the length of the memory block in bytes
+*/
+BOTAN_DLL void unlock_mem(void* addr, u32bit length);
+
+}
+
+#endif
diff --git a/src/utils/util.cpp b/src/utils/util.cpp
index 84dfd1a14..09ac9f1ca 100644
--- a/src/utils/util.cpp
+++ b/src/utils/util.cpp
@@ -12,24 +12,6 @@
namespace Botan {
/*
-* Round up n to multiple of align_to
-*/
-u32bit round_up(u32bit n, u32bit align_to)
- {
- if(n % align_to || n == 0)
- n += align_to - (n % align_to);
- return n;
- }
-
-/*
-* Round down n to multiple of align_to
-*/
-u32bit round_down(u32bit n, u32bit align_to)
- {
- return (n - (n % align_to));
- }
-
-/*
* Choose the exponent size for a DL group
*/
u32bit dl_work_factor(u32bit bits)
diff --git a/src/utils/util.h b/src/utils/util.h
index ac7867390..e3dadc64b 100644
--- a/src/utils/util.h
+++ b/src/utils/util.h
@@ -18,16 +18,22 @@ namespace Botan {
BOTAN_DLL u64bit system_time();
/*
-* Memory Locking Functions
+* Round up n to multiple of align_to
*/
-BOTAN_DLL bool lock_mem(void*, u32bit);
-BOTAN_DLL void unlock_mem(void*, u32bit);
+inline u32bit round_up(u32bit n, u32bit align_to)
+ {
+ if(n % align_to || n == 0)
+ n += align_to - (n % align_to);
+ return n;
+ }
/*
-* Misc Utility Functions
+* Round down n to multiple of align_to
*/
-BOTAN_DLL u32bit round_up(u32bit, u32bit);
-BOTAN_DLL u32bit round_down(u32bit, u32bit);
+inline u32bit round_down(u32bit n, u32bit align_to)
+ {
+ return (n - (n % align_to));
+ }
/*
* Work Factor Estimates