aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build-data/os/freebsd4
-rw-r--r--src/build-data/os/linux4
-rw-r--r--src/build-data/os/solaris4
-rw-r--r--src/build-data/os/windows4
-rw-r--r--src/secalloc/ml_unix/mlock.cpp33
-rw-r--r--src/secalloc/ml_unix/xxxinfo.txt25
-rw-r--r--src/secalloc/ml_win32/mlock.cpp27
-rw-r--r--src/secalloc/ml_win32/xxxinfo.txt12
-rw-r--r--src/utils/info.txt4
-rw-r--r--src/utils/mlock.cpp23
-rw-r--r--src/utils/util.h2
11 files changed, 42 insertions, 100 deletions
diff --git a/src/build-data/os/freebsd b/src/build-data/os/freebsd
index e58ade517..ea96b0c88 100644
--- a/src/build-data/os/freebsd
+++ b/src/build-data/os/freebsd
@@ -2,6 +2,10 @@ realname "FreeBSD"
os_type unix
+<target_features>
+posix_mlock
+</target_features>
+
<supports_shared>
all
</supports_shared>
diff --git a/src/build-data/os/linux b/src/build-data/os/linux
index acf224244..53528511a 100644
--- a/src/build-data/os/linux
+++ b/src/build-data/os/linux
@@ -2,6 +2,10 @@ realname "Linux"
os_type unix
+<target_features>
+posix_mlock
+</target_features>
+
# Is this correct?
<supports_shared>
all
diff --git a/src/build-data/os/solaris b/src/build-data/os/solaris
index a1c1b40b3..8610b4898 100644
--- a/src/build-data/os/solaris
+++ b/src/build-data/os/solaris
@@ -2,6 +2,10 @@ realname "Solaris"
os_type unix
+<target_features>
+posix_mlock
+</target_features>
+
<supports_shared>
all
</supports_shared>
diff --git a/src/build-data/os/windows b/src/build-data/os/windows
index 62b271271..823c60d6c 100644
--- a/src/build-data/os/windows
+++ b/src/build-data/os/windows
@@ -12,6 +12,10 @@ doc_dir docs
install_cmd_data copy
install_cmd_exec copy
+<target_features>
+win32_virtual_lock
+</target_features>
+
<supports_shared>
msvc
</supports_shared>
diff --git a/src/secalloc/ml_unix/mlock.cpp b/src/secalloc/ml_unix/mlock.cpp
deleted file mode 100644
index 98214a215..000000000
--- a/src/secalloc/ml_unix/mlock.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*************************************************
-* Memory Locking Functions Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
-
-#include <botan/util.h>
-
-#ifndef _POSIX_C_SOURCE
- #define _POSIX_C_SOURCE 199309
-#endif
-
-#include <sys/types.h>
-#include <sys/mman.h>
-
-namespace Botan {
-
-/*************************************************
-* Lock an area of memory into RAM *
-*************************************************/
-void lock_mem(void* ptr, u32bit bytes)
- {
- mlock(ptr, bytes);
- }
-
-/*************************************************
-* Unlock a previously locked region of memory *
-*************************************************/
-void unlock_mem(void* ptr, u32bit bytes)
- {
- munlock(ptr, bytes);
- }
-
-}
diff --git a/src/secalloc/ml_unix/xxxinfo.txt b/src/secalloc/ml_unix/xxxinfo.txt
deleted file mode 100644
index 201a30ead..000000000
--- a/src/secalloc/ml_unix/xxxinfo.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-realname "Memory Locking for Unix"
-
-load_on auto
-
-<replace>
-mlock.cpp
-</replace>
-
-<os>
-aix
-darwin
-freebsd
-hpux
-irix
-linux
-netbsd
-openbsd
-qnx
-solaris
-tru64
-</os>
-
-<libs>
-tru64 -> rt
-</libs>
diff --git a/src/secalloc/ml_win32/mlock.cpp b/src/secalloc/ml_win32/mlock.cpp
deleted file mode 100644
index 8c5919934..000000000
--- a/src/secalloc/ml_win32/mlock.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*************************************************
-* Memory Locking Functions Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
-
-#include <botan/util.h>
-#include <windows.h>
-
-namespace Botan {
-
-/*************************************************
-* Lock an area of memory into RAM *
-*************************************************/
-void lock_mem(void* ptr, u32bit bytes)
- {
- VirtualLock(ptr, bytes);
- }
-
-/*************************************************
-* Unlock a previously locked region of memory *
-*************************************************/
-void unlock_mem(void* ptr, u32bit bytes)
- {
- VirtualUnlock(ptr, bytes);
- }
-
-}
diff --git a/src/secalloc/ml_win32/xxxinfo.txt b/src/secalloc/ml_win32/xxxinfo.txt
deleted file mode 100644
index 92936e1de..000000000
--- a/src/secalloc/ml_win32/xxxinfo.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-realname "Memory Locking for Win32"
-
-load_on auto
-
-<replace>
-mlock.cpp
-</replace>
-
-<os>
-windows
-cygwin
-</os>
diff --git a/src/utils/info.txt b/src/utils/info.txt
index 5effb77ed..820c3069f 100644
--- a/src/utils/info.txt
+++ b/src/utils/info.txt
@@ -4,6 +4,10 @@ define UTIL_FUNCTIONS
load_on auto
+<libs>
+tru64 -> rt
+</libs>
+
<add>
charset.cpp
mlock.cpp
diff --git a/src/utils/mlock.cpp b/src/utils/mlock.cpp
index e4456658d..12947709d 100644
--- a/src/utils/mlock.cpp
+++ b/src/utils/mlock.cpp
@@ -5,20 +5,39 @@
#include <botan/util.h>
+#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
+ #include <sys/types.h>
+ #include <sys/mman.h>
+#elif defined(BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK)
+ #include <windows.h>
+#endif
+
namespace Botan {
/*************************************************
* Lock an area of memory into RAM *
*************************************************/
-void lock_mem(void*, u32bit)
+bool lock_mem(void* ptr, u32bit bytes)
{
+#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
+ return (mlock(ptr, bytes) == 0);
+#elif defined(BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK)
+ return (VirtualLock(ptr, bytes) != 0);
+#else
+ return false;
+#endif
}
/*************************************************
* Unlock a previously locked region of memory *
*************************************************/
-void unlock_mem(void*, u32bit)
+void unlock_mem(void* ptr, u32bit bytes)
{
+#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
+ munlock(ptr, bytes);
+#elif defined(BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK)
+ VirtualUnlock(ptr, bytes);
+#endif
}
}
diff --git a/src/utils/util.h b/src/utils/util.h
index 879acd1db..62ecb948d 100644
--- a/src/utils/util.h
+++ b/src/utils/util.h
@@ -18,7 +18,7 @@ BOTAN_DLL u64bit system_time();
/*************************************************
* Memory Locking Functions *
*************************************************/
-BOTAN_DLL void lock_mem(void*, u32bit);
+BOTAN_DLL bool lock_mem(void*, u32bit);
BOTAN_DLL void unlock_mem(void*, u32bit);
/*************************************************