aboutsummaryrefslogtreecommitdiffstats
path: root/modules/allocation/ml_unix/mlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/allocation/ml_unix/mlock.cpp')
-rw-r--r--modules/allocation/ml_unix/mlock.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/allocation/ml_unix/mlock.cpp b/modules/allocation/ml_unix/mlock.cpp
new file mode 100644
index 000000000..98214a215
--- /dev/null
+++ b/modules/allocation/ml_unix/mlock.cpp
@@ -0,0 +1,33 @@
+/*************************************************
+* 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);
+ }
+
+}