Commit 0ba5f0f94b1e671b3892857afe66b05180727651

Con Kolivas 2012-11-05T14:02:43

Use a standard function for flipping bytes.

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)