CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
1// Copyright SCI Semiconductor and CHERIoT Contributors.
2// SPDX-License-Identifier: MIT
3#pragma once
4/**
5 * \file
6 * POSIX time definitions. This is *not* a complete implementation of the POSIX
7 * spec. The following are not implemented in CHERIoT RTOS:
8 *
9 * - `FD_CLR()`, `FD_ISSET()`, `FD_SET(), `FD_ZERO()`, `FD_SETSIZE`, and
10 * `fd_set`, used for `select`.
11 * - `select` is not implemented because we do not have the POSIX file
12 * descriptor abstraction, use the APIs in `multiwaiter.h` to wait for multiple
13 * event sources.
14 * - `utimes`, which depends on a filesystem.
15 * - `getitimer` and `setitimer`, which are deprecated in POSIX.
16 */
17
18#include <cdefs.h>
19#include <stdint.h>
20
21// The names in this file come from C or POSIX and so do not correspond to our
22// naming scheme. This header is expected to be included in C, so should also
23// not provide warnings about void in function parameter lists.
24// NOLINTBEGIN(readability-identifier-naming,modernize-redundant-void-arg)
25
26/// Type for holding seconds
27typedef int64_t time_t;
28/// Type for holding microseconds up to one second, which requires 20 bits.
29typedef uint32_t suseconds_t;
30
31/**
32 * Type used for time values as seconds and microseconds.
33 */
34struct timeval
35{
36 /// Number of seconds.
37 time_t tv_sec;
38 /// Number of microseconds (must be less than 1,000,000)
39 suseconds_t tv_usec;
40};
41
42/**
43 * Get the current wall-clock time. The time-zone parameter is unused.
44 */
45__cheriot_libcall int gettimeofday(struct timeval *__restrict tp,
46 void *__restrict tzp);
47
48// NOLINTEND(readability-identifier-naming,modernize-redundant-void-arg)
Definition time.h:35
suseconds_t tv_usec
Number of microseconds (must be less than 1,000,000).
Definition time.h:39
time_t tv_sec
Number of seconds.
Definition time.h:37
__cheriot_libcall int gettimeofday(struct timeval *__restrict tp, void *__restrict tzp)
Get the current wall-clock time.