mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(big): add 64-bit-centric ops
This commit is contained in:
parent
23fb94c19d
commit
d3fd03d67e
4 changed files with 105 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ check_cxx_compiler_flag(-Wno-invalid-offsetof HAS_NO_INVALID_OFFSETOF)
|
|||
|
||||
file(GLOB STORM_SOURCES
|
||||
"*.cpp"
|
||||
"big/*.cpp"
|
||||
"hash/*.cpp"
|
||||
"queue/*.cpp"
|
||||
"string/*.cpp"
|
||||
|
|
|
|||
24
storm/big/Ops.cpp
Normal file
24
storm/big/Ops.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "storm/big/Ops.hpp"
|
||||
|
||||
uint32_t ExtractLowPart(uint64_t& value) {
|
||||
auto low = static_cast<uint32_t>(value);
|
||||
value >>= 32;
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
uint32_t ExtractLowPartSx(uint64_t& value) {
|
||||
auto low = static_cast<uint32_t>(value);
|
||||
value >>= 32;
|
||||
|
||||
if (value >= 0x80000000) {
|
||||
reinterpret_cast<uint32_t*>(&value)[0] = value;
|
||||
reinterpret_cast<uint32_t*>(&value)[1] = -1;
|
||||
}
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
uint64_t MakeLarge(uint32_t low, uint32_t high) {
|
||||
return low + (static_cast<uint64_t>(high) << 32);
|
||||
}
|
||||
12
storm/big/Ops.hpp
Normal file
12
storm/big/Ops.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef STORM_BIG_OPS_HPP
|
||||
#define STORM_BIG_OPS_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
uint32_t ExtractLowPart(uint64_t& value);
|
||||
|
||||
uint32_t ExtractLowPartSx(uint64_t& value);
|
||||
|
||||
uint64_t MakeLarge(uint32_t low, uint32_t high);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue