Documentation
WASI
clock_res_get

clock_res_get()

Get the resolution of the specified clock.

Description

The clock_res_get() function is used to retrieve the resolution of the specified clock. It returns the resolution of the clock in nanoseconds.

Syntax

  ;;; Note: This is similar to `clock_getres` in POSIX.
  ;;; return `errno::inval`.
  ;;; Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
  ;;; Return the resolution of a clock.
  (@interface func (export "clock_res_get")
    ;;; The clock for which to return the resolution.
    (param $id $clockid)
    ;;; The resolution of the clock, or an error if one happened.
    (result $error (expected $timestamp (error $errno)))
  )

Parameters

  • ctx: A mutable reference to the function environment.
  • clock_id: The ID of the clock to get the resolution of.
  • resolution: A WebAssembly pointer to a memory location where the resolution of the clock will be written.

Return Value

The function returns an Errno value indicating the success or failure of the operation.

Logging

This function has been instrumented with trace-level logging.

Note

The clock_res_get() function retrieves the resolution of the specified clock. The resolution is returned in nanoseconds and is written to the specified memory location.