Browse Source

Replace swabn with bswap_32mult (matching swap32yes parameters and performance)

Luke Dashjr 11 years ago
parent
commit
ce5a2c0f31
2 changed files with 8 additions and 17 deletions
  1. 1 1
      driver-zeusminer.c
  2. 7 16
      miner.h

+ 1 - 1
driver-zeusminer.c

@@ -215,7 +215,7 @@ bool zeusminer_job_prepare(struct thr_info *thr, struct work *work, __maybe_unus
 	uint32_t header = clk_header + target_me;
 	uint32_t header = clk_header + target_me;
 	
 	
 	pk_u32be(state->ob_bin, 0, header);
 	pk_u32be(state->ob_bin, 0, header);
-	swabn(state->ob_bin + 4, work->data, 80);
+	bswap_32mult(&state->ob_bin[4], work->data, 80/4);
 	
 	
 	return true;
 	return true;
 }
 }

+ 7 - 16
miner.h

@@ -746,24 +746,15 @@ void bswap_96p(void * const dest_p, const void * const src_p)
 }
 }
 
 
 static inline
 static inline
-void swabn(void * const dest_p, const void * const src_p, size_t sz)
+void bswap_32mult(void * const dest_p, const void * const src_p, const size_t sz)
 {
 {
-	char *s = (char *)src_p;
-	char *d = (char *)dest_p + sz - 1;
+	const uint32_t *s = src_p;
+	const uint32_t *s_end = &s[sz];
+	uint32_t *d = dest_p;
+	d = &d[sz - 1];
 	
 	
-	if (src_p == dest_p)
-	{
-		char t;
-		for (sz /= 2; sz > 0; --sz, ++s, --d)
-		{
-			t = *s;
-			*s = *d;
-			*d = t;
-		}
-	}
-	else
-		for ( ; sz > 0; --sz, ++s, --d)
-			*d = *s;
+	for ( ; s < s_end; ++s, --d)
+		*d = bswap_32(*s);
 }
 }
 
 
 #define flip32(dest_p, src_p) swap32yes(dest_p, src_p, 32 / 4)
 #define flip32(dest_p, src_p) swap32yes(dest_p, src_p, 32 / 4)