mirror of
https://github.com/wownero/RandomX.git
synced 2026-10-20 00:38:48 +02:00
Preserve floating point state when calling randomx_calculate_hash
This commit is contained in:
@@ -36,6 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "cpu.hpp"
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <cfenv>
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -349,6 +350,8 @@ extern "C" {
|
||||
assert(machine != nullptr);
|
||||
assert(inputSize == 0 || input != nullptr);
|
||||
assert(output != nullptr);
|
||||
fenv_t fpstate;
|
||||
fegetenv(&fpstate);
|
||||
alignas(16) uint64_t tempHash[8];
|
||||
int blakeResult = blake2b(tempHash, sizeof(tempHash), input, inputSize, nullptr, 0);
|
||||
assert(blakeResult == 0);
|
||||
@@ -361,6 +364,7 @@ extern "C" {
|
||||
}
|
||||
machine->run(&tempHash);
|
||||
machine->getFinalResult(output, RANDOMX_HASH_SIZE);
|
||||
fesetenv(&fpstate);
|
||||
}
|
||||
|
||||
void randomx_calculate_hash_first(randomx_vm* machine, const void* input, size_t inputSize) {
|
||||
|
||||
Reference in New Issue
Block a user