mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Move from the thread safe localtime_r to regular localtime which is the only one supported on newer pthread libraries on mingw32 to make it compile with
the newer ming. Thread safety is of no importance where localtime is used in this code.
This commit is contained in:
parent
63777c9d30
commit
5b4761003c
40
cgminer.c
40
cgminer.c
@ -238,16 +238,16 @@ static bool time_before(struct tm *tm1, struct tm *tm2)
|
|||||||
static bool should_run(void)
|
static bool should_run(void)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct tm tm;
|
struct tm *tm;
|
||||||
|
|
||||||
if (!schedstart.enable && !schedstop.enable)
|
if (!schedstart.enable && !schedstop.enable)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
localtime_r(&tv.tv_sec, &tm);
|
tm = localtime(&tv.tv_sec);
|
||||||
if (schedstart.enable) {
|
if (schedstart.enable) {
|
||||||
if (!schedstop.enable) {
|
if (!schedstop.enable) {
|
||||||
if (time_before(&tm, &schedstart.tm))
|
if (time_before(tm, &schedstart.tm))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* This is a once off event with no stop time set */
|
/* This is a once off event with no stop time set */
|
||||||
@ -255,46 +255,46 @@ static bool should_run(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (time_before(&schedstart.tm, &schedstop.tm)) {
|
if (time_before(&schedstart.tm, &schedstop.tm)) {
|
||||||
if (time_before(&tm, &schedstop.tm) && !time_before(&tm, &schedstart.tm))
|
if (time_before(tm, &schedstop.tm) && !time_before(tm, &schedstart.tm))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
} /* Times are reversed */
|
} /* Times are reversed */
|
||||||
if (time_before(&tm, &schedstart.tm)) {
|
if (time_before(tm, &schedstart.tm)) {
|
||||||
if (time_before(&tm, &schedstop.tm))
|
if (time_before(tm, &schedstop.tm))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/* only schedstop.enable == true */
|
/* only schedstop.enable == true */
|
||||||
if (!time_before(&tm, &schedstop.tm))
|
if (!time_before(tm, &schedstop.tm))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_datestamp(char *f, struct timeval *tv)
|
void get_datestamp(char *f, struct timeval *tv)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm *tm;
|
||||||
|
|
||||||
localtime_r(&tv->tv_sec, &tm);
|
tm = localtime(&tv->tv_sec);
|
||||||
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d]",
|
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d]",
|
||||||
tm.tm_year + 1900,
|
tm->tm_year + 1900,
|
||||||
tm.tm_mon + 1,
|
tm->tm_mon + 1,
|
||||||
tm.tm_mday,
|
tm->tm_mday,
|
||||||
tm.tm_hour,
|
tm->tm_hour,
|
||||||
tm.tm_min,
|
tm->tm_min,
|
||||||
tm.tm_sec);
|
tm->tm_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_timestamp(char *f, struct timeval *tv)
|
void get_timestamp(char *f, struct timeval *tv)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm *tm;
|
||||||
|
|
||||||
localtime_r(&tv->tv_sec, &tm);
|
tm = localtime(&tv->tv_sec);
|
||||||
sprintf(f, "[%02d:%02d:%02d]",
|
sprintf(f, "[%02d:%02d:%02d]",
|
||||||
tm.tm_hour,
|
tm->tm_hour,
|
||||||
tm.tm_min,
|
tm->tm_min,
|
||||||
tm.tm_sec);
|
tm->tm_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void applog_and_exit(const char *fmt, ...)
|
static void applog_and_exit(const char *fmt, ...)
|
||||||
|
16
util.c
16
util.c
@ -79,21 +79,21 @@ void vapplog(int prio, const char *fmt, va_list ap)
|
|||||||
char *f;
|
char *f;
|
||||||
int len;
|
int len;
|
||||||
struct timeval tv = { };
|
struct timeval tv = { };
|
||||||
struct tm tm;
|
struct tm *tm;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
|
|
||||||
localtime_r(&tv.tv_sec, &tm);
|
tm = localtime(&tv.tv_sec);
|
||||||
|
|
||||||
len = 40 + strlen(fmt) + 22;
|
len = 40 + strlen(fmt) + 22;
|
||||||
f = alloca(len);
|
f = alloca(len);
|
||||||
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %s\n",
|
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %s\n",
|
||||||
tm.tm_year + 1900,
|
tm->tm_year + 1900,
|
||||||
tm.tm_mon + 1,
|
tm->tm_mon + 1,
|
||||||
tm.tm_mday,
|
tm->tm_mday,
|
||||||
tm.tm_hour,
|
tm->tm_hour,
|
||||||
tm.tm_min,
|
tm->tm_min,
|
||||||
tm.tm_sec,
|
tm->tm_sec,
|
||||||
fmt);
|
fmt);
|
||||||
/* Only output to stderr if it's not going to the screen as well */
|
/* Only output to stderr if it's not going to the screen as well */
|
||||||
if (!isatty(fileno((FILE *)stderr))) {
|
if (!isatty(fileno((FILE *)stderr))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user