fix(esp_libc): provide timespec_get missing from toolchain

Both newlib and picolibc headers in toolchain 16.1 declare timespec_get()
but the archives do not define it. Provide the missing C11 implementation
through esp_libc, mapping TIME_UTC to clock_gettime(CLOCK_REALTIME).

Closes https://github.com/espressif/esp-idf/issues/18889
This commit is contained in:
Guillaume Souchere
2026-07-28 08:23:33 +02:00
parent f930f9fe10
commit 9cea97187f
4 changed files with 32 additions and 1 deletions
@@ -548,6 +548,17 @@ TEST_CASE("test posix_timers clock_... functions", "[newlib]")
test_posix_timers_clock();
}
TEST_CASE("timespec_get returns UTC time", "[newlib]")
{
struct timespec ts = {0};
TEST_ASSERT_EQUAL_INT(TIME_UTC, timespec_get(&ts, TIME_UTC));
TEST_ASSERT_GREATER_OR_EQUAL_INT64(0, ts.tv_sec);
TEST_ASSERT_GREATER_OR_EQUAL_INT32(0, ts.tv_nsec);
TEST_ASSERT_LESS_THAN_INT32(1000000000L, ts.tv_nsec);
TEST_ASSERT_EQUAL_INT(0, timespec_get(&ts, -1));
}
#define TEST_USE_CPU_CYCLES 1
#if TEST_USE_CPU_CYCLES && CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
#include "esp_cpu.h"