| <!-- |
| Copyright 2023 The Fuchsia Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| |
| DO NOT EDIT. Generated from FIDL library zx by zither, a Fuchsia platform tool. |
| |
| See //docs/reference/syscalls/README.md#documentation-generation for |
| regeneration instructions. |
| --> |
| |
| # zx_counter_write |
| |
| ## Summary |
| |
| Write a value to a counter. |
| |
| ## Declaration |
| |
| ```c |
| #include <zircon/syscalls.h> |
| |
| zx_status_t zx_counter_write(zx_handle_t handle, int64_t value); |
| ``` |
| |
| ## Description |
| |
| `zx_counter_write()` writes *value* to the counter referenced by *handle*, |
| asserting/deasserting signals as necessary. See [`zx_counter_add()`] for |
| the conditions on which signals are asserted/deasserted. |
| |
| Because concurrent operations on a counter may be interleaved with one another, |
| an implementation of a "counting semaphore" synchronization protocol should use |
| `zx_counter_add()` instead of a sequence of `zx_counter_read()`, modify, |
| `zx_counter_write()`. |
| |
| ## Rights |
| |
| *handle* must have `ZX_RIGHT_WRITE`. |
| |
| ## Return value |
| |
| `zx_counter_write()` returns `ZX_OK` on success. |
| |
| On failure, an error value is returned. |
| |
| ## Errors |
| |
| `ZX_ERR_WRONG_TYPE` if *handle* is not a counter handle. |
| |
| `ZX_ERR_ACCESS_DENIED` if *handle* does not have `ZX_RIGHT_WRITE`. |
| |
| `ZX_ERR_INVALID_ARGS` if *value* is an invalid pointer. |
| |
| ## See also |
| |
| - [`zx_object_wait_async()`] |
| - [`zx_object_wait_many()`] |
| - [`zx_object_wait_one()`] |
| - [`zx_counter_create()`] |
| - [`zx_counter_add()`] |
| - [`zx_counter_read()`] |
| |
| [`zx_object_wait_async()`]: object_wait_async.md |
| [`zx_object_wait_many()`]: object_wait_many.md |
| [`zx_object_wait_one()`]: object_wait_one.md |
| [`zx_counter_create()`]: counter_create.md |
| [`zx_counter_add()`]: counter_add.md |
| [`zx_counter_read()`]: counter_read.md |