Commit e1dd27c5c2603021baa1b4896a6409234ea04caf

ckolivas 2011-06-29T11:19:43

Ensure that we don't overflow due to 32 bit limitations.

diff --git a/cpu-miner.c b/cpu-miner.c
index 43f004d..a2591a2 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -933,7 +933,7 @@ static void *gpuminer_thread(void *userdata)
 
 		/* This finish flushes the readbuffer set with CL_FALSE later */
 		clFinish(clState->commandQueue);
-		if (diff.tv_sec > opt_scantime  || work->blk.nonce > MAXTHREADS - hashes || work_restart[thr_id].restart) {
+		if (diff.tv_sec > opt_scantime  || work->blk.nonce >= MAXTHREADS - hashes || work_restart[thr_id].restart) {
 			/* Ignore any reads since we're getting new work and queue a clean buffer */
 			status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
 					BUFFERSIZE, blank_res, 0, NULL, NULL);
diff --git a/findnonce.h b/findnonce.h
index 7ca8f70..34e28d0 100644
--- a/findnonce.h
+++ b/findnonce.h
@@ -2,7 +2,7 @@
 #define __FINDNONCE_H__
 #include "miner.h"
 
-#define MAXTHREADS (0xFFFFFFFF)
+#define MAXTHREADS (0xFFFFFFFEULL)
 #define BUFFERSIZE (sizeof(uint32_t) * 128)
 
 extern void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data);