mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-26 14:34:16 +00:00
Merge pull request #203 from xiangfu/openwrt
Fix a swab32 bug under work_decode on MIPS cpu machine
This commit is contained in:
commit
b69d735cfe
@ -7,6 +7,10 @@
|
|||||||
* any later version. See COPYING for more details.
|
* any later version. See COPYING for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Compile:
|
||||||
|
* gcc api-example.c -I compat/jansson -o cgminer-api
|
||||||
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
17
cgminer.c
17
cgminer.c
@ -1182,6 +1182,11 @@ static bool work_decode(const json_t *val, struct work *work)
|
|||||||
sha2_starts( &ctx, 0 );
|
sha2_starts( &ctx, 0 );
|
||||||
sha2_update( &ctx, data.c, 64 );
|
sha2_update( &ctx, data.c, 64 );
|
||||||
memcpy(work->midstate, ctx.state, sizeof(work->midstate));
|
memcpy(work->midstate, ctx.state, sizeof(work->midstate));
|
||||||
|
#if defined(__BIG_ENDIAN__) || defined(MIPSEB)
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
(((uint32_t*) (work->midstate))[i]) = swab32(((uint32_t*) (work->midstate))[i]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likely(!jobj_binary(val, "hash1", work->hash1, sizeof(work->hash1), false))) {
|
if (likely(!jobj_binary(val, "hash1", work->hash1, sizeof(work->hash1), false))) {
|
||||||
@ -1196,18 +1201,6 @@ static bool work_decode(const json_t *val, struct work *work)
|
|||||||
|
|
||||||
memset(work->hash, 0, sizeof(work->hash));
|
memset(work->hash, 0, sizeof(work->hash));
|
||||||
|
|
||||||
#ifdef __BIG_ENDIAN__
|
|
||||||
int swapcounter = 0;
|
|
||||||
for (swapcounter = 0; swapcounter < 32; swapcounter++)
|
|
||||||
(((uint32_t*) (work->data))[swapcounter]) = swab32(((uint32_t*) (work->data))[swapcounter]);
|
|
||||||
for (swapcounter = 0; swapcounter < 16; swapcounter++)
|
|
||||||
(((uint32_t*) (work->hash1))[swapcounter]) = swab32(((uint32_t*) (work->hash1))[swapcounter]);
|
|
||||||
for (swapcounter = 0; swapcounter < 8; swapcounter++)
|
|
||||||
(((uint32_t*) (work->midstate))[swapcounter]) = swab32(((uint32_t*) (work->midstate))[swapcounter]);
|
|
||||||
for (swapcounter = 0; swapcounter < 8; swapcounter++)
|
|
||||||
(((uint32_t*) (work->target))[swapcounter]) = swab32(((uint32_t*) (work->target))[swapcounter]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gettimeofday(&work->tv_staged, NULL);
|
gettimeofday(&work->tv_staged, NULL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -350,7 +350,7 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|||||||
return ESTIMATE_HASHES;
|
return ESTIMATE_HASHES;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __BIG_ENDIAN__
|
#if !defined (__BIG_ENDIAN__) && !defined(MIPSEB)
|
||||||
nonce = swab32(nonce);
|
nonce = swab32(nonce);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user