aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-01-22 14:31:01 -0500
committerJack Lloyd <[email protected]>2017-01-22 14:40:03 -0500
commitef8c214eb28abc36ddc4ffff467c51ed69cae63c (patch)
tree5cfff5f1aa1a108ff35c50b9c58a9661d9a2d0be /src/lib/utils
parent2dc8d318194ae31b2bedc17c2e153d6e76e8791d (diff)
Add basic test for OS utils
Mainly driven by missing test for OS::run_cpu_instruction_probe. Currently only works on x86 and ARM. Tested on x86-64 native and aarch64 qemu.
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/os_utils.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/utils/os_utils.h b/src/lib/utils/os_utils.h
index b74debc46..60ef2cf5b 100644
--- a/src/lib/utils/os_utils.h
+++ b/src/lib/utils/os_utils.h
@@ -15,13 +15,21 @@ namespace Botan {
namespace OS {
+/*
+* This header is internal (not installed) and these functions are not
+* intended to be called by applications. However they are given public
+* visibility (using BOTAN_DLL macro) for the tests. This also probably
+* allows them to be overridden by the application on ELF systems, but
+* this hasn't been tested.
+*/
+
/**
* @return process ID assigned by the operating system.
* On Unix and Windows systems, this always returns a result
* On IncludeOS it returns 0 since there is no process ID to speak of
* in a unikernel.
*/
-uint32_t get_process_id();
+uint32_t BOTAN_DLL get_process_id();
/**
* @return highest resolution clock available on the system.
@@ -36,13 +44,13 @@ uint32_t get_process_id();
* On other platforms clock_gettime is used with some monotonic timer, if available.
* As a final fallback std::chrono::high_resolution_clock is used.
*/
-uint64_t get_processor_timestamp();
+uint64_t BOTAN_DLL get_processor_timestamp();
/**
* @return system clock with best resolution available, normalized to
* nanoseconds resolution.
*/
-uint64_t get_system_timestamp_ns();
+uint64_t BOTAN_DLL get_system_timestamp_ns();
/**
* @return maximum amount of memory (in bytes) Botan could/should
@@ -82,7 +90,7 @@ void free_locked_pages(void* ptr, size_t length);
* -1 illegal instruction detected
* -2 exception thrown
*/
-int run_cpu_instruction_probe(std::function<int ()> probe_fn);
+int BOTAN_DLL run_cpu_instruction_probe(std::function<int ()> probe_fn);
}