Create a new clock object.
#include <zircon/syscalls.h> zx_status_t zx_clock_create(uint64_t options, const void* args, zx_handle_t* out);
None.
Creates a new zircon clock object. See clocks for an overview of clock objects.
The following options are defined for clock objects:
One additional creation-time argument may be specified when configuring the clock, the backstop time. See clocks for more details about backstop times.
In order to configure a backstop time, a user must pass a zx_clock_create_args_v1_t
structure to the zx_clock_create
call via the args
parameter. Additionally, the options
bits must have ZX_CLOCK_ARGS_VERSION(1)
set in them.
For example, a user who wished to create a monotonic clock with a backstop time of 5500 might do something like the following.
#include <zircon/syscalls.h> #include <zircon/syscalls/clock.h> zx_handle_t MakeAClock() { zx_clock_create_args_v1_t args; zx_handle_t the_clock; zx_status_t status; args.backstop_time = 5500; status = zx_clock_create(ZX_CLOCK_ARGS_VERSION(1) | ZX_CLOCK_OPT_MONOTONIC, &args, &the_clock); if (status != ZX_OK) { // Log the error return ZX_HANDLE_INVALID; } return the_clock; }
Users do not have to supply an arguments structure. If an explicit backstop is not required, users may omit the version bits from the options parameter and simply pass nullptr for args.
On success, returns ZX_OK along with a new clock object via the out handle. Handles to newly created clock objects will have the ZX_RIGHT_READ and ZX_RIGHT_WRITE rights assigned to them.