|
Zephyr Project API 4.2.1
A Scalable Open Source RTOS
|
Utilities supporting operation on time data structures. More...
#include <limits.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <time.h>#include <zephyr/sys_clock.h>#include <zephyr/sys/__assert.h>#include <zephyr/sys/math_extras.h>#include <zephyr/sys/time_units.h>#include <zephyr/sys/util.h>#include <zephyr/toolchain.h>#include <zephyr/types.h>Go to the source code of this file.
Data Structures | |
| struct | timeutil_sync_config |
| Immutable state for synchronizing two clocks. More... | |
| struct | timeutil_sync_instant |
| Representation of an instant in two time scales. More... | |
| struct | timeutil_sync_state |
| State required to convert instants between time scales. More... | |
Macros | |
| #define | TIME_UTILS_BASE_YEAR 1900 |
Functions | |
| int64_t | timeutil_timegm64 (const struct tm *tm) |
| Convert broken-down time to a POSIX epoch offset in seconds. | |
| time_t | timeutil_timegm (const struct tm *tm) |
| Convert broken-down time to a POSIX epoch offset in seconds. | |
| int | timeutil_sync_state_update (struct timeutil_sync_state *tsp, const struct timeutil_sync_instant *inst) |
| Record a new instant in the time synchronization state. | |
| int | timeutil_sync_state_set_skew (struct timeutil_sync_state *tsp, float skew, const struct timeutil_sync_instant *base) |
| Update the state with a new skew and possibly base value. | |
| float | timeutil_sync_estimate_skew (const struct timeutil_sync_state *tsp) |
| Estimate the skew based on current state. | |
| int | timeutil_sync_ref_from_local (const struct timeutil_sync_state *tsp, uint64_t local, uint64_t *refp) |
| Interpolate a reference timescale instant from a local instant. | |
| int | timeutil_sync_local_from_ref (const struct timeutil_sync_state *tsp, uint64_t ref, int64_t *localp) |
| Interpolate a local timescale instant from a reference instant. | |
| int32_t | timeutil_sync_skew_to_ppb (float skew) |
| Convert from a skew to an error in parts-per-billion. | |
| static bool | timespec_is_valid (const struct timespec *ts) |
| Check if a timespec is valid. | |
| static bool | timespec_normalize (struct timespec *ts) |
Normalize a timespec so that the tv_nsec field is in valid range. | |
| static bool | timespec_add (struct timespec *a, const struct timespec *b) |
| Add one timespec to another. | |
| static bool | timespec_negate (struct timespec *ts) |
| Negate a timespec object. | |
| static bool | timespec_sub (struct timespec *a, const struct timespec *b) |
| Subtract one timespec from another. | |
| static int | timespec_compare (const struct timespec *a, const struct timespec *b) |
| Compare two timespec objects. | |
| static bool | timespec_equal (const struct timespec *a, const struct timespec *b) |
| Check if two timespec objects are equal. | |
| static void | timespec_from_timeout (k_timeout_t timeout, struct timespec *ts) |
| Convert a kernel timeout to a timespec. | |
| static k_timeout_t | timespec_to_timeout (const struct timespec *ts) |
| Convert a timespec to a kernel timeout. | |
Utilities supporting operation on time data structures.
POSIX defines gmtime() to convert from time_t to struct tm, but all inverse transformations are non-standard or require access to time zone information. timeutil_timegm() implements the functionality of the GNU extension timegm() function, but changes the error value as EOVERFLOW is not a standard C error identifier.
timeutil_timegm64() is provided to support full precision conversion on platforms where time_t is limited to 32 bits.