---
title: "clock_res_get()"
description: "Get the resolution of the specified clock."
url: "https://wasix.org/docs/api-reference/wasi/clock_res_get/"
markdown: "https://wasix.org/docs/api-reference/wasi/clock_res_get.md"
---

# `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

```ebnf
  ;;; 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.

---

[Documentation index](https://wasix.org/llms.txt) · [HTML version](https://wasix.org/docs/api-reference/wasi/clock_res_get/)
