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.
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
diff --git a/cgminer.c b/cgminer.c
index cd79a19..fa89cff 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -238,16 +238,16 @@ static bool time_before(struct tm *tm1, struct tm *tm2)
static bool should_run(void)
{
struct timeval tv;
- struct tm tm;
+ struct tm *tm;
if (!schedstart.enable && !schedstop.enable)
return true;
gettimeofday(&tv, NULL);
- localtime_r(&tv.tv_sec, &tm);
+ tm = localtime(&tv.tv_sec);
if (schedstart.enable) {
if (!schedstop.enable) {
- if (time_before(&tm, &schedstart.tm))
+ if (time_before(tm, &schedstart.tm))
return false;
/* This is a once off event with no stop time set */
@@ -255,46 +255,46 @@ static bool should_run(void)
return true;
}
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 false;
} /* Times are reversed */
- if (time_before(&tm, &schedstart.tm)) {
- if (time_before(&tm, &schedstop.tm))
+ if (time_before(tm, &schedstart.tm)) {
+ if (time_before(tm, &schedstop.tm))
return true;
return false;
}
return true;
}
/* only schedstop.enable == true */
- if (!time_before(&tm, &schedstop.tm))
+ if (!time_before(tm, &schedstop.tm))
return false;
return true;
}
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]",
- tm.tm_year + 1900,
- tm.tm_mon + 1,
- tm.tm_mday,
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec);
+ tm->tm_year + 1900,
+ tm->tm_mon + 1,
+ tm->tm_mday,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
}
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]",
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec);
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
}
static void applog_and_exit(const char *fmt, ...)
diff --git a/util.c b/util.c
index 9a8f08e..563a4d7 100644
--- a/util.c
+++ b/util.c
@@ -79,21 +79,21 @@ void vapplog(int prio, const char *fmt, va_list ap)
char *f;
int len;
struct timeval tv = { };
- struct tm tm;
+ struct tm *tm;
gettimeofday(&tv, NULL);
- localtime_r(&tv.tv_sec, &tm);
+ tm = localtime(&tv.tv_sec);
len = 40 + strlen(fmt) + 22;
f = alloca(len);
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %s\n",
- tm.tm_year + 1900,
- tm.tm_mon + 1,
- tm.tm_mday,
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec,
+ tm->tm_year + 1900,
+ tm->tm_mon + 1,
+ tm->tm_mday,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec,
fmt);
/* Only output to stderr if it's not going to the screen as well */
if (!isatty(fileno((FILE *)stderr))) {