miner.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. #ifndef __MINER_H__
  2. #define __MINER_H__
  3. #include "config.h"
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #include <sys/time.h>
  7. #include <pthread.h>
  8. #include <jansson.h>
  9. #include <curl/curl.h>
  10. #include "elist.h"
  11. #include "uthash.h"
  12. #include "logging.h"
  13. #ifdef HAVE_OPENCL
  14. #include "CL/cl.h"
  15. #endif /* HAVE_OPENCL */
  16. #ifdef STDC_HEADERS
  17. # include <stdlib.h>
  18. # include <stddef.h>
  19. #else
  20. # ifdef HAVE_STDLIB_H
  21. # include <stdlib.h>
  22. # endif
  23. #endif
  24. #ifdef HAVE_ALLOCA_H
  25. # include <alloca.h>
  26. #elif defined __GNUC__
  27. # ifndef WIN32
  28. # define alloca __builtin_alloca
  29. # else
  30. # include <malloc.h>
  31. # endif
  32. #elif defined _AIX
  33. # define alloca __alloca
  34. #elif defined _MSC_VER
  35. # include <malloc.h>
  36. # define alloca _alloca
  37. #else
  38. # ifndef HAVE_ALLOCA
  39. # ifdef __cplusplus
  40. extern "C"
  41. # endif
  42. void *alloca (size_t);
  43. # endif
  44. #endif
  45. #if defined (__linux)
  46. #ifndef LINUX
  47. #define LINUX
  48. #endif
  49. #endif
  50. #ifdef HAVE_ADL
  51. #include "ADL_SDK/adl_sdk.h"
  52. #endif
  53. #ifdef HAVE_LIBUSB
  54. #include <libusb-1.0/libusb.h>
  55. #endif
  56. #ifdef USE_ZTEX
  57. #include "libztex.h"
  58. #endif
  59. #if !defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  60. #define bswap_16 __builtin_bswap16
  61. #define bswap_32 __builtin_bswap32
  62. #define bswap_64 __builtin_bswap64
  63. #else
  64. #if HAVE_BYTESWAP_H
  65. #include <byteswap.h>
  66. #elif defined(USE_SYS_ENDIAN_H)
  67. #include <sys/endian.h>
  68. #elif defined(__APPLE__)
  69. #include <libkern/OSByteOrder.h>
  70. #define bswap_16 OSSwapInt16
  71. #define bswap_32 OSSwapInt32
  72. #define bswap_64 OSSwapInt64
  73. #else
  74. #define bswap_16(value) \
  75. ((((value) & 0xff) << 8) | ((value) >> 8))
  76. #define bswap_32(value) \
  77. (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
  78. (uint32_t)bswap_16((uint16_t)((value) >> 16)))
  79. #define bswap_64(value) \
  80. (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
  81. << 32) | \
  82. (uint64_t)bswap_32((uint32_t)((value) >> 32)))
  83. #endif
  84. #endif /* !defined(__GLXBYTEORDER_H__) */
  85. /* This assumes htobe32 is a macro in endian.h */
  86. #ifndef htobe32
  87. # if __BYTE_ORDER == __LITTLE_ENDIAN
  88. # define be32toh(x) bswap_32(x)
  89. # define htobe32(x) bswap_32(x)
  90. # elif __BYTE_ORDER == __BIG_ENDIAN
  91. # define be32toh(x) (x)
  92. # define htobe32(x) (x)
  93. #else
  94. #error UNKNOWN BYTE ORDER
  95. #endif
  96. #endif
  97. #undef unlikely
  98. #undef likely
  99. #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
  100. #define unlikely(expr) (__builtin_expect(!!(expr), 0))
  101. #define likely(expr) (__builtin_expect(!!(expr), 1))
  102. #else
  103. #define unlikely(expr) (expr)
  104. #define likely(expr) (expr)
  105. #endif
  106. #define __maybe_unused __attribute__((unused))
  107. #define uninitialised_var(x) x = x
  108. #if defined(__i386__)
  109. #define WANT_CRYPTOPP_ASM32
  110. #endif
  111. #ifndef ARRAY_SIZE
  112. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  113. #endif
  114. enum alive {
  115. LIFE_WELL,
  116. LIFE_SICK,
  117. LIFE_DEAD,
  118. LIFE_NOSTART
  119. };
  120. enum pool_strategy {
  121. POOL_FAILOVER,
  122. POOL_ROUNDROBIN,
  123. POOL_ROTATE,
  124. POOL_LOADBALANCE,
  125. };
  126. #define TOP_STRATEGY (POOL_LOADBALANCE)
  127. struct strategies {
  128. const char *s;
  129. };
  130. struct cgpu_info;
  131. #ifdef HAVE_ADL
  132. struct gpu_adl {
  133. ADLTemperature lpTemperature;
  134. int iAdapterIndex;
  135. int lpAdapterID;
  136. int iBusNumber;
  137. char strAdapterName[256];
  138. ADLPMActivity lpActivity;
  139. ADLODParameters lpOdParameters;
  140. ADLODPerformanceLevels *DefPerfLev;
  141. ADLFanSpeedInfo lpFanSpeedInfo;
  142. ADLFanSpeedValue lpFanSpeedValue;
  143. ADLFanSpeedValue DefFanSpeedValue;
  144. int iEngineClock;
  145. int iMemoryClock;
  146. int iVddc;
  147. int iPercentage;
  148. bool autofan;
  149. bool autoengine;
  150. bool managed; /* Were the values ever changed on this card */
  151. int lastengine;
  152. int lasttemp;
  153. int targetfan;
  154. int targettemp;
  155. int overtemp;
  156. int minspeed;
  157. int maxspeed;
  158. int gpu;
  159. bool has_fanspeed;
  160. struct gpu_adl *twin;
  161. };
  162. #endif
  163. struct thr_info;
  164. struct work;
  165. struct device_api {
  166. const char*dname;
  167. const char*name;
  168. // API-global functions
  169. void (*api_detect)();
  170. // Device-specific functions
  171. void (*reinit_device)(struct cgpu_info*);
  172. void (*get_statline_before)(char*, struct cgpu_info*);
  173. void (*get_statline)(char*, struct cgpu_info*);
  174. json_t* (*get_extra_device_detail)(struct cgpu_info*);
  175. json_t* (*get_extra_device_status)(struct cgpu_info*);
  176. json_t* (*get_extra_device_perf_stats)(struct cgpu_info*);
  177. // Thread-specific functions
  178. bool (*thread_prepare)(struct thr_info*);
  179. uint64_t (*can_limit_work)(struct thr_info*);
  180. bool (*thread_init)(struct thr_info*);
  181. void (*free_work)(struct thr_info*, struct work*);
  182. bool (*prepare_work)(struct thr_info*, struct work*);
  183. uint64_t (*scanhash)(struct thr_info*, struct work*, uint64_t);
  184. void (*thread_shutdown)(struct thr_info*);
  185. };
  186. enum dev_enable {
  187. DEV_ENABLED,
  188. DEV_DISABLED,
  189. DEV_RECOVER,
  190. };
  191. enum cl_kernels {
  192. KL_NONE,
  193. KL_POCLBM,
  194. KL_PHATK,
  195. KL_DIAKGCN,
  196. KL_DIABLO,
  197. };
  198. enum dev_reason {
  199. REASON_THREAD_FAIL_INIT,
  200. REASON_THREAD_ZERO_HASH,
  201. REASON_THREAD_FAIL_QUEUE,
  202. REASON_DEV_SICK_IDLE_60,
  203. REASON_DEV_DEAD_IDLE_600,
  204. REASON_DEV_NOSTART,
  205. REASON_DEV_OVER_HEAT,
  206. REASON_DEV_THERMAL_CUTOFF,
  207. };
  208. #define REASON_NONE "None"
  209. #define REASON_THREAD_FAIL_INIT_STR "Thread failed to init"
  210. #define REASON_THREAD_ZERO_HASH_STR "Thread got zero hashes"
  211. #define REASON_THREAD_FAIL_QUEUE_STR "Thread failed to queue work"
  212. #define REASON_DEV_SICK_IDLE_60_STR "Device idle for 60s"
  213. #define REASON_DEV_DEAD_IDLE_600_STR "Device dead - idle for 600s"
  214. #define REASON_DEV_NOSTART_STR "Device failed to start"
  215. #define REASON_DEV_OVER_HEAT_STR "Device over heated"
  216. #define REASON_DEV_THERMAL_CUTOFF_STR "Device reached thermal cutoff"
  217. #define REASON_UNKNOWN_STR "Unknown reason - code bug"
  218. #define MIN_SEC_UNSET 99999999
  219. struct cgminer_stats {
  220. uint32_t getwork_calls;
  221. struct timeval getwork_wait;
  222. struct timeval getwork_wait_max;
  223. struct timeval getwork_wait_min;
  224. };
  225. struct cgpu_info {
  226. int cgminer_id;
  227. const struct device_api *api;
  228. int device_id;
  229. const char *name;
  230. const char *device_path;
  231. FILE *device_file;
  232. union {
  233. #ifdef USE_ZTEX
  234. struct libztex_device *device_ztex;
  235. #endif
  236. int device_fd;
  237. };
  238. enum dev_enable deven;
  239. int accepted;
  240. int rejected;
  241. int hw_errors;
  242. double rolling;
  243. double total_mhashes;
  244. double utility;
  245. enum alive status;
  246. char init[40];
  247. struct timeval last_message_tv;
  248. int threads;
  249. struct thr_info *thread;
  250. unsigned int max_hashes;
  251. bool mapped;
  252. int virtual_gpu;
  253. int virtual_adl;
  254. int intensity;
  255. bool dynamic;
  256. const char *kname;
  257. #ifdef HAVE_OPENCL
  258. cl_uint vwidth;
  259. size_t work_size;
  260. enum cl_kernels kernel;
  261. #endif
  262. float temp;
  263. int cutofftemp;
  264. #ifdef HAVE_ADL
  265. bool has_adl;
  266. struct gpu_adl adl;
  267. int gpu_engine;
  268. int min_engine;
  269. int gpu_fan;
  270. int min_fan;
  271. int gpu_memclock;
  272. int gpu_memdiff;
  273. int gpu_powertune;
  274. float gpu_vddc;
  275. #endif
  276. int last_share_pool;
  277. time_t last_share_pool_time;
  278. time_t device_last_well;
  279. time_t device_last_not_well;
  280. enum dev_reason device_not_well_reason;
  281. int thread_fail_init_count;
  282. int thread_zero_hash_count;
  283. int thread_fail_queue_count;
  284. int dev_sick_idle_60_count;
  285. int dev_dead_idle_600_count;
  286. int dev_nostart_count;
  287. int dev_over_heat_count; // It's a warning but worth knowing
  288. int dev_thermal_cutoff_count;
  289. struct cgminer_stats cgminer_stats;
  290. };
  291. extern bool add_cgpu(struct cgpu_info*);
  292. struct thread_q {
  293. struct list_head q;
  294. bool frozen;
  295. pthread_mutex_t mutex;
  296. pthread_cond_t cond;
  297. };
  298. struct thr_info {
  299. int id;
  300. int device_thread;
  301. pthread_t pth;
  302. struct thread_q *q;
  303. struct cgpu_info *cgpu;
  304. void *cgpu_data;
  305. struct timeval last;
  306. struct timeval sick;
  307. bool pause;
  308. bool getwork;
  309. double rolling;
  310. };
  311. extern int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
  312. extern void thr_info_cancel(struct thr_info *thr);
  313. extern void thr_info_freeze(struct thr_info *thr);
  314. struct string_elist {
  315. char *string;
  316. bool free_me;
  317. struct list_head list;
  318. };
  319. static inline void string_elist_add(const char *s, struct list_head *head)
  320. {
  321. struct string_elist *n;
  322. n = calloc(1, sizeof(*n));
  323. n->string = strdup(s);
  324. n->free_me = true;
  325. list_add_tail(&n->list, head);
  326. }
  327. static inline void string_elist_del(struct string_elist *item)
  328. {
  329. if (item->free_me)
  330. free(item->string);
  331. list_del(&item->list);
  332. }
  333. static inline uint32_t swab32(uint32_t v)
  334. {
  335. return bswap_32(v);
  336. }
  337. static inline void swap256(void *dest_p, const void *src_p)
  338. {
  339. uint32_t *dest = dest_p;
  340. const uint32_t *src = src_p;
  341. dest[0] = src[7];
  342. dest[1] = src[6];
  343. dest[2] = src[5];
  344. dest[3] = src[4];
  345. dest[4] = src[3];
  346. dest[5] = src[2];
  347. dest[6] = src[1];
  348. dest[7] = src[0];
  349. }
  350. extern void quit(int status, const char *format, ...);
  351. static inline void mutex_lock(pthread_mutex_t *lock)
  352. {
  353. if (unlikely(pthread_mutex_lock(lock)))
  354. quit(1, "WTF MUTEX ERROR ON LOCK!");
  355. }
  356. static inline void mutex_unlock(pthread_mutex_t *lock)
  357. {
  358. if (unlikely(pthread_mutex_unlock(lock)))
  359. quit(1, "WTF MUTEX ERROR ON UNLOCK!");
  360. }
  361. static inline void wr_lock(pthread_rwlock_t *lock)
  362. {
  363. if (unlikely(pthread_rwlock_wrlock(lock)))
  364. quit(1, "WTF WRLOCK ERROR ON LOCK!");
  365. }
  366. static inline void rd_lock(pthread_rwlock_t *lock)
  367. {
  368. if (unlikely(pthread_rwlock_rdlock(lock)))
  369. quit(1, "WTF RDLOCK ERROR ON LOCK!");
  370. }
  371. static inline void rw_unlock(pthread_rwlock_t *lock)
  372. {
  373. if (unlikely(pthread_rwlock_unlock(lock)))
  374. quit(1, "WTF RWLOCK ERROR ON UNLOCK!");
  375. }
  376. static inline void rd_unlock(pthread_rwlock_t *lock)
  377. {
  378. rw_unlock(lock);
  379. }
  380. static inline void wr_unlock(pthread_rwlock_t *lock)
  381. {
  382. rw_unlock(lock);
  383. }
  384. static inline void mutex_init(pthread_mutex_t *lock)
  385. {
  386. if (unlikely(pthread_mutex_init(lock, NULL)))
  387. quit(1, "Failed to pthread_mutex_init");
  388. }
  389. static inline void rwlock_init(pthread_rwlock_t *lock)
  390. {
  391. if (unlikely(pthread_rwlock_init(lock, NULL)))
  392. quit(1, "Failed to pthread_rwlock_init");
  393. }
  394. struct pool;
  395. extern bool opt_protocol;
  396. extern char *opt_kernel_path;
  397. extern char *opt_socks_proxy;
  398. extern char *cgminer_path;
  399. extern bool opt_autofan;
  400. extern bool opt_autoengine;
  401. extern bool use_curses;
  402. extern char *opt_api_allow;
  403. extern char *opt_api_description;
  404. extern int opt_api_port;
  405. extern bool opt_api_listen;
  406. extern bool opt_api_network;
  407. extern bool opt_delaynet;
  408. extern bool opt_restart;
  409. extern pthread_rwlock_t netacc_lock;
  410. extern const uint32_t sha256_init_state[];
  411. extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
  412. const char *rpc_req, bool, bool, bool *,
  413. struct pool *pool, bool);
  414. extern char *bin2hex(const unsigned char *p, size_t len);
  415. extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
  416. typedef bool (*sha256_func)(int thr_id, const unsigned char *pmidstate,
  417. unsigned char *pdata,
  418. unsigned char *phash1, unsigned char *phash,
  419. const unsigned char *ptarget,
  420. uint32_t max_nonce,
  421. uint32_t *last_nonce,
  422. uint32_t nonce);
  423. extern int
  424. timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
  425. extern bool fulltest(const unsigned char *hash, const unsigned char *target);
  426. extern int opt_scantime;
  427. struct work_restart {
  428. volatile unsigned long restart;
  429. char padding[128 - sizeof(unsigned long)];
  430. };
  431. extern void thread_reportin(struct thr_info *thr);
  432. extern void kill_work(void);
  433. extern void reinit_device(struct cgpu_info *cgpu);
  434. #ifdef HAVE_ADL
  435. extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, int *activity, int *fanspeed, int *fanpercent, int *powertune);
  436. extern int set_fanspeed(int gpu, int iFanSpeed);
  437. extern int set_vddc(int gpu, float fVddc);
  438. extern int set_engineclock(int gpu, int iEngineClock);
  439. extern int set_memoryclock(int gpu, int iMemoryClock);
  440. #endif
  441. extern void api(int thr_id);
  442. extern struct pool *current_pool(void);
  443. extern int active_pools(void);
  444. extern int add_pool_details(bool live, char *url, char *user, char *pass);
  445. #define ADD_POOL_MAXIMUM 1
  446. #define ADD_POOL_OK 0
  447. #define MAX_GPUDEVICES 16
  448. #define MAX_DEVICES 64
  449. #define MAX_POOLS (32)
  450. #define MIN_INTENSITY -10
  451. #define _MIN_INTENSITY_STR "-10"
  452. #define MAX_INTENSITY 14
  453. #define _MAX_INTENSITY_STR "14"
  454. extern struct list_head scan_devices;
  455. extern int nDevs;
  456. extern int opt_n_threads;
  457. extern int num_processors;
  458. extern int hw_errors;
  459. extern bool use_syslog;
  460. extern struct thr_info *thr_info;
  461. extern struct work_restart *work_restart;
  462. extern struct cgpu_info gpus[MAX_GPUDEVICES];
  463. extern int gpu_threads;
  464. extern double total_secs;
  465. extern int mining_threads;
  466. extern struct cgpu_info *cpus;
  467. extern int total_devices;
  468. extern struct cgpu_info *devices[];
  469. extern int total_pools;
  470. extern struct pool *pools[MAX_POOLS];
  471. extern const char *algo_names[];
  472. extern enum sha256_algos opt_algo;
  473. extern struct strategies strategies[];
  474. extern enum pool_strategy pool_strategy;
  475. extern int opt_rotate_period;
  476. extern double total_mhashes_done;
  477. extern unsigned int new_blocks;
  478. extern unsigned int found_blocks;
  479. extern int total_accepted, total_rejected;
  480. extern int total_getworks, total_stale, total_discarded;
  481. extern unsigned int local_work;
  482. extern unsigned int total_go, total_ro;
  483. extern const int opt_cutofftemp;
  484. extern int opt_log_interval;
  485. #ifdef HAVE_OPENCL
  486. typedef struct {
  487. cl_uint ctx_a; cl_uint ctx_b; cl_uint ctx_c; cl_uint ctx_d;
  488. cl_uint ctx_e; cl_uint ctx_f; cl_uint ctx_g; cl_uint ctx_h;
  489. cl_uint cty_a; cl_uint cty_b; cl_uint cty_c; cl_uint cty_d;
  490. cl_uint cty_e; cl_uint cty_f; cl_uint cty_g; cl_uint cty_h;
  491. cl_uint merkle; cl_uint ntime; cl_uint nbits; cl_uint nonce;
  492. cl_uint fW0; cl_uint fW1; cl_uint fW2; cl_uint fW3; cl_uint fW15;
  493. cl_uint fW01r; cl_uint fcty_e; cl_uint fcty_e2;
  494. cl_uint W16; cl_uint W17; cl_uint W2;
  495. cl_uint PreVal4; cl_uint T1;
  496. cl_uint C1addK5; cl_uint D1A; cl_uint W2A; cl_uint W17_2;
  497. cl_uint PreVal4addT1; cl_uint T1substate0;
  498. cl_uint PreVal4_2;
  499. cl_uint PreVal0;
  500. cl_uint PreW18;
  501. cl_uint PreW19;
  502. cl_uint PreW31;
  503. cl_uint PreW32;
  504. /* For diakgcn */
  505. cl_uint B1addK6, PreVal0addK7, W16addK16, W17addK17;
  506. cl_uint zeroA, zeroB;
  507. cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
  508. } dev_blk_ctx;
  509. #else
  510. typedef struct {
  511. uint32_t nonce;
  512. } dev_blk_ctx;
  513. #endif
  514. struct curl_ent {
  515. CURL *curl;
  516. struct list_head node;
  517. struct timeval tv;
  518. };
  519. enum pool_enable {
  520. POOL_ENABLED,
  521. POOL_DISABLED,
  522. POOL_REJECTING,
  523. };
  524. struct pool {
  525. int pool_no;
  526. int prio;
  527. int accepted, rejected;
  528. int seq_rejects;
  529. bool submit_fail;
  530. bool idle;
  531. bool lagging;
  532. bool probed;
  533. enum pool_enable enabled;
  534. bool submit_old;
  535. bool removed;
  536. bool lp_started;
  537. char *hdr_path;
  538. char *lp_url;
  539. unsigned int getwork_requested;
  540. unsigned int stale_shares;
  541. unsigned int discarded_work;
  542. unsigned int getfail_occasions;
  543. unsigned int remotefail_occasions;
  544. struct timeval tv_idle;
  545. char *rpc_url;
  546. char *rpc_userpass;
  547. char *rpc_user, *rpc_pass;
  548. pthread_mutex_t pool_lock;
  549. struct thread_q *submit_q;
  550. struct thread_q *getwork_q;
  551. pthread_t longpoll_thread;
  552. pthread_t submit_thread;
  553. pthread_t getwork_thread;
  554. int curls;
  555. pthread_cond_t cr_cond;
  556. struct list_head curlring;
  557. time_t last_share_time;
  558. struct cgminer_stats cgminer_stats;
  559. };
  560. struct work {
  561. unsigned char data[128];
  562. unsigned char hash1[64];
  563. unsigned char midstate[32];
  564. unsigned char target[32];
  565. unsigned char hash[32];
  566. int rolls;
  567. uint32_t output[1];
  568. uint32_t valid;
  569. dev_blk_ctx blk;
  570. struct thr_info *thr;
  571. int thr_id;
  572. struct pool *pool;
  573. struct timeval tv_staged;
  574. bool mined;
  575. bool clone;
  576. bool cloned;
  577. bool rolltime;
  578. bool longpoll;
  579. unsigned int work_block;
  580. int id;
  581. UT_hash_handle hh;
  582. time_t share_found_time;
  583. };
  584. extern void get_datestamp(char *, struct timeval *);
  585. bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
  586. extern void tailsprintf(char *f, const char *fmt, ...);
  587. extern void wlogprint(const char *f, ...);
  588. extern int curses_int(const char *query);
  589. extern char *curses_input(const char *query);
  590. extern void kill_work(void);
  591. extern void switch_pools(struct pool *selected);
  592. extern void remove_pool(struct pool *pool);
  593. extern void write_config(FILE *fcfg);
  594. extern void log_curses(int prio, const char *f, va_list ap);
  595. extern void clear_logwin(void);
  596. extern bool pool_tclear(struct pool *pool, bool *var);
  597. extern struct thread_q *tq_new(void);
  598. extern void tq_free(struct thread_q *tq);
  599. extern bool tq_push(struct thread_q *tq, void *data);
  600. extern void *tq_pop(struct thread_q *tq, const struct timespec *abstime);
  601. extern void tq_freeze(struct thread_q *tq);
  602. extern void tq_thaw(struct thread_q *tq);
  603. extern bool successful_connect;
  604. extern void adl(void);
  605. extern void app_restart(void);
  606. #endif /* __MINER_H__ */