feat(esp_libc): refactored POSIX timers get/set functions

- Added sys/timex.h and clock_adjtime API
This commit is contained in:
Ondrej Kosta
2026-02-18 16:15:26 +01:00
parent 4ca48c370e
commit ed2e6735ff
28 changed files with 1428 additions and 545 deletions

View File

@@ -0,0 +1,43 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get current realtime in microseconds (adjusted boot time + time_since_boot).
*/
uint64_t esp_libc_timekeeping_get_realtime_us(void);
/**
* @brief Set realtime to the given epoch in microseconds (stops any slew, sets boot time).
*/
void esp_libc_timekeeping_set_realtime_us(uint64_t us);
/**
* @brief Get remaining adjtime correction in microseconds.
*
* @return Remaining slew in microseconds.
*/
int64_t esp_libc_timekeeping_adjtime_get_remaining_us(void);
/**
* @brief Apply an adjtime offset (slew) in microseconds.
*
* @param offset_us Offset to apply in microseconds (positive or negative).
* @param prev_remaining_us On success, set to previous remaining correction in microseconds.
* @return 0 on success, -1 on error (e.g. invalid offset magnitude).
*/
int esp_libc_timekeeping_adjtime_apply(int64_t offset_us, int64_t *prev_remaining_us);
#ifdef __cplusplus
}
#endif