diff --git a/cgminer.c b/cgminer.c index 50b36a3d..e13f3925 100644 --- a/cgminer.c +++ b/cgminer.c @@ -1481,9 +1481,7 @@ static void calc_midstate(struct work *work) sha2_starts(&ctx); sha2_update(&ctx, data, 64); memcpy(work->midstate, ctx.state, 32); -#if defined(__BIG_ENDIAN__) || defined(MIPSEB) - flip32(work->midstate, work->midstate); -#endif + endian_flip32(work->midstate, work->midstate); } static struct work *make_work(void) @@ -2439,9 +2437,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit) cgpu = get_thr_cgpu(thr_id); -#ifdef __BIG_ENDIAN__ - flip128(work->data, work->data); -#endif + endian_flip128(work->data, work->data); /* build hex string */ hexstr = bin2hex(work->data, sizeof(work->data)); diff --git a/miner.h b/miner.h index 243b4d24..49f99c94 100644 --- a/miner.h +++ b/miner.h @@ -670,6 +670,29 @@ static inline void flip128(void *dest_p, const void *src_p) dest[i] = swab32(src[i]); } +/* For flipping to the correct endianness if necessary */ +#if defined(__BIG_ENDIAN__) || defined(MIPSEB) +static inline void endian_flip32(void *dest_p, const void *src_p) +{ + flip32(dest_p, src_p); +} + +static inline void endian_flip128(void *dest_p, const void *src_p) +{ + flip128(dest_p, src_p); +} +#else +static inline void +endian_flip32(void __maybe_unused *dest_p, const void __maybe_unused *src_p) +{ +} + +static inline void +endian_flip128(void __maybe_unused *dest_p, const void __maybe_unused *src_p) +{ +} +#endif + extern void quit(int status, const char *format, ...); static inline void mutex_lock(pthread_mutex_t *lock)