Skip to content

Commit ac5bb75

Browse files
committed
Change clock calls to be redefines
1 parent dcb75a2 commit ac5bb75

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

wolfcrypt/src/wc_port.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,11 +4000,7 @@ 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
40044003
if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
4005-
#else
4006-
if (sys_clock_gettime(SYS_CLOCK_REALTIME, &ts) == 0)
4007-
#endif
40084004
if (timer != NULL)
40094005
*timer = ts.tv_sec;
40104006

wolfcrypt/test/test.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,11 +3061,7 @@ 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
30653064
clock_settime(CLOCK_REALTIME, &utctime);
3066-
#else
3067-
sys_clock_settime(SYS_CLOCK_REALTIME, &utctime);
3068-
#endif
30693065
#endif
30703066
#ifdef DEVKITPRO
30713067
void *framebuffer;

wolfssl/wolfcrypt/wc_port.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,14 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
15431543
#include <time.h>
15441544
#endif
15451545

1546+
#ifndef CLOCK_REALTIME
1547+
#ifdef SYS_CLOCK_REALTIME
1548+
#define CLOCK_REALTIME SYS_CLOCK_REALTIME
1549+
#define clock_gettime sys_clock_gettime
1550+
#define clock_settime sys_clock_settime
1551+
#endif
1552+
#endif
1553+
15461554
#if defined(CONFIG_RTC)
15471555
#if defined(CONFIG_PICOLIBC) || defined(CONFIG_NEWLIB_LIBC)
15481556
#include <zephyr/drivers/rtc.h>

zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,7 @@ 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
591590
clock_settime(CLOCK_REALTIME, &utctime);
592-
#else
593-
sys_clock_settime(SYS_CLOCK_REALTIME, &utctime);
594-
#endif
595591

596592
#ifdef HAVE_FIPS
597593
wolfCrypt_SetCb_fips(myFipsCb);

0 commit comments

Comments
 (0)