aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-12-23 14:42:49 -0500
committerJack Lloyd <[email protected]>2018-12-23 14:42:49 -0500
commitf7f42d07187b357dc5b4c3de53f29af88bd07eb6 (patch)
tree2979a79abf3446a5c231da8707f084bb685998ae /src/lib/utils
parent716005aa4283c962dfe1478e4ee85bef5cfda293 (diff)
Rename OS::get_processor_timestamp to OS::get_cpu_cycle_counter
Using phrase "timestamp" makes it sound like it has some relation to wall clock which it does not.
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/os_utils.cpp6
-rw-r--r--src/lib/utils/os_utils.h2
-rw-r--r--src/lib/utils/timer.cpp5
3 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index 77be98dc6..946a2c297 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -100,7 +100,7 @@ bool OS::running_in_privileged_state()
#endif
}
-uint64_t OS::get_processor_timestamp()
+uint64_t OS::get_cpu_cycle_counter()
{
uint64_t rtc = 0;
@@ -153,7 +153,7 @@ uint64_t OS::get_processor_timestamp()
asm volatile("mfctl 16,%0" : "=r" (rtc)); // 64-bit only?
#else
- //#warning "OS::get_processor_timestamp not implemented"
+ //#warning "OS::get_cpu_cycle_counter not implemented"
#endif
#endif
@@ -163,7 +163,7 @@ uint64_t OS::get_processor_timestamp()
uint64_t OS::get_high_resolution_clock()
{
- if(uint64_t cpu_clock = OS::get_processor_timestamp())
+ if(uint64_t cpu_clock = OS::get_cpu_cycle_counter())
return cpu_clock;
#if defined(BOTAN_TARGET_OS_IS_EMSCRIPTEN)
diff --git a/src/lib/utils/os_utils.h b/src/lib/utils/os_utils.h
index 39e30fcb7..24cbdd5a3 100644
--- a/src/lib/utils/os_utils.h
+++ b/src/lib/utils/os_utils.h
@@ -46,7 +46,7 @@ bool running_in_privileged_state();
* Currently supported processors are x86, PPC, Alpha, SPARC, IA-64, S/390x, and HP-PA.
* If no CPU cycle counter is available on this system, returns zero.
*/
-uint64_t BOTAN_TEST_API get_processor_timestamp();
+uint64_t BOTAN_TEST_API get_cpu_cycle_counter();
/*
* @return best resolution timestamp available
diff --git a/src/lib/utils/timer.cpp b/src/lib/utils/timer.cpp
index 5196397b9..1b4f3068c 100644
--- a/src/lib/utils/timer.cpp
+++ b/src/lib/utils/timer.cpp
@@ -5,6 +5,7 @@
*/
#include <botan/internal/timer.h>
+#include <botan/internal/os_utils.h>
#include <algorithm>
#include <sstream>
#include <iomanip>
@@ -15,7 +16,7 @@ void Timer::start()
{
stop();
m_timer_start = OS::get_system_timestamp_ns();
- m_cpu_cycles_start = OS::get_processor_timestamp();
+ m_cpu_cycles_start = OS::get_cpu_cycle_counter();
}
void Timer::stop()
@@ -24,7 +25,7 @@ void Timer::stop()
{
if(m_cpu_cycles_start != 0)
{
- const uint64_t cycles_taken = OS::get_processor_timestamp() - m_cpu_cycles_start;
+ const uint64_t cycles_taken = OS::get_cpu_cycle_counter() - m_cpu_cycles_start;
if(cycles_taken > 0)
{
m_cpu_cycles_used += static_cast<size_t>(cycles_taken * m_clock_cycle_ratio);