Use a standard function for flipping bytes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/cgminer.c b/cgminer.c
index d7049f6..bc86c9c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2300,13 +2300,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
unsigned char data[80];
int i;
- for (i = 0; i < 80 / 4; i++) {
- uint32_t *src32, *dst32;
-
- src32 = (uint32_t *)&work->data[i * 4];
- dst32 = (uint32_t *)&data[i * 4];
- *dst32 = swab32(*src32);
- }
+ flip256(data, work->data);
header = bin2hex(data, 80);
sprintf(gbt_block, "%s", header);
free(header);
diff --git a/miner.h b/miner.h
index 0f37b87..91b0300 100644
--- a/miner.h
+++ b/miner.h
@@ -544,6 +544,16 @@ static inline void swab256(void *dest_p, const void *src_p)
dest[7] = swab32(src[0]);
}
+static inline void flip256(void *dest_p, const void *src_p)
+{
+ uint32_t *dest = dest_p;
+ const uint32_t *src = src_p;
+ int i;
+
+ for (i = 0; i < 8; i++)
+ dest[i] = swab32(src[i]);
+}
+
extern void quit(int status, const char *format, ...);
static inline void mutex_lock(pthread_mutex_t *lock)