aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-12-06 11:07:53 -0500
committerJack Lloyd <[email protected]>2019-12-06 11:11:56 -0500
commitf0ca6fd32b1d02e6ad5c42219b249d49d8158bce (patch)
tree9b40940c1c35dda19809316c846f8d94ecfc9e05 /src
parentcecaaf474d6f6c5c5e1dd040b70ec34411d67da2 (diff)
Make CPU probes noexcept
Diffstat (limited to 'src')
-rw-r--r--src/lib/utils/cpuid/cpuid_arm.cpp10
-rw-r--r--src/lib/utils/cpuid/cpuid_ppc.cpp2
-rw-r--r--src/tests/test_os_utils.cpp12
3 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/utils/cpuid/cpuid_arm.cpp b/src/lib/utils/cpuid/cpuid_arm.cpp
index 6c947c62b..b422de9d2 100644
--- a/src/lib/utils/cpuid/cpuid_arm.cpp
+++ b/src/lib/utils/cpuid/cpuid_arm.cpp
@@ -200,11 +200,11 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
NEON registers v0-v7 are caller saved in Aarch64
*/
- auto neon_probe = []() -> int { asm("and v0.16b, v0.16b, v0.16b"); return 1; };
- auto aes_probe = []() -> int { asm(".word 0x4e284800"); return 1; };
- auto pmull_probe = []() -> int { asm(".word 0x0ee0e000"); return 1; };
- auto sha1_probe = []() -> int { asm(".word 0x5e280800"); return 1; };
- auto sha2_probe = []() -> int { asm(".word 0x5e282800"); return 1; };
+ auto neon_probe = []() noexcept -> int { asm("and v0.16b, v0.16b, v0.16b"); return 1; };
+ auto aes_probe = []() noexcept -> int { asm(".word 0x4e284800"); return 1; };
+ auto pmull_probe = []() noexcept -> int { asm(".word 0x0ee0e000"); return 1; };
+ auto sha1_probe = []() noexcept -> int { asm(".word 0x5e280800"); return 1; };
+ auto sha2_probe = []() noexcept -> int { asm(".word 0x5e282800"); return 1; };
// Only bother running the crypto detection if we found NEON
diff --git a/src/lib/utils/cpuid/cpuid_ppc.cpp b/src/lib/utils/cpuid/cpuid_ppc.cpp
index ff528d88e..4fb24f24b 100644
--- a/src/lib/utils/cpuid/cpuid_ppc.cpp
+++ b/src/lib/utils/cpuid/cpuid_ppc.cpp
@@ -86,7 +86,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
(others, too, maybe?) will trap and emulate it for us.
*/
- int pvr = OS::run_cpu_instruction_probe([]() -> int {
+ int pvr = OS::run_cpu_instruction_probe([]() noexcept -> int {
uint32_t pvr = 0;
asm volatile("mfspr %0, 287" : "=r" (pvr));
// Top 16 bits suffice to identify the model
diff --git a/src/tests/test_os_utils.cpp b/src/tests/test_os_utils.cpp
index 1ed90d8a3..997e6208a 100644
--- a/src/tests/test_os_utils.cpp
+++ b/src/tests/test_os_utils.cpp
@@ -99,7 +99,7 @@ class OS_Utils_Tests final : public Test
// TODO better tests
const uint64_t hr_ts1 = Botan::OS::get_high_resolution_clock();
- result.test_ne("high resolution timestamp value is never zero", hr_ts1, 0);
+ result.confirm("high resolution timestamp value is never zero", hr_ts1 != 0);
size_t counts = 0;
while(counts < max_trials && (Botan::OS::get_high_resolution_clock() == hr_ts1))
@@ -128,7 +128,7 @@ class OS_Utils_Tests final : public Test
Test::Result result("OS::get_system_timestamp_ns");
uint64_t sys_ts1 = Botan::OS::get_system_timestamp_ns();
- result.test_ne("System timestamp value is never zero", sys_ts1, 0);
+ result.confirm("System timestamp value is never zero", sys_ts1 != 0);
// do something that consumes a little time
Botan::OS::get_process_id();
@@ -155,7 +155,7 @@ class OS_Utils_Tests final : public Test
// OS::run_cpu_instruction_probe only implemented for Unix signals or Windows SEH
- std::function<int ()> ok_fn = []() -> int { return 5; };
+ std::function<int ()> ok_fn = []() noexcept -> int { return 5; };
const int run_rc = Botan::OS::run_cpu_instruction_probe(ok_fn);
if(run_rc == -3)
@@ -169,17 +169,17 @@ class OS_Utils_Tests final : public Test
std::function<int ()> crash_probe;
#if defined(BOTAN_TARGET_COMPILER_IS_MSVC)
- crash_probe = []() -> int { __ud2(); return 3; };
+ crash_probe = []() noexcept -> int { __ud2(); return 3; };
#elif defined(BOTAN_USE_GCC_INLINE_ASM)
#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY)
- crash_probe = []() -> int { asm volatile("ud2"); return 3; };
+ crash_probe = []() noexcept -> int { asm volatile("ud2"); return 3; };
#elif defined(BOTAN_TARGET_CPU_IS_ARM_FAMILY)
//ARM: asm volatile (".word 0xf7f0a000\n");
// illegal instruction in both ARM and Thumb modes
- crash_probe = []() -> int { asm volatile(".word 0xe7f0def0\n"); return 3; };
+ crash_probe = []() noexcept -> int { asm volatile(".word 0xe7f0def0\n"); return 3; };
#else
/*