From 8d81f1d20704c00dea3754f03010ea5000b37635 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 22 Apr 2013 09:28:06 +1000 Subject: [PATCH] Provide a flip128 helper to simplify big endian flipping. --- cgminer.c | 4 +--- miner.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cgminer.c b/cgminer.c index cf43719f..50b36a3d 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2440,9 +2440,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit) cgpu = get_thr_cgpu(thr_id); #ifdef __BIG_ENDIAN__ - int swapcounter = 0; - for (swapcounter = 0; swapcounter < 32; swapcounter++) - (((uint32_t*) (work->data))[swapcounter]) = swab32(((uint32_t*) (work->data))[swapcounter]); + flip128(work->data, work->data); #endif /* build hex string */ diff --git a/miner.h b/miner.h index 2d2e7093..243b4d24 100644 --- a/miner.h +++ b/miner.h @@ -660,6 +660,16 @@ static inline void flip80(void *dest_p, const void *src_p) dest[i] = swab32(src[i]); } +static inline void flip128(void *dest_p, const void *src_p) +{ + uint32_t *dest = dest_p; + const uint32_t *src = src_p; + int i; + + for (i = 0; i < 32; i++) + dest[i] = swab32(src[i]); +} + extern void quit(int status, const char *format, ...); static inline void mutex_lock(pthread_mutex_t *lock)