1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-31 08:54:19 +00:00

VS2010 build: revert le256todouble() cast/ref/deref change.

Introduced by commit 87e5f35745321132cea3e5b21ddb7d69e8a8eb0f

The cast/ref/deref is performed wrong and breaks share/best share display.
It is not the value of target that should be increased, but its address.

If all else fails, add an `#ifdef _MSVC_VER`; we should avoid it if possible.

In either case, constructs like `&(*(((uint64_t *)target) + 24))` must be
explained (in a comment).
This commit is contained in:
Noel Maersk 2014-01-28 20:30:00 +02:00
parent 8d25b38e9b
commit d9eb547c5a

View File

@ -2901,16 +2901,16 @@ static double le256todouble(const void *target)
uint64_t *data64; uint64_t *data64;
double dcut64; double dcut64;
data64 = &(*(((uint64_t *)target) + 24)); data64 = (uint64_t *)(target + 24);
dcut64 = le64toh(*data64) * bits192; dcut64 = le64toh(*data64) * bits192;
data64 = &(*(((uint64_t *)target) + 16)); data64 = (uint64_t *)(target + 16);
dcut64 += le64toh(*data64) * bits128; dcut64 += le64toh(*data64) * bits128;
data64 = &(*(((uint64_t *)target) + 8)); data64 = (uint64_t *)(target + 8);
dcut64 += le64toh(*data64) * bits64; dcut64 += le64toh(*data64) * bits64;
data64 = (uint64_t *)(target); data64 = (uint64_t *)target;
dcut64 += le64toh(*data64); dcut64 += le64toh(*data64);
return dcut64; return dcut64;
@ -3557,6 +3557,7 @@ static uint64_t share_diff(const struct work *work)
s64 = 0; s64 = 0;
ret = round(d64 / s64); ret = round(d64 / s64);
applog(LOG_DEBUG, "Found share with difficulty %lu", ret);
cg_wlock(&control_lock); cg_wlock(&control_lock);
if (unlikely(ret > best_diff)) { if (unlikely(ret > best_diff)) {