Backport changes from xmrig-aeon.
This commit is contained in:
parent
3de7983826
commit
caf7cda1d5
4 changed files with 31 additions and 67 deletions
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mm_malloc.h>
|
||||
|
||||
#ifndef BUILD_TEST
|
||||
# include "xmrig.h"
|
||||
|
@ -35,7 +36,6 @@
|
|||
#include "crypto/c_skein.h"
|
||||
#include "cryptonight.h"
|
||||
#include "options.h"
|
||||
#include "utils/applog.h"
|
||||
|
||||
|
||||
const static char test_input[76] = {
|
||||
|
@ -68,13 +68,13 @@ void (*cryptonight_hash_ctx)(const void* input, size_t size, void* output, struc
|
|||
static bool self_test() {
|
||||
char output[32];
|
||||
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) malloc(sizeof(struct cryptonight_ctx));
|
||||
ctx->memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) _mm_malloc(sizeof(struct cryptonight_ctx), 16);
|
||||
ctx->memory = (uint8_t *) _mm_malloc(MEMORY, 16);
|
||||
|
||||
cryptonight_hash_ctx(test_input, sizeof(test_input), output, ctx);
|
||||
|
||||
free(ctx->memory);
|
||||
free(ctx);
|
||||
_mm_free(ctx->memory);
|
||||
_mm_free(ctx);
|
||||
|
||||
return memcmp(output, test_output, 32) == 0;
|
||||
}
|
||||
|
@ -139,20 +139,18 @@ void (* const extra_hashes[4])(const void *, size_t, char *) = {do_blake_hash, d
|
|||
#ifndef BUILD_TEST
|
||||
int scanhash_cryptonight(int thr_id, uint32_t *hash, uint32_t *restrict blob, size_t blob_size, uint32_t target, uint32_t max_nonce, unsigned long *restrict hashes_done, struct cryptonight_ctx *restrict ctx) {
|
||||
uint32_t *nonceptr = (uint32_t*) (((char*) blob) + 39);
|
||||
uint32_t n = *nonceptr - 1;
|
||||
const uint32_t first_nonce = n + 1;
|
||||
|
||||
do {
|
||||
*nonceptr = ++n;
|
||||
cryptonight_hash_ctx(blob, blob_size, hash, ctx);
|
||||
(*hashes_done)++;
|
||||
|
||||
if (unlikely(hash[7] < target)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
} while (likely((n <= max_nonce && !work_restart[thr_id].restart)));
|
||||
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
(*nonceptr)++;
|
||||
} while (likely(((*nonceptr) < max_nonce && !work_restart[thr_id].restart)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue