Skip to content

Commit 5d39bb8

Browse files
committed
240430.192839.HKT fix stress.c
1 parent c5a7a62 commit 5d39bb8

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

c/tests/stress.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
#define M_INEQ_MAX 1000
1515
#define M_NLCON 200
1616

17+
// Thread-safe version of localtime
18+
#ifdef _WIN32
19+
#define localtime_safe(a, b) localtime_s(a, b)
20+
#else
21+
#define localtime_safe(a, b) localtime_r(b, a)
22+
#endif
23+
1724
int n = 0;
1825
int m_ineq = 0;
1926
const double alpha = 4.0;
@@ -67,7 +74,7 @@ unsigned int get_random_seed(void)
6774
char buf[10] = {0};
6875
time_t t = time(NULL);
6976
struct tm timeinfo;
70-
localtime_s(&timeinfo, &t);
77+
localtime_safe(&timeinfo, &t);
7178
int rc = strftime(buf, 10, "%y%W", &timeinfo);
7279
if (!rc)
7380
return 42;

0 commit comments

Comments
 (0)