Commit d4af2d05355722f69464bc1c00981046cc8df14b

Luke Dashjr 2012-07-06T02:39:32

Turn work_restart array into a bool in thr_info

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
diff --git a/cgminer.c b/cgminer.c
index 29ffc38..275f0c6 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -158,8 +158,6 @@ int gpur_thr_id;
 static int api_thr_id;
 static int total_threads;
 
-struct work_restart *work_restart = NULL;
-
 static pthread_mutex_t hash_lock;
 static pthread_mutex_t qd_lock;
 static pthread_mutex_t *stgd_lock;
@@ -2516,7 +2514,7 @@ static void restart_threads(void)
 	queue_request(NULL, true);
 
 	for (i = 0; i < mining_threads; i++)
-		work_restart[i].restart = 1;
+		thr_info[i].work_restart = true;
 
 	mutex_lock(&restart_lock);
 	pthread_cond_broadcast(&restart_cond);
@@ -4021,7 +4019,7 @@ void *miner_thread(void *userdata)
 	gettimeofday(&tv_lastupdate, NULL);
 
 	while (1) {
-		work_restart[thr_id].restart = 0;
+		mythr->work_restart = false;
 		if (api->free_work && likely(work->pool))
 			api->free_work(mythr, work);
 		if (unlikely(!get_work(work, requested, mythr, thr_id))) {
@@ -4076,7 +4074,7 @@ void *miner_thread(void *userdata)
 
 			gettimeofday(&getwork_start, NULL);
 
-			if (unlikely(work_restart[thr_id].restart)) {
+			if (unlikely(mythr->work_restart)) {
 
 				/* Apart from device_thread 0, we stagger the
 				 * starting of every next thread to try and get
@@ -5326,10 +5324,6 @@ int main(int argc, char *argv[])
 	#endif // defined(unix)
 
 	total_threads = mining_threads + 7;
-	work_restart = calloc(total_threads, sizeof(*work_restart));
-	if (!work_restart)
-		quit(1, "Failed to calloc work_restart");
-
 	thr_info = calloc(total_threads, sizeof(*thr));
 	if (!thr_info)
 		quit(1, "Failed to calloc thr_info");
diff --git a/driver-bitforce.c b/driver-bitforce.c
index e73fa6c..06e8ef8 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -308,7 +308,7 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 		return 0;
 
 	while (bitforce->wait_ms < BITFORCE_LONG_TIMEOUT_MS) {
-		if (unlikely(work_restart[thr->id].restart))
+		if (unlikely(thr->work_restart))
 			return 1;
 		mutex_lock(&bitforce->device_mutex);
 		BFwrite(fdDev, "ZFX", 3);
diff --git a/driver-cpu.c b/driver-cpu.c
index 1f8ac89..fb41669 100644
--- a/driver-cpu.c
+++ b/driver-cpu.c
@@ -81,51 +81,51 @@ extern int dev_from_id(int thr_id);
 
 
 /* chipset-optimized hash functions */
-extern bool ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
+extern bool ScanHash_4WaySSE2(struct thr_info*, const unsigned char *pmidstate,
 	unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
 	uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
 
-extern bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
+extern bool ScanHash_altivec_4way(struct thr_info*, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
 	uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
 
-extern bool scanhash_via(int, const unsigned char *pmidstate,
+extern bool scanhash_via(struct thr_info*, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *target,
 	uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
 
-extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
+extern bool scanhash_c(struct thr_info*, const unsigned char *midstate, unsigned char *data,
 	      unsigned char *hash1, unsigned char *hash,
 	      const unsigned char *target,
 	      uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
 
-extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
+extern bool scanhash_cryptopp(struct thr_info*, const unsigned char *midstate,unsigned char *data,
 	      unsigned char *hash1, unsigned char *hash,
 	      const unsigned char *target,
 	      uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
 
-extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
+extern bool scanhash_asm32(struct thr_info*, const unsigned char *midstate,unsigned char *data,
 	      unsigned char *hash1, unsigned char *hash,
 	      const unsigned char *target,
 	      uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
 
-extern bool scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
+extern bool scanhash_sse2_64(struct thr_info*, const unsigned char *pmidstate, unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
 	uint32_t max_nonce, uint32_t *last_nonce,
 	uint32_t nonce);
 
-extern bool scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
+extern bool scanhash_sse4_64(struct thr_info*, const unsigned char *pmidstate, unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
 	uint32_t max_nonce, uint32_t *last_nonce,
 	uint32_t nonce);
 
-extern bool scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
+extern bool scanhash_sse2_32(struct thr_info*, const unsigned char *pmidstate, unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
 	uint32_t max_nonce, uint32_t *last_nonce,
@@ -224,8 +224,7 @@ double bench_algo_stage3(
 	memset(&work, 0, sizeof(work));
 	memcpy(&work, &bench_block, min_size);
 
-	struct work_restart dummy;
-	work_restart = &dummy;
+	struct thr_info dummy = {0};
 
 	struct timeval end;
 	struct timeval start;
@@ -236,7 +235,7 @@ double bench_algo_stage3(
 			{
 				sha256_func func = sha256_funcs[algo];
 				(*func)(
-					0,
+					&dummy,
 					work.midstate,
 					work.data,
 					work.hash1,
@@ -248,7 +247,6 @@ double bench_algo_stage3(
 				);
 			}
 	gettimeofday(&end, 0);
-	work_restart = NULL;
 
 	uint64_t usec_end = ((uint64_t)end.tv_sec)*1000*1000 + end.tv_usec;
 	uint64_t usec_start = ((uint64_t)start.tv_sec)*1000*1000 + start.tv_usec;
@@ -795,7 +793,7 @@ CPUSearch:
 	{
 		sha256_func func = sha256_funcs[opt_algo];
 		rc = (*func)(
-			thr_id,
+			thr,
 			work->midstate,
 			work->data,
 			work->hash1,
diff --git a/driver-cpu.h b/driver-cpu.h
index 59d7557..ced400a 100644
--- a/driver-cpu.h
+++ b/driver-cpu.h
@@ -1,7 +1,7 @@
 #ifndef __DEVICE_CPU_H__
 #define __DEVICE_CPU_H__
 
-#include "miner.h" /* for work_restart, TODO: re-factor dependency */
+#include "miner.h"
 
 #include "config.h"
 #include <stdbool.h>
diff --git a/driver-icarus.c b/driver-icarus.c
index 2fe561e..bcb7d18 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -198,7 +198,7 @@ static void rev(unsigned char *s, size_t l)
 #define icarus_open2(devpath, purge)  serial_open(devpath, 115200, ICARUS_READ_FAULT_DECISECONDS, purge)
 #define icarus_open(devpath)  icarus_open2(devpath, false)
 
-static int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, int thr_id, int read_count)
+static int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct thr_info *thr, int read_count)
 {
 	ssize_t ret = 0;
 	int rc = 0;
@@ -232,7 +232,7 @@ static int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, in
 			return 1;
 		}
 
-		if (thr_id >= 0 && work_restart[thr_id].restart) {
+		if (thr->work_restart) {
 			if (opt_debug) {
 				applog(LOG_DEBUG,
 					"Icarus Read: Work restart at %.2f seconds",
@@ -392,7 +392,10 @@ static bool icarus_detect_one(const char *devpath)
 	gettimeofday(&tv_start, NULL);
 
 	memset(nonce_bin, 0, sizeof(nonce_bin));
-	icarus_gets(nonce_bin, fd, &tv_finish, -1, 1);
+	struct thr_info dummy = {
+		.work_restart = false,
+	};
+	icarus_gets(nonce_bin, fd, &tv_finish, &dummy, 1);
 
 	icarus_close(fd);
 
@@ -474,7 +477,6 @@ static bool icarus_prepare(struct thr_info *thr)
 static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 				__maybe_unused uint64_t max_nonce)
 {
-	const int thr_id = thr->id;
 	struct cgpu_info *icarus;
 	int fd;
 	int ret;
@@ -529,7 +531,7 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	/* Icarus will return 4 bytes (ICARUS_READ_SIZE) nonces or nothing */
 	memset(nonce_bin, 0, sizeof(nonce_bin));
 	info = icarus_info[icarus->device_id];
-	ret = icarus_gets(nonce_bin, fd, &tv_finish, thr_id, info->read_count);
+	ret = icarus_gets(nonce_bin, fd, &tv_finish, thr, info->read_count);
 
 	work->blk.nonce = 0xffffffff;
 	memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin));
diff --git a/driver-modminer.c b/driver-modminer.c
index 5b00aac..88bc3f2 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -390,7 +390,7 @@ fd_set fds;
 	return true;
 }
 
-#define work_restart(thr)  work_restart[thr->id].restart
+#define work_restart(thr)  thr->work_restart
 
 static uint64_t
 modminer_process_results(struct thr_info*thr)
diff --git a/driver-ztex.c b/driver-ztex.c
index db22392..e2b3755 100644
--- a/driver-ztex.c
+++ b/driver-ztex.c
@@ -240,9 +240,9 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
 	overflow = false;
 
 	applog(LOG_DEBUG, "%s: entering poll loop", ztex->repr);
-	while (!(overflow || work_restart[thr->id].restart)) {
+	while (!(overflow || thr->work_restart)) {
 		usleep(250000);
-		if (work_restart[thr->id].restart) {
+		if (thr->work_restart) {
 			applog(LOG_DEBUG, "%s: New work detected", ztex->repr);
 			break;
 		}
@@ -265,7 +265,7 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
 		}
 		ztex_releaseFpga(ztex);
 
-		if (work_restart[thr->id].restart) {
+		if (thr->work_restart) {
 			applog(LOG_DEBUG, "%s: New work detected", ztex->repr);
 			break;
 		}
diff --git a/miner.h b/miner.h
index d3fa209..14dd3bb 100644
--- a/miner.h
+++ b/miner.h
@@ -419,6 +419,8 @@ struct thr_info {
 	bool	pause;
 	bool	getwork;
 	double	rolling;
+
+	bool	work_restart;
 };
 
 extern int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
@@ -553,7 +555,7 @@ extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
 extern char *bin2hex(const unsigned char *p, size_t len);
 extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
 
-typedef bool (*sha256_func)(int thr_id, const unsigned char *pmidstate,
+typedef bool (*sha256_func)(struct thr_info*, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
@@ -565,11 +567,6 @@ extern bool fulltest(const unsigned char *hash, const unsigned char *target);
 
 extern int opt_scantime;
 
-struct work_restart {
-	volatile unsigned long	restart;
-	char			padding[128 - sizeof(unsigned long)];
-};
-
 extern pthread_mutex_t restart_lock;
 extern pthread_cond_t restart_cond;
 
@@ -609,7 +606,6 @@ extern int num_processors;
 extern int hw_errors;
 extern bool use_syslog;
 extern struct thr_info *thr_info;
-extern struct work_restart *work_restart;
 extern struct cgpu_info gpus[MAX_GPUDEVICES];
 extern int gpu_threads;
 extern double total_secs;
diff --git a/sha256_4way.c b/sha256_4way.c
index 35116a6..d7d03ac 100644
--- a/sha256_4way.c
+++ b/sha256_4way.c
@@ -100,7 +100,7 @@ static const unsigned int pSHA256InitState[8] =
 {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
 
 
-bool ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
+bool ScanHash_4WaySSE2(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
@@ -139,7 +139,7 @@ bool ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
             }
         }
 
-        if ((nonce >= max_nonce) || work_restart[thr_id].restart)
+        if ((nonce >= max_nonce) || thr->work_restart)
         {
             *last_nonce = nonce;
             return false;
diff --git a/sha256_altivec_4way.c b/sha256_altivec_4way.c
index cb3351c..f9d8429 100644
--- a/sha256_altivec_4way.c
+++ b/sha256_altivec_4way.c
@@ -73,7 +73,7 @@ static const unsigned int pSHA256InitState[8] =
 {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
 
 
-bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
+bool ScanHash_altivec_4way(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
@@ -111,7 +111,7 @@ bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
             }
         }
 
-        if ((nonce >= max_nonce) || work_restart[thr_id].restart)
+        if ((nonce >= max_nonce) || thr->work_restart)
         {
             *last_nonce = nonce;
             return false;
diff --git a/sha256_cryptopp.c b/sha256_cryptopp.c
index aab8bba..607f0c4 100644
--- a/sha256_cryptopp.c
+++ b/sha256_cryptopp.c
@@ -93,7 +93,7 @@ static void runhash(void *state, const void *input, const void *init)
 }
 
 /* suspiciously similar to ScanHash* from bitcoin */
-bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
+bool scanhash_cryptopp(struct thr_info*thr, const unsigned char *midstate,
 		unsigned char *data,
 	        unsigned char *hash1, unsigned char *hash,
 		const unsigned char *target,
@@ -105,8 +105,6 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
 
 	data += 64;
 
-	work_restart[thr_id].restart = 0;
-
 	while (1) {
 		n++;
 		*nonce = n;
@@ -119,7 +117,7 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
 			return true;
 		}
 
-		if ((n >= max_nonce) || work_restart[thr_id].restart) {
+		if ((n >= max_nonce) || thr->work_restart) {
 			*last_nonce = n;
 			return false;
 		}
@@ -577,7 +575,7 @@ static void runhash32(void *state, const void *input, const void *init)
 }
 
 /* suspiciously similar to ScanHash* from bitcoin */
-bool scanhash_asm32(int thr_id, const unsigned char *midstate,
+bool scanhash_asm32(struct thr_info*thr, const unsigned char *midstate,
 		unsigned char *data,
 	        unsigned char *hash1, unsigned char *hash,
 		const unsigned char *target,
@@ -601,7 +599,7 @@ bool scanhash_asm32(int thr_id, const unsigned char *midstate,
 			return true;
 		}
 
-		if ((n >= max_nonce) || work_restart[thr_id].restart) {
+		if ((n >= max_nonce) || thr->work_restart) {
 			*last_nonce = n;
 			return false;
 		}
diff --git a/sha256_generic.c b/sha256_generic.c
index 95591fe..8badf29 100644
--- a/sha256_generic.c
+++ b/sha256_generic.c
@@ -239,7 +239,7 @@ const uint32_t sha256_init_state[8] = {
 };
 
 /* suspiciously similar to ScanHash* from bitcoin */
-bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
+bool scanhash_c(struct thr_info*thr, const unsigned char *midstate, unsigned char *data,
 	        unsigned char *hash1, unsigned char *hash,
 		const unsigned char *target,
 	        uint32_t max_nonce, uint32_t *last_nonce,
@@ -265,7 +265,7 @@ bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
 			return true;
 		}
 
-		if ((n >= max_nonce) || work_restart[thr_id].restart) {
+		if ((n >= max_nonce) || thr->work_restart) {
 			*last_nonce = n;
 			return false;
 		}
diff --git a/sha256_sse2_amd64.c b/sha256_sse2_amd64.c
index a109e8a..65a9390 100644
--- a/sha256_sse2_amd64.c
+++ b/sha256_sse2_amd64.c
@@ -48,7 +48,7 @@ const uint32_t sha256_init[8]__attribute__((aligned(0x100))) =
 __m128i g_4sha256_k[64];
 __m128i sha256_consts_m128i[64]__attribute__((aligned(0x1000)));
 
-bool scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
+bool scanhash_sse2_64(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
@@ -119,7 +119,7 @@ bool scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
 		}
 	}
 
-        if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
+        if (unlikely((nonce >= max_nonce) || thr->work_restart))
         {
 			*last_nonce = nonce;
 			return false;
diff --git a/sha256_sse2_i386.c b/sha256_sse2_i386.c
index 669781a..30d9ef1 100644
--- a/sha256_sse2_i386.c
+++ b/sha256_sse2_i386.c
@@ -48,7 +48,7 @@ const uint32_t sha256_32init[8]__attribute__((aligned(0x100))) =
 __m128i g_4sha256_k[64];
 __m128i sha256_consts_m128i[64]__attribute__((aligned(0x1000)));
 
-bool scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
+bool scanhash_sse2_32(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
@@ -111,7 +111,7 @@ bool scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
 	    }
 	}
 
-	if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart)) {
+	if (unlikely((nonce >= max_nonce) || thr->work_restart)) {
 		*last_nonce = nonce;
 		return false;
 	}
diff --git a/sha256_sse4_amd64.c b/sha256_sse4_amd64.c
index a9cd685..78d7490 100644
--- a/sha256_sse4_amd64.c
+++ b/sha256_sse4_amd64.c
@@ -47,7 +47,7 @@ static uint32_t g_sha256_hinit[8] =
 
 __m128i g_4sha256_k[64];
 
-bool scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
+bool scanhash_sse4_64(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *pdata,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *ptarget,
@@ -118,7 +118,7 @@ bool scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
 		}
 	}
 
-        if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
+        if (unlikely((nonce >= max_nonce) || thr->work_restart))
         {
 			*last_nonce = nonce;
 			return false;
diff --git a/sha256_via.c b/sha256_via.c
index 35f4262..05fdb3e 100644
--- a/sha256_via.c
+++ b/sha256_via.c
@@ -19,7 +19,7 @@ static void via_sha256(void *hash, void *buf, unsigned len)
 		     :"memory");
 }
 
-bool scanhash_via(int thr_id, const unsigned char *pmidstate,
+bool scanhash_via(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *data_inout,
 	unsigned char *phash1, unsigned char *phash,
 	const unsigned char *target,
@@ -74,7 +74,7 @@ bool scanhash_via(int thr_id, const unsigned char *pmidstate,
 			return true;
 		}
 
-		if ((n >= max_nonce) || work_restart[thr_id].restart) {
+		if ((n >= max_nonce) || thr->work_restart) {
 			*last_nonce = n;
 			return false;
 		}