diff options
author | Jack Lloyd <[email protected]> | 2015-12-05 13:10:59 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-12-05 13:10:59 -0500 |
commit | f75ae7463a7f300a0b2a95693062b7129b6cc53d (patch) | |
tree | faec9ed28956bcd2dda6e8d26f4ba094678bb454 /src/lib/utils/os_utils.h | |
parent | 2a472e9b33617afa62f5f899ec7eba90eb2f7ece (diff) |
Add OS utility header
Provide abstractions for the locking allocator (allocate and free
locked pages) to decouple it from the platform dependent code. Should
make it easy to write a Windows version using VirtualAlloc+VirtualLock.
Exposes max mlock limit as a build.h toggle
Diffstat (limited to 'src/lib/utils/os_utils.h')
-rw-r--r-- | src/lib/utils/os_utils.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lib/utils/os_utils.h b/src/lib/utils/os_utils.h new file mode 100644 index 000000000..0030f88c9 --- /dev/null +++ b/src/lib/utils/os_utils.h @@ -0,0 +1,40 @@ +/* +* OS specific utility functions +* (C) 2015 Jack Lloyd +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#ifndef BOTAN_OS_UTILS_H__ +#define BOTAN_OS_UTILS_H__ + +#include <botan/types.h> + +namespace Botan { + +namespace OS { + +/* +* Returns the maximum amount of memory (in bytes) we could/should +* hyptothetically allocate. Reads "BOTAN_MLOCK_POOL_SIZE" from +* environment which can be set to zero. +*/ +size_t get_memory_locking_limit(); + +/* +* Request so many bytes of page-aligned RAM locked into memory OS +* calls (mlock, VirtualLock, or similar). Returns null on failure. The +* memory returned is zeroed. Free it with free_locked_pages. +*/ +void* allocate_locked_pages(size_t length); + +/* +* Free memory allocated by allocate_locked_pages +*/ +void free_locked_pages(void* ptr, size_t length); + +} + +} + +#endif |