Skip to content

Commit dcb75a2

Browse files
committed
Fix gating for when _POSIX_C_SOURCE is not used
1 parent 62041a2 commit dcb75a2

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

wolfcrypt/src/wc_port.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,7 +4000,11 @@ time_t z_time(time_t * timer)
40004000

40014001
/* Fallback to uptime since boot. This works for relative times, but
40024002
* not for ASN.1 date validation */
4003+
#ifdef _POSIX_C_SOURCE
40034004
if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
4005+
#else
4006+
if (sys_clock_gettime(SYS_CLOCK_REALTIME, &ts) == 0)
4007+
#endif
40044008
if (timer != NULL)
40054009
*timer = ts.tv_sec;
40064010

wolfcrypt/test/test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,7 +3061,11 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
30613061
struct timespec utctime;
30623062
utctime.tv_sec = 1521725159; /* dummy time: 2018-03-22T13:25:59+00:00 */
30633063
utctime.tv_nsec = 0;
3064+
#ifdef _POSIX_C_SOURCE
30643065
clock_settime(CLOCK_REALTIME, &utctime);
3066+
#else
3067+
sys_clock_settime(SYS_CLOCK_REALTIME, &utctime);
3068+
#endif
30653069
#endif
30663070
#ifdef DEVKITPRO
30673071
void *framebuffer;

zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,11 @@ int main()
587587
struct timespec utctime;
588588
utctime.tv_sec = 1658510212; /* Friday, July 22, 2022 5:16:52 PM GMT */
589589
utctime.tv_nsec = 0;
590+
#ifdef _POSIX_C_SOURCE
590591
clock_settime(CLOCK_REALTIME, &utctime);
592+
#else
593+
sys_clock_settime(SYS_CLOCK_REALTIME, &utctime);
594+
#endif
591595

592596
#ifdef HAVE_FIPS
593597
wolfCrypt_SetCb_fips(myFipsCb);

0 commit comments

Comments
 (0)