- lfm's byte swap optimization (faster! improves via, cryptopp)
This optimization (__builtin_bswap32) is only available on gcc 4.3 or later, and it's a bit silly because you can get this optimization from <byteswap.h> via bswap_32() (which is smart enough to use the bswap opcode) on gcc 2.0 or later. AFAIK, as long as you have optimizations turned on, the generated code is identical. I appreciate your work here, I am using your miner on my servers to mine with their idle cpu-time -- the power is already bought, after all. I've attached a patch if you don't want to trust bswap_32() to be equivalent:
Code:
diff --git a/miner.h b/miner.h
index 539b5d6..eef4ee0 100644
--- a/miner.h
+++ b/miner.h
@@ -1,6 +1,7 @@
#ifndef __MINER_H__
#define __MINER_H__
+#include <byteswap.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/time.h>
@@ -24,7 +25,11 @@
static inline uint32_t swab32(uint32_t v)
{
+#if (__GNUC__ >= 4 && __GNUC_PATCHLEVEL__ >= 3)
return __builtin_bswap32(v);
+#else
+ return bswap_32(v);
+#endif
}
static inline void swap256(void *dest_p, const void *src_p)