fix cryptonight builds with -O3 or -Ofast

taken from: https://github.com/monero-project/monero/pull/9042
This commit is contained in:
Boog900 2023-10-29 01:02:12 +01:00
parent 3a52b346e1
commit 7559532408
No known key found for this signature in database
GPG key ID: 5401367FB7302004
2 changed files with 6 additions and 4 deletions

View file

@ -21,7 +21,7 @@ fn main() {
.file("c/CryptonightR_JIT.c")
.file("c/CryptonightR_template.S")
.flag("-maes")
.flag("-O2")
.flag("-O3")
.flag("-fexceptions")
.compile("cryptonight")
}

View file

@ -213,16 +213,17 @@ static void E8(hashState *state)
/*The compression function F8 */
static void F8(hashState *state)
{
uint64 i;
uint64_t* x = (uint64_t*)state->x;
const uint64_t* buf = (uint64*)state->buffer;
/*xor the 512-bit message with the fist half of the 1024-bit hash state*/
for (i = 0; i < 8; i++) state->x[i >> 1][i & 1] ^= ((uint64*)state->buffer)[i];
for (int i = 0; i < 8; ++i) x[i] ^= buf[i];
/*the bijective function E8 */
E8(state);
/*xor the 512-bit message with the second half of the 1024-bit hash state*/
for (i = 0; i < 8; i++) state->x[(8+i) >> 1][(8+i) & 1] ^= ((uint64*)state->buffer)[i];
for (int i = 0; i < 8; ++i) x[i + 8] ^= buf[i];
}
/*before hashing a message, initialize the hash state as H0 */
@ -240,6 +241,7 @@ static HashReturn Init(hashState *state, int hashbitlen)
case 224: memcpy(state->x,JH224_H0,128); break;
case 256: memcpy(state->x,JH256_H0,128); break;
case 384: memcpy(state->x,JH384_H0,128); break;
default:
case 512: memcpy(state->x,JH512_H0,128); break;
}