1.5. time — System time¶
Source code: src/kernel/time.h, src/kernel/time.c
Test code: tst/kernel/time/main.c
Test coverage: src/kernel/time.c
Functions
-
int
time_get(struct time_t *now_p)¶ Get current time in seconds and nanoseconds. The resolution of the time is implementation specific and may vary a lot between different architectures.
- Return
- zero(0) or negative error code.
- Parameters
now_p: Read current time.
-
int
time_set(struct time_t *new_p)¶ Set current time in seconds and nanoseconds.
- Return
- zero(0) or negative error code.
- Parameters
new_p: New current time.
-
int
time_add(struct time_t *res_p, struct time_t *left_p, struct time_t *right_p)¶ Add given times.
- Return
- zero(0) or negative error code.
- Parameters
res_p: The result of the addingleft_ptoright_p.left_p: First operand.right_p: Second operand.
-
int
time_subtract(struct time_t *res_p, struct time_t *left_p, struct time_t *right_p)¶ Subtract given times.
- Return
- zero(0) or negative error code.
- Parameters
res_p: The result of the subtranctingleft_pfromright_p.left_p: The operand to subtract from.right_p: The operand to subtract.
-
void
time_busy_wait_us(long useconds)¶ Busy wait for given number of microseconds.
NOTE: The maximum allowed time to sleep is target specific.
- Return
- void
- Parameters
useconds: Microseconds to busy wait.
-
struct
time_t¶ - #include <time.h>
-
struct
date_t¶ - #include <time.h>
A date in year, month, date, day, hour, minute and seconds.