Merge branch 'master' of github.com:ckolivas/cgminer
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/driver-klondike.c b/driver-klondike.c
index a445bf4..2446202 100644
--- a/driver-klondike.c
+++ b/driver-klondike.c
@@ -1432,7 +1432,8 @@ static void get_klondike_statline_before(char *buf, size_t siz, struct cgpu_info
}
rd_unlock(&(klninfo->stat_lock));
fan /= slaves + 1;
- fan *= 100/255;
+ //fan *= 100/255; // <-- You can't do this because int 100 / int 255 == 0
+ fan = 100 * fan / 255;
if (fan > 99) // short on screen space
fan = 99;
clock /= slaves + 1;
diff --git a/sha2.c b/sha2.c
index f1970e1..6777b28 100644
--- a/sha2.c
+++ b/sha2.c
@@ -36,16 +36,6 @@
#include "sha2.h"
-#define SHFR(x, n) (x >> n)
-#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
-#define CH(x, y, z) ((x & y) ^ (~x & z))
-#define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
-
-#define SHA256_F1(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
-#define SHA256_F2(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
-#define SHA256_F3(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3))
-#define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
-
#define UNPACK32(x, str) \
{ \
*((str) + 3) = (uint8_t) ((x) ); \
diff --git a/sha2.h b/sha2.h
index faa4f61..71d4404 100644
--- a/sha2.h
+++ b/sha2.h
@@ -41,6 +41,16 @@
#define SHA256_DIGEST_SIZE ( 256 / 8)
#define SHA256_BLOCK_SIZE ( 512 / 8)
+#define SHFR(x, n) (x >> n)
+#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
+#define CH(x, y, z) ((x & y) ^ (~x & z))
+#define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+
+#define SHA256_F1(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
+#define SHA256_F2(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
+#define SHA256_F3(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3))
+#define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
+
typedef struct {
unsigned int tot_len;
unsigned int len;
@@ -48,6 +58,8 @@ typedef struct {
uint32_t h[8];
} sha256_ctx;
+extern uint32_t sha256_k[64];
+
void sha256_init(sha256_ctx * ctx);
void sha256_update(sha256_ctx *ctx, const unsigned char *message,
unsigned int len);