Add a value to a counter.
#include <zircon/syscalls.h> zx_status_t zx_counter_add(zx_handle_t handle, int64_t value);
zx_counter_add() adds value to the counter referenced by handle.
After the result of the addition, if the counter's value is:
less than or equal to zero - ZX_COUNTER_NON_POSITIVE will be asserted and ZX_COUNTER_POSITIVE will be deasserted.
greater than zero - ZX_COUNTER_POSITIVE will be asserted and ZX_COUNTER_NON_POSITIVE will be deasserted.
handle must have both ZX_RIGHT_READ and ZX_RIGHT_WRITE. Because a counter's value could be determined by checking for ZX_ERR_OUT_OF_RANGE on a series of carefully crafted zx_counter_add() calls, there is no way to create a counter that cannot be read, but which can be added.
zx_counter_add() returns ZX_OK on success.
On failure, an error value is returned.
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_OUT_OF_RANGE if the result of the addition would overflow or underflow.