mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Merge pull request #155 from luke-jr/no_curses
Make curses TUI support optional at compile-time.
This commit is contained in:
commit
7458927f02
9
adl.c
9
adl.c
@ -12,9 +12,12 @@
|
|||||||
#if defined(HAVE_ADL) && (defined(__linux) || defined (WIN32))
|
#if defined(HAVE_ADL) && (defined(__linux) || defined (WIN32))
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <curses.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
|
#include <curses.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "miner.h"
|
#include "miner.h"
|
||||||
#include "ADL_SDK/adl_sdk.h"
|
#include "ADL_SDK/adl_sdk.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
@ -850,6 +853,7 @@ static void get_vddcrange(int gpu, float *imin, float *imax)
|
|||||||
*imax = (float)ga->lpOdParameters.sVddc.iMax / 1000;
|
*imax = (float)ga->lpOdParameters.sVddc.iMax / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static float curses_float(const char *query)
|
static float curses_float(const char *query)
|
||||||
{
|
{
|
||||||
float ret;
|
float ret;
|
||||||
@ -860,6 +864,7 @@ static float curses_float(const char *query)
|
|||||||
free(cvar);
|
free(cvar);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int set_vddc(int gpu, float fVddc)
|
int set_vddc(int gpu, float fVddc)
|
||||||
{
|
{
|
||||||
@ -1150,6 +1155,7 @@ void set_defaultengine(int gpu)
|
|||||||
unlock_adl();
|
unlock_adl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
void change_autosettings(int gpu)
|
void change_autosettings(int gpu)
|
||||||
{
|
{
|
||||||
struct gpu_adl *ga = &gpus[gpu].adl;
|
struct gpu_adl *ga = &gpus[gpu].adl;
|
||||||
@ -1306,6 +1312,7 @@ updated:
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
goto updated;
|
goto updated;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void clear_adl(int nDevs)
|
void clear_adl(int nDevs)
|
||||||
{
|
{
|
||||||
|
71
cgminer.c
71
cgminer.c
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -116,7 +118,13 @@ int gpu_threads;
|
|||||||
int opt_n_threads = -1;
|
int opt_n_threads = -1;
|
||||||
int mining_threads;
|
int mining_threads;
|
||||||
int num_processors;
|
int num_processors;
|
||||||
bool use_curses = true;
|
bool use_curses =
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
|
true
|
||||||
|
#else
|
||||||
|
false
|
||||||
|
#endif
|
||||||
|
;
|
||||||
static bool opt_submit_stale;
|
static bool opt_submit_stale;
|
||||||
static int opt_shares;
|
static int opt_shares;
|
||||||
static bool opt_fail_only;
|
static bool opt_fail_only;
|
||||||
@ -141,7 +149,9 @@ int longpoll_thr_id;
|
|||||||
static int stage_thr_id;
|
static int stage_thr_id;
|
||||||
static int watchpool_thr_id;
|
static int watchpool_thr_id;
|
||||||
static int watchdog_thr_id;
|
static int watchdog_thr_id;
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static int input_thr_id;
|
static int input_thr_id;
|
||||||
|
#endif
|
||||||
int gpur_thr_id;
|
int gpur_thr_id;
|
||||||
static int api_thr_id;
|
static int api_thr_id;
|
||||||
static int total_threads;
|
static int total_threads;
|
||||||
@ -151,7 +161,9 @@ struct work_restart *work_restart = NULL;
|
|||||||
static pthread_mutex_t hash_lock;
|
static pthread_mutex_t hash_lock;
|
||||||
static pthread_mutex_t qd_lock;
|
static pthread_mutex_t qd_lock;
|
||||||
static pthread_mutex_t *stgd_lock;
|
static pthread_mutex_t *stgd_lock;
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static pthread_mutex_t curses_lock;
|
static pthread_mutex_t curses_lock;
|
||||||
|
#endif
|
||||||
static pthread_rwlock_t blk_lock;
|
static pthread_rwlock_t blk_lock;
|
||||||
pthread_rwlock_t netacc_lock;
|
pthread_rwlock_t netacc_lock;
|
||||||
|
|
||||||
@ -179,6 +191,9 @@ enum pool_strategy pool_strategy = POOL_FAILOVER;
|
|||||||
int opt_rotate_period;
|
int opt_rotate_period;
|
||||||
static int total_urls, total_users, total_passes, total_userpasses;
|
static int total_urls, total_users, total_passes, total_userpasses;
|
||||||
|
|
||||||
|
#ifndef HAVE_CURSES
|
||||||
|
const
|
||||||
|
#endif
|
||||||
static bool curses_active = false;
|
static bool curses_active = false;
|
||||||
|
|
||||||
static char current_block[37];
|
static char current_block[37];
|
||||||
@ -828,7 +843,12 @@ static struct opt_table opt_config_table[] = {
|
|||||||
#endif
|
#endif
|
||||||
OPT_WITHOUT_ARG("--text-only|-T",
|
OPT_WITHOUT_ARG("--text-only|-T",
|
||||||
opt_set_invbool, &use_curses,
|
opt_set_invbool, &use_curses,
|
||||||
"Disable ncurses formatted screen output"),
|
#ifdef HAVE_CURSES
|
||||||
|
"Disable ncurses formatted screen output"
|
||||||
|
#else
|
||||||
|
opt_hidden
|
||||||
|
#endif
|
||||||
|
),
|
||||||
OPT_WITH_ARG("--url|-o",
|
OPT_WITH_ARG("--url|-o",
|
||||||
set_url, NULL, NULL,
|
set_url, NULL, NULL,
|
||||||
"URL for bitcoin JSON-RPC server"),
|
"URL for bitcoin JSON-RPC server"),
|
||||||
@ -1127,13 +1147,16 @@ static int requests_staged(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
WINDOW *mainwin, *statuswin, *logwin;
|
WINDOW *mainwin, *statuswin, *logwin;
|
||||||
|
#endif
|
||||||
double total_secs = 0.1;
|
double total_secs = 0.1;
|
||||||
static char statusline[256];
|
static char statusline[256];
|
||||||
static int devcursor, logstart, logcursor;
|
static int devcursor, logstart, logcursor;
|
||||||
struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
|
struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
|
||||||
struct cgpu_info *cpus;
|
struct cgpu_info *cpus;
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static inline void unlock_curses(void)
|
static inline void unlock_curses(void)
|
||||||
{
|
{
|
||||||
mutex_unlock(&curses_lock);
|
mutex_unlock(&curses_lock);
|
||||||
@ -1154,6 +1177,7 @@ static bool curses_active_locked(void)
|
|||||||
unlock_curses();
|
unlock_curses();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tailsprintf(char *f, const char *fmt, ...)
|
void tailsprintf(char *f, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
@ -1192,6 +1216,7 @@ static void text_print_status(int thr_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
/* Must be called with curses mutex lock held and curses_active */
|
/* Must be called with curses mutex lock held and curses_active */
|
||||||
static void curses_print_status(void)
|
static void curses_print_status(void)
|
||||||
{
|
{
|
||||||
@ -1274,6 +1299,7 @@ static void curses_print_devstatus(int thr_id)
|
|||||||
|
|
||||||
wclrtoeol(statuswin);
|
wclrtoeol(statuswin);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void print_status(int thr_id)
|
static void print_status(int thr_id)
|
||||||
{
|
{
|
||||||
@ -1281,6 +1307,7 @@ static void print_status(int thr_id)
|
|||||||
text_print_status(thr_id);
|
text_print_status(thr_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
/* Check for window resize. Called with curses mutex locked */
|
/* Check for window resize. Called with curses mutex locked */
|
||||||
static inline bool change_logwinsize(void)
|
static inline bool change_logwinsize(void)
|
||||||
{
|
{
|
||||||
@ -1336,7 +1363,9 @@ void wlogprint(const char *f, ...)
|
|||||||
unlock_curses();
|
unlock_curses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
void log_curses(int prio, const char *f, va_list ap)
|
void log_curses(int prio, const char *f, va_list ap)
|
||||||
{
|
{
|
||||||
bool high_prio;
|
bool high_prio;
|
||||||
@ -1366,6 +1395,7 @@ void clear_logwin(void)
|
|||||||
unlock_curses();
|
unlock_curses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* regenerate the full work->hash value and also return true if it's a block */
|
/* regenerate the full work->hash value and also return true if it's a block */
|
||||||
bool regeneratehash(const struct work *work)
|
bool regeneratehash(const struct work *work)
|
||||||
@ -1700,6 +1730,7 @@ static void workio_cmd_free(struct workio_cmd *wc)
|
|||||||
free(wc);
|
free(wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static void disable_curses(void)
|
static void disable_curses(void)
|
||||||
{
|
{
|
||||||
if (curses_active_locked()) {
|
if (curses_active_locked()) {
|
||||||
@ -1728,6 +1759,7 @@ static void disable_curses(void)
|
|||||||
unlock_curses();
|
unlock_curses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void print_summary(void);
|
static void print_summary(void);
|
||||||
|
|
||||||
@ -2260,6 +2292,7 @@ static bool stage_work(struct work *work)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
int curses_int(const char *query)
|
int curses_int(const char *query)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -2270,8 +2303,11 @@ int curses_int(const char *query)
|
|||||||
free(cvar);
|
free(cvar);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static bool input_pool(bool live);
|
static bool input_pool(bool live);
|
||||||
|
#endif
|
||||||
|
|
||||||
int active_pools(void)
|
int active_pools(void)
|
||||||
{
|
{
|
||||||
@ -2285,6 +2321,7 @@ int active_pools(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static void display_pool_summary(struct pool *pool)
|
static void display_pool_summary(struct pool *pool)
|
||||||
{
|
{
|
||||||
double efficiency = 0.0;
|
double efficiency = 0.0;
|
||||||
@ -2332,6 +2369,7 @@ static void remove_pool(struct pool *pool)
|
|||||||
pool->pool_no = total_pools;
|
pool->pool_no = total_pools;
|
||||||
total_pools--;
|
total_pools--;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void write_config(FILE *fcfg)
|
void write_config(FILE *fcfg)
|
||||||
{
|
{
|
||||||
@ -2482,6 +2520,7 @@ void write_config(FILE *fcfg)
|
|||||||
fputs("\n}", fcfg);
|
fputs("\n}", fcfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static void display_pools(void)
|
static void display_pools(void)
|
||||||
{
|
{
|
||||||
struct pool *pool;
|
struct pool *pool;
|
||||||
@ -2686,10 +2725,12 @@ retry:
|
|||||||
immedok(logwin, false);
|
immedok(logwin, false);
|
||||||
opt_loginput = false;
|
opt_loginput = false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void start_longpoll(void);
|
static void start_longpoll(void);
|
||||||
static void stop_longpoll(void);
|
static void stop_longpoll(void);
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static void set_options(void)
|
static void set_options(void)
|
||||||
{
|
{
|
||||||
int selected;
|
int selected;
|
||||||
@ -2830,6 +2871,7 @@ static void *input_thread(void __maybe_unused *userdata)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This thread should not be shut down unless a problem occurs */
|
/* This thread should not be shut down unless a problem occurs */
|
||||||
static void *workio_thread(void *userdata)
|
static void *workio_thread(void *userdata)
|
||||||
@ -3731,6 +3773,7 @@ out:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__maybe_unused
|
||||||
static void stop_longpoll(void)
|
static void stop_longpoll(void)
|
||||||
{
|
{
|
||||||
struct thr_info *thr = &thr_info[longpoll_thr_id];
|
struct thr_info *thr = &thr_info[longpoll_thr_id];
|
||||||
@ -3817,6 +3860,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
|
|||||||
|
|
||||||
hashmeter(-1, &zero_tv, 0);
|
hashmeter(-1, &zero_tv, 0);
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
if (curses_active_locked()) {
|
if (curses_active_locked()) {
|
||||||
change_logwinsize();
|
change_logwinsize();
|
||||||
curses_print_status();
|
curses_print_status();
|
||||||
@ -3828,6 +3872,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
|
|||||||
wrefresh(logwin);
|
wrefresh(logwin);
|
||||||
unlock_curses();
|
unlock_curses();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
|
|
||||||
@ -4041,7 +4086,9 @@ static void clean_up(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gettimeofday(&total_tv_end, NULL);
|
gettimeofday(&total_tv_end, NULL);
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
disable_curses();
|
disable_curses();
|
||||||
|
#endif
|
||||||
if (!opt_realquiet && successful_connect)
|
if (!opt_realquiet && successful_connect)
|
||||||
print_summary();
|
print_summary();
|
||||||
|
|
||||||
@ -4068,6 +4115,7 @@ void quit(int status, const char *format, ...)
|
|||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
char *curses_input(const char *query)
|
char *curses_input(const char *query)
|
||||||
{
|
{
|
||||||
char *input;
|
char *input;
|
||||||
@ -4085,6 +4133,7 @@ char *curses_input(const char *query)
|
|||||||
noecho();
|
noecho();
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int add_pool_details(bool live, char *url, char *user, char *pass)
|
int add_pool_details(bool live, char *url, char *user, char *pass)
|
||||||
{
|
{
|
||||||
@ -4120,6 +4169,7 @@ int add_pool_details(bool live, char *url, char *user, char *pass)
|
|||||||
return ADD_POOL_OK;
|
return ADD_POOL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
static bool input_pool(bool live)
|
static bool input_pool(bool live)
|
||||||
{
|
{
|
||||||
char *url = NULL, *user = NULL, *pass = NULL;
|
char *url = NULL, *user = NULL, *pass = NULL;
|
||||||
@ -4171,6 +4221,7 @@ out:
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(unix)
|
#if defined(unix)
|
||||||
static void fork_monitor()
|
static void fork_monitor()
|
||||||
@ -4240,6 +4291,7 @@ out:
|
|||||||
}
|
}
|
||||||
#endif // defined(unix)
|
#endif // defined(unix)
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
void enable_curses(void) {
|
void enable_curses(void) {
|
||||||
int x,y;
|
int x,y;
|
||||||
|
|
||||||
@ -4262,6 +4314,7 @@ void enable_curses(void) {
|
|||||||
curses_active = true;
|
curses_active = true;
|
||||||
unlock_curses();
|
unlock_curses();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: fix need a dummy CPU device_api even if no support for CPU mining */
|
/* TODO: fix need a dummy CPU device_api even if no support for CPU mining */
|
||||||
#ifndef WANT_CPUMINE
|
#ifndef WANT_CPUMINE
|
||||||
@ -4311,7 +4364,9 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
mutex_init(&hash_lock);
|
mutex_init(&hash_lock);
|
||||||
mutex_init(&qd_lock);
|
mutex_init(&qd_lock);
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
mutex_init(&curses_lock);
|
mutex_init(&curses_lock);
|
||||||
|
#endif
|
||||||
mutex_init(&control_lock);
|
mutex_init(&control_lock);
|
||||||
rwlock_init(&blk_lock);
|
rwlock_init(&blk_lock);
|
||||||
rwlock_init(&netacc_lock);
|
rwlock_init(&netacc_lock);
|
||||||
@ -4393,8 +4448,10 @@ int main (int argc, char *argv[])
|
|||||||
successful_connect = true;
|
successful_connect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
if (use_curses)
|
if (use_curses)
|
||||||
enable_curses();
|
enable_curses();
|
||||||
|
#endif
|
||||||
|
|
||||||
applog(LOG_WARNING, "Started %s", packagename);
|
applog(LOG_WARNING, "Started %s", packagename);
|
||||||
|
|
||||||
@ -4498,14 +4555,18 @@ int main (int argc, char *argv[])
|
|||||||
logstart += total_devices;
|
logstart += total_devices;
|
||||||
logcursor = logstart + 1;
|
logcursor = logstart + 1;
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
check_winsizes();
|
check_winsizes();
|
||||||
|
|
||||||
if (opt_realquiet)
|
if (opt_realquiet)
|
||||||
use_curses = false;
|
use_curses = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!total_pools) {
|
if (!total_pools) {
|
||||||
applog(LOG_WARNING, "Need to specify at least one pool server.");
|
applog(LOG_WARNING, "Need to specify at least one pool server.");
|
||||||
if (!use_curses || (use_curses && !input_pool(false)))
|
#ifdef HAVE_CURSES
|
||||||
|
if (!use_curses || !input_pool(false))
|
||||||
|
#endif
|
||||||
quit(1, "Pool setup failed");
|
quit(1, "Pool setup failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4627,6 +4688,7 @@ int main (int argc, char *argv[])
|
|||||||
applog(LOG_WARNING, "Pool: %d URL: %s User: %s Password: %s",
|
applog(LOG_WARNING, "Pool: %d URL: %s User: %s Password: %s",
|
||||||
i, pool->rpc_url, pool->rpc_user, pool->rpc_pass);
|
i, pool->rpc_url, pool->rpc_user, pool->rpc_pass);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
if (use_curses) {
|
if (use_curses) {
|
||||||
halfdelay(150);
|
halfdelay(150);
|
||||||
applog(LOG_ERR, "Press any key to exit, or cgminer will try again in 15s.");
|
applog(LOG_ERR, "Press any key to exit, or cgminer will try again in 15s.");
|
||||||
@ -4634,6 +4696,7 @@ int main (int argc, char *argv[])
|
|||||||
quit(0, "No servers could be used! Exiting.");
|
quit(0, "No servers could be used! Exiting.");
|
||||||
nocbreak();
|
nocbreak();
|
||||||
} else
|
} else
|
||||||
|
#endif
|
||||||
quit(0, "No servers could be used! Exiting.");
|
quit(0, "No servers could be used! Exiting.");
|
||||||
}
|
}
|
||||||
} while (!pools_active);
|
} while (!pools_active);
|
||||||
@ -4738,6 +4801,7 @@ begin_bench:
|
|||||||
quit(1, "API thread create failed");
|
quit(1, "API thread create failed");
|
||||||
pthread_detach(thr->pth);
|
pthread_detach(thr->pth);
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
/* Create curses input thread for keyboard input. Create this last so
|
/* Create curses input thread for keyboard input. Create this last so
|
||||||
* that we know all threads are created since this can call kill_work
|
* that we know all threads are created since this can call kill_work
|
||||||
* to try and shut down ll previous threads. */
|
* to try and shut down ll previous threads. */
|
||||||
@ -4746,6 +4810,7 @@ begin_bench:
|
|||||||
if (thr_info_create(thr, NULL, input_thread, thr))
|
if (thr_info_create(thr, NULL, input_thread, thr))
|
||||||
quit(1, "input thread create failed");
|
quit(1, "input thread create failed");
|
||||||
pthread_detach(thr->pth);
|
pthread_detach(thr->pth);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* main loop - simply wait for workio thread to exit. This is not the
|
/* main loop - simply wait for workio thread to exit. This is not the
|
||||||
* normal exit path and only occurs should the workio_thread die
|
* normal exit path and only occurs should the workio_thread die
|
||||||
|
31
configure.ac
31
configure.ac
@ -207,12 +207,33 @@ if test "x$icarus" = xyes; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
|
AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
|
||||||
|
|
||||||
AC_SEARCH_LIBS(addstr, ncurses pdcurses, ,
|
|
||||||
AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev]))
|
|
||||||
|
|
||||||
AC_CHECK_LIB(ncurses, addstr, NCURSES_LIBS=-lncurses)
|
curses="auto"
|
||||||
AC_CHECK_LIB(pdcurses, addstr, PDCURSES_LIBS=-lpdcurses)
|
|
||||||
|
|
||||||
|
AC_ARG_WITH([curses],
|
||||||
|
[AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
|
||||||
|
[curses=$withval]
|
||||||
|
)
|
||||||
|
if test "x$curses" = "xno"; then
|
||||||
|
cursesmsg='User specified --without-curses. TUI support DISABLED'
|
||||||
|
else
|
||||||
|
AC_SEARCH_LIBS(addstr, ncurses pdcurses, [
|
||||||
|
curses=yes
|
||||||
|
cursesmsg="FOUND: ${ac_cv_search_addstr:2}"
|
||||||
|
AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
|
||||||
|
], [
|
||||||
|
if test "x$curses" = "xyes"; then
|
||||||
|
AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
|
||||||
|
else
|
||||||
|
AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
|
||||||
|
curses=no
|
||||||
|
cursesmsg='NOT FOUND. TUI support DISABLED'
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
|
||||||
AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
|
AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
|
||||||
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
|
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
|
||||||
AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
|
AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
|
||||||
@ -365,6 +386,8 @@ echo
|
|||||||
echo "Configuration Options Summary:"
|
echo "Configuration Options Summary:"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
echo " curses.TUI...........: $cursesmsg"
|
||||||
|
|
||||||
if test "x$opencl" != xno; then
|
if test "x$opencl" != xno; then
|
||||||
if test $found_opencl = 1; then
|
if test $found_opencl = 1; then
|
||||||
echo " OpenCL...............: FOUND. GPU mining support enabled"
|
echo " OpenCL...............: FOUND. GPU mining support enabled"
|
||||||
|
10
device-gpu.c
10
device-gpu.c
@ -11,7 +11,10 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -32,8 +35,10 @@
|
|||||||
|
|
||||||
/* TODO: cleanup externals ********************/
|
/* TODO: cleanup externals ********************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
extern WINDOW *mainwin, *statuswin, *logwin;
|
extern WINDOW *mainwin, *statuswin, *logwin;
|
||||||
extern void enable_curses(void);
|
extern void enable_curses(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int mining_threads;
|
extern int mining_threads;
|
||||||
extern double total_secs;
|
extern double total_secs;
|
||||||
@ -526,6 +531,9 @@ void pause_dynamic_threads(int gpu)
|
|||||||
|
|
||||||
struct device_api opencl_api;
|
struct device_api opencl_api;
|
||||||
|
|
||||||
|
#endif /* HAVE_OPENCL */
|
||||||
|
|
||||||
|
#if defined(HAVE_OPENCL) && defined(HAVE_CURSES)
|
||||||
void manage_gpu(void)
|
void manage_gpu(void)
|
||||||
{
|
{
|
||||||
struct thr_info *thr;
|
struct thr_info *thr;
|
||||||
@ -1183,11 +1191,13 @@ static bool opencl_thread_prepare(struct thr_info *thr)
|
|||||||
applog(LOG_ERR, "Restarting the GPU from the menu will not fix this.");
|
applog(LOG_ERR, "Restarting the GPU from the menu will not fix this.");
|
||||||
applog(LOG_ERR, "Try restarting cgminer.");
|
applog(LOG_ERR, "Try restarting cgminer.");
|
||||||
failmessage = true;
|
failmessage = true;
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
if (use_curses) {
|
if (use_curses) {
|
||||||
buf = curses_input("Press enter to continue");
|
buf = curses_input("Press enter to continue");
|
||||||
if (buf)
|
if (buf)
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
cgpu->deven = DEV_DISABLED;
|
cgpu->deven = DEV_DISABLED;
|
||||||
cgpu->status = LIFE_NOSTART;
|
cgpu->status = LIFE_NOSTART;
|
||||||
|
43
logging.c
43
logging.c
@ -18,9 +18,29 @@ bool opt_log_output = false;
|
|||||||
/* per default priorities higher than LOG_NOTICE are logged */
|
/* per default priorities higher than LOG_NOTICE are logged */
|
||||||
int opt_log_level = LOG_NOTICE;
|
int opt_log_level = LOG_NOTICE;
|
||||||
|
|
||||||
|
static void my_log_curses(int prio, char *f, va_list ap)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
|
extern bool use_curses;
|
||||||
|
if (use_curses)
|
||||||
|
log_curses(prio, f, ap);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
int len = strlen(f);
|
||||||
|
|
||||||
|
strcpy(f + len - 1, " \n");
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSES
|
||||||
|
log_curses(prio, f, ap);
|
||||||
|
#else
|
||||||
|
vprintf(f, ap);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void vapplog(int prio, const char *fmt, va_list ap)
|
void vapplog(int prio, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
extern bool use_curses;
|
|
||||||
if (!opt_debug && prio == LOG_DEBUG)
|
if (!opt_debug && prio == LOG_DEBUG)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -60,15 +80,7 @@ void vapplog(int prio, const char *fmt, va_list ap)
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_curses)
|
my_log_curses(prio, f, ap);
|
||||||
log_curses(prio, f, ap);
|
|
||||||
else {
|
|
||||||
int len = strlen(f);
|
|
||||||
|
|
||||||
strcpy(f + len - 1, " \n");
|
|
||||||
|
|
||||||
log_curses(prio, f, ap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +102,6 @@ void applog(int prio, const char *fmt, ...)
|
|||||||
*/
|
*/
|
||||||
static void __maybe_unused log_generic(int prio, const char *fmt, va_list ap)
|
static void __maybe_unused log_generic(int prio, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
extern bool use_curses;
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
if (use_syslog) {
|
if (use_syslog) {
|
||||||
vsyslog(prio, fmt, ap);
|
vsyslog(prio, fmt, ap);
|
||||||
@ -127,15 +138,7 @@ static void __maybe_unused log_generic(int prio, const char *fmt, va_list ap)
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_curses)
|
my_log_curses(prio, f, ap);
|
||||||
log_curses(prio, f, ap);
|
|
||||||
else {
|
|
||||||
int len = strlen(f);
|
|
||||||
|
|
||||||
strcpy(f + len - 1, " \n");
|
|
||||||
|
|
||||||
log_curses(prio, f, ap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* we can not generalize variable argument list */
|
/* we can not generalize variable argument list */
|
||||||
|
1
util.c
1
util.c
@ -19,7 +19,6 @@
|
|||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <curses.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user