@@ -5013,34 +5013,34 @@ struct VM {
50135013 #else
50145014 __attribute__ ((noinline))
50155015 #endif
5016- ULONG64 operator ()() const noexcept {
5016+ std:: uint64_t 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 ULONG64 v = 0x9E3779B97F4A7C15ULL ;
5021+ volatile std:: uint64_t 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
50255025 volatile int local_static = 0 ; // local volatile (stack-like)
50265026 static volatile int module_static = 0 ; // static in function scope (image address)
50275027 auto probe_lambda = []() noexcept {}; // stack-local lambda object
5028- uintptr_t pa = reinterpret_cast <uintptr_t >(&v);
5029- uintptr_t pb = reinterpret_cast <uintptr_t >(&local_static);
5030- uintptr_t pc = reinterpret_cast <uintptr_t >(&module_static);
5031- uintptr_t pd = reinterpret_cast <uintptr_t >(&probe_lambda);
5028+ std:: uintptr_t pa = reinterpret_cast <std:: uintptr_t >(&v);
5029+ std:: uintptr_t pb = reinterpret_cast <std:: uintptr_t >(&local_static);
5030+ std:: uintptr_t pc = reinterpret_cast <std:: uintptr_t >(&module_static);
5031+ std:: uintptr_t pd = reinterpret_cast <std:: uintptr_t >(&probe_lambda);
50325032
5033- v ^= static_cast <ULONG64 >(pa) + 0x9E3779B97F4A7C15ULL + (v << 6 ) + (v >> 2 );
5034- v ^= static_cast <ULONG64 >(pb) + (v << 7 );
5035- v ^= static_cast <ULONG64 >(pc) + (v >> 11 );
5036- v ^= static_cast <ULONG64 >(pd) + 0xBF58476D1CE4E5B9ULL ;
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 ) ;
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
5042- uintptr_t la = reinterpret_cast <uintptr_t >(&stack_local);
5043- v ^= (static_cast <ULONG64 >(la) + (static_cast <ULONG64 >(i) * 0x9E3779B97F4A7CULL ));
5042+ 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 ) ));
50445044 // dependent shifts to spread any small differences
50455045 v ^= (v << ((i & 31 )));
50465046 v ^= (v >> (((i + 13 ) & 31 )));
@@ -5052,25 +5052,26 @@ struct VM {
50525052 v ^= (v << 13 );
50535053 v ^= (v >> 7 );
50545054 v ^= (v << 17 );
5055- v *= 0x2545F4914F6CDD1DULL ;
5055+ v *= UINT64_C ( 0x2545F4914F6CDD1D ) ;
50565056 v ^= (v >> 33 );
50575057
50585058 // another compiler fence to prevent hoisting results
50595059 std::atomic_signal_fence (std::memory_order_seq_cst);
50605060
5061- return static_cast <ULONG64 >(v);
5061+ return static_cast <std:: uint64_t >(v);
50625062 }
50635063 };
50645064
50655065 // rejection sampling as before to avoid modulo bias
5066- auto rng = [](ULONG64 min, ULONG64 max, auto getrand) noexcept -> ULONG64 {
5067- const ULONG64 range = max - min + 1 ;
5068- const ULONG64 limit = (~0ULL ) - ((~0ULL ) % range);
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);
50695070 for (;;) {
5070- const ULONG64 r = getrand ();
5071+ const std:: uint64_t r = getrand ();
50715072 if (r < limit) return min + (r % range);
50725073 // small local mix to change subsequent outputs (still in user-mode and not a syscall)
5073- volatile ULONG64 scrub = r;
5074+ volatile std:: uint64_t scrub = r;
50745075 scrub ^= (scrub << 11 );
50755076 scrub ^= (scrub >> 9 );
50765077 (void )scrub;
0 commit comments