Skip to content

Commit ef97330

Browse files
author
Requiem
committed
style: changed data types to rust convention
1 parent a5faf0a commit ef97330

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/vmaware.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5013,12 +5013,12 @@ struct VM {
50135013
#else
50145014
__attribute__((noinline))
50155015
#endif
5016-
std::uint64_t operator()() const noexcept {
5016+
u64 operator()() const noexcept {
50175017
// TO prevent hoisting across this call
50185018
std::atomic_signal_fence(std::memory_order_seq_cst);
50195019

50205020
// start state (golden ratio)
5021-
volatile std::uint64_t v = UINT64_C(0x9E3779B97F4A7C15);
5021+
volatile u64 v = UINT64_C(0x9E3779B97F4A7C15);
50225022

50235023
// mix in addresses (ASLR gives entropy but if ASLR disabled or bypassed we have some tricks still)
50245024
// Take addresses of various locals/statics and mark some volatile so they cannot be optimized away
@@ -5030,17 +5030,17 @@ struct VM {
50305030
std::uintptr_t pc = reinterpret_cast<std::uintptr_t>(&module_static);
50315031
std::uintptr_t pd = reinterpret_cast<std::uintptr_t>(&probe_lambda);
50325032

5033-
v ^= static_cast<std::uint64_t>(pa) + UINT64_C(0x9E3779B97F4A7C15) + (v << 6) + (v >> 2);
5034-
v ^= static_cast<std::uint64_t>(pb) + (v << 7);
5035-
v ^= static_cast<std::uint64_t>(pc) + (v >> 11);
5036-
v ^= static_cast<std::uint64_t>(pd) + UINT64_C(0xBF58476D1CE4E5B9);
5033+
v ^= static_cast<u64>(pa) + UINT64_C(0x9E3779B97F4A7C15) + (v << 6) + (v >> 2);
5034+
v ^= static_cast<u64>(pb) + (v << 7);
5035+
v ^= static_cast<u64>(pc) + (v >> 11);
5036+
v ^= static_cast<u64>(pd) + UINT64_C(0xBF58476D1CE4E5B9);
50375037

50385038
// dependent operations on volatile locals to prevent elimination
50395039
for (int i = 0; i < 24; ++i) {
50405040
volatile int stack_local = i ^ static_cast<int>(v);
50415041
// take address each iteration and fold it in
50425042
std::uintptr_t la = reinterpret_cast<std::uintptr_t>(&stack_local);
5043-
v ^= (static_cast<std::uint64_t>(la) + (static_cast<std::uint64_t>(i) * UINT64_C(0x9E3779B97F4A7C)));
5043+
v ^= (static_cast<u64>(la) + (static_cast<u64>(i) * UINT64_C(0x9E3779B97F4A7C)));
50445044
// dependent shifts to spread any small differences
50455045
v ^= (v << ((i & 31)));
50465046
v ^= (v >> (((i + 13) & 31)));
@@ -5058,20 +5058,20 @@ struct VM {
50585058
// another compiler fence to prevent hoisting results
50595059
std::atomic_signal_fence(std::memory_order_seq_cst);
50605060

5061-
return static_cast<std::uint64_t>(v);
5061+
return static_cast<u64>(v);
50625062
}
50635063
};
50645064

50655065
// rejection sampling as before to avoid modulo bias
5066-
auto rng = [](std::uint64_t min, std::uint64_t max, auto getrand) noexcept -> std::uint64_t {
5067-
const std::uint64_t range = max - min + 1;
5068-
const std::uint64_t max_val = std::numeric_limits<std::uint64_t>::max();
5069-
const std::uint64_t limit = max_val - (max_val % range);
5066+
auto rng = [](u64 min, u64 max, auto getrand) noexcept -> u64 {
5067+
const u64 range = max - min + 1;
5068+
const u64 max_val = std::numeric_limits<u64>::max();
5069+
const u64 limit = max_val - (max_val % range);
50705070
for (;;) {
5071-
const std::uint64_t r = getrand();
5071+
const u64 r = getrand();
50725072
if (r < limit) return min + (r % range);
50735073
// small local mix to change subsequent outputs (still in user-mode and not a syscall)
5074-
volatile std::uint64_t scrub = r;
5074+
volatile u64 scrub = r;
50755075
scrub ^= (scrub << 11);
50765076
scrub ^= (scrub >> 9);
50775077
(void)scrub;

0 commit comments

Comments
 (0)