| // Copyright 2025 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. | |
| // This file is automatically generated by //sdk/lib/async/rust/sys:async_sys_bindgen_golden. | |
| #![expect(non_camel_case_types)] | |
| use zx_types::*; | |
| #[doc = " Dispatcher interface for performing asynchronous operations.\n There may be multiple implementations of this interface."] | |
| pub type async_dispatcher_t = async_dispatcher; | |
| #[doc = " Holds context for a bell trap and its handler.\n\n After successfully posting setting the trap, the client is responsible for retaining\n the structure in memory (and unmodified) until the guest has been destroyed or the\n dispatcher shuts down. There is no way to cancel a trap which has been set."] | |
| pub type async_guest_bell_trap_t = async_guest_bell_trap; | |
| #[doc = " Holds context for an asynchronous wait operation and its handler.\n\n After successfully beginning the wait, the client is responsible for retaining\n the structure in memory (and unmodified) until the wait's handler runs, the wait\n is successfully canceled, or the dispatcher shuts down. Thereafter, the wait\n may be started begun or destroyed."] | |
| pub type async_wait_t = async_wait; | |
| #[doc = " Holds context for a task and its handler.\n\n After successfully posting the task, the client is responsible for retaining\n the structure in memory (and unmodified) until the task's handler runs, the task\n is successfully canceled, or the dispatcher shuts down. Thereafter, the task\n may be posted again or destroyed."] | |
| pub type async_task_t = async_task; | |
| #[doc = " Holds content for a packet receiver and its handler.\n\n After successfully queuing packets to the receiver, the client is responsible\n for retaining the structure in memory (and unmodified) until all packets have\n been received by the handler or the dispatcher shuts down. There is no way\n to cancel a packet which has been queued.\n\n Multiple packets may be delivered to the same receiver concurrently."] | |
| pub type async_receiver_t = async_receiver; | |
| #[doc = " Similar to async_wait, but holds state for an interrupt."] | |
| pub type async_irq_t = async_irq; | |
| #[doc = " Holds content for a paged request packet receiver and its handler.\n\n The client is responsible for retaining the structure in memory\n (and unmodified) until all packets have been received by the handler or the\n dispatcher shuts down."] | |
| pub type async_paged_vmo_t = async_paged_vmo; | |
| #[doc = " A dispatcher-specific sequence identifier, which identifies a set of actions\n with a total ordering of execution: each subsequent action will always\n observe side-effects from previous actions, if the thread(s) performing those\n actions have the same sequence identifier.\n\n For example, a dispatcher backed by a thread pool may choose to implement\n sequences by acquiring a sequence-specific lock before running any actions\n from that sequence, ensuring mutual exclusion within each sequence."] | |
| pub type async_sequence_id_t = async_sequence_id; | |
| #[doc = " Private state owned by the asynchronous dispatcher.\n This allows the dispatcher to associate a small amount of state with pending\n asynchronous operations without having to allocate additional heap storage of\n its own.\n\n Clients must initialize the contents of this structure to zero using\n |ASYNC_STATE_INIT| or with calloc, memset, or a similar means."] | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_state_t { | |
| pub reserved: [usize; 2usize], | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_state_t"][::core::mem::size_of::<async_state_t>() - 16usize]; | |
| ["Alignment of async_state_t"][::core::mem::align_of::<async_state_t>() - 8usize]; | |
| ["Offset of field: async_state_t::reserved"] | |
| [::core::mem::offset_of!(async_state_t, reserved) - 0usize]; | |
| }; | |
| #[doc = " Asynchronous dispatcher interface.\n\n Clients should not call into this interface directly: use the wrapper functions\n declared in other header files, such as |async_begin_wait()| in <lib/async/wait.h>.\n See the documentation of those functions for details about each method's purpose\n and behavior.\n\n This interface consists of several groups of methods:\n\n - Timing: |now|\n - Waiting for signals: |begin_wait|, |cancel_wait|\n - Posting tasks: |post_task|, |cancel_task|\n - Queuing packets: |queue_packet|\n - Virtual machine operations: |set_guest_bell_trap|\n\n To preserve binary compatibility, each successive version of this interface\n is guaranteed to be backwards-compatible with clients of earlier versions.\n New methods must only be added by extending the structure at the end and\n declaring a new version number. Do not reorder the declarations or modify\n existing versions.\n\n Implementations of this interface must provide valid (non-null) function pointers\n for every method declared in the interface version they support. Unsupported\n methods must return |ZX_ERR_NOT_SUPPORTED| and have no other side-effects.\n Furthermore, if an implementation supports one method of a group, such as |begin_wait|,\n then it must also support the other methods of the group, such as |cancel_wait|.\n\n Many clients assume that the dispatcher interface is fully implemented and may\n fail to work with dispatchers that do not support the methods they need.\n Therefore general-purpose dispatcher implementations are encouraged to support\n the whole interface to ensure broad compatibility."] | |
| pub type async_ops_version_t = u32; | |
| pub const ASYNC_OPS_V1: async_ops_version_t = 1; | |
| pub const ASYNC_OPS_V2: async_ops_version_t = 2; | |
| pub const ASYNC_OPS_V3: async_ops_version_t = 3; | |
| pub const ASYNC_OPS_V4: async_ops_version_t = 4; | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_ops { | |
| #[doc = " The interface version number, e.g. |ASYNC_OPS_V1|."] | |
| pub version: async_ops_version_t, | |
| #[doc = " Reserved for future expansion, set to zero."] | |
| pub reserved: u32, | |
| pub v1: async_ops_v1, | |
| pub v2: async_ops_v2, | |
| pub v3: async_ops_v3, | |
| pub v4: async_ops_v4, | |
| } | |
| #[doc = " Operations supported by |ASYNC_OPS_V1|."] | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_ops_v1 { | |
| #[doc = " See |async_now()| for details."] | |
| pub now: ::core::option::Option< | |
| unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_time_t, | |
| >, | |
| #[doc = " See |async_begin_wait()| for details."] | |
| pub begin_wait: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| wait: *mut async_wait_t, | |
| ) -> zx_status_t, | |
| >, | |
| #[doc = " See |async_cancel_wait()| for details."] | |
| pub cancel_wait: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| wait: *mut async_wait_t, | |
| ) -> zx_status_t, | |
| >, | |
| #[doc = " See |async_post_task()| for details."] | |
| pub post_task: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| task: *mut async_task_t, | |
| ) -> zx_status_t, | |
| >, | |
| #[doc = " See |async_cancel_task()| for details."] | |
| pub cancel_task: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| task: *mut async_task_t, | |
| ) -> zx_status_t, | |
| >, | |
| #[doc = " See |async_queue_packet()| for details."] | |
| pub queue_packet: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| receiver: *mut async_receiver_t, | |
| data: *const zx_packet_user_t, | |
| ) -> zx_status_t, | |
| >, | |
| #[doc = " See |async_set_guest_bell_trap()| for details."] | |
| pub set_guest_bell_trap: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| trap: *mut async_guest_bell_trap_t, | |
| guest: zx_handle_t, | |
| addr: zx_vaddr_t, | |
| length: usize, | |
| ) -> zx_status_t, | |
| >, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_ops_v1"][::core::mem::size_of::<async_ops_v1>() - 56usize]; | |
| ["Alignment of async_ops_v1"][::core::mem::align_of::<async_ops_v1>() - 8usize]; | |
| ["Offset of field: async_ops_v1::now"][::core::mem::offset_of!(async_ops_v1, now) - 0usize]; | |
| ["Offset of field: async_ops_v1::begin_wait"] | |
| [::core::mem::offset_of!(async_ops_v1, begin_wait) - 8usize]; | |
| ["Offset of field: async_ops_v1::cancel_wait"] | |
| [::core::mem::offset_of!(async_ops_v1, cancel_wait) - 16usize]; | |
| ["Offset of field: async_ops_v1::post_task"] | |
| [::core::mem::offset_of!(async_ops_v1, post_task) - 24usize]; | |
| ["Offset of field: async_ops_v1::cancel_task"] | |
| [::core::mem::offset_of!(async_ops_v1, cancel_task) - 32usize]; | |
| ["Offset of field: async_ops_v1::queue_packet"] | |
| [::core::mem::offset_of!(async_ops_v1, queue_packet) - 40usize]; | |
| ["Offset of field: async_ops_v1::set_guest_bell_trap"] | |
| [::core::mem::offset_of!(async_ops_v1, set_guest_bell_trap) - 48usize]; | |
| }; | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_ops_v2 { | |
| pub bind_irq: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| irq: *mut async_irq_t, | |
| ) -> zx_status_t, | |
| >, | |
| pub unbind_irq: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| irq: *mut async_irq_t, | |
| ) -> zx_status_t, | |
| >, | |
| pub create_paged_vmo: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| paged_vmo: *mut async_paged_vmo_t, | |
| options: u32, | |
| pager: zx_handle_t, | |
| vmo_size: u64, | |
| vmo_out: *mut zx_handle_t, | |
| ) -> zx_status_t, | |
| >, | |
| pub detach_paged_vmo: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| paged_vmo: *mut async_paged_vmo_t, | |
| ) -> zx_status_t, | |
| >, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_ops_v2"][::core::mem::size_of::<async_ops_v2>() - 32usize]; | |
| ["Alignment of async_ops_v2"][::core::mem::align_of::<async_ops_v2>() - 8usize]; | |
| ["Offset of field: async_ops_v2::bind_irq"] | |
| [::core::mem::offset_of!(async_ops_v2, bind_irq) - 0usize]; | |
| ["Offset of field: async_ops_v2::unbind_irq"] | |
| [::core::mem::offset_of!(async_ops_v2, unbind_irq) - 8usize]; | |
| ["Offset of field: async_ops_v2::create_paged_vmo"] | |
| [::core::mem::offset_of!(async_ops_v2, create_paged_vmo) - 16usize]; | |
| ["Offset of field: async_ops_v2::detach_paged_vmo"] | |
| [::core::mem::offset_of!(async_ops_v2, detach_paged_vmo) - 24usize]; | |
| }; | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_ops_v3 { | |
| #[doc = " See |async_get_sequence_id()| for details."] | |
| pub get_sequence_id: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| out_sequence_id: *mut async_sequence_id_t, | |
| out_error: *mut *const ::core::ffi::c_char, | |
| ) -> zx_status_t, | |
| >, | |
| #[doc = " See |async_check_sequence_id()| for details."] | |
| pub check_sequence_id: ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| sequence_id: async_sequence_id_t, | |
| out_error: *mut *const ::core::ffi::c_char, | |
| ) -> zx_status_t, | |
| >, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_ops_v3"][::core::mem::size_of::<async_ops_v3>() - 16usize]; | |
| ["Alignment of async_ops_v3"][::core::mem::align_of::<async_ops_v3>() - 8usize]; | |
| ["Offset of field: async_ops_v3::get_sequence_id"] | |
| [::core::mem::offset_of!(async_ops_v3, get_sequence_id) - 0usize]; | |
| ["Offset of field: async_ops_v3::check_sequence_id"] | |
| [::core::mem::offset_of!(async_ops_v3, check_sequence_id) - 8usize]; | |
| }; | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_ops_v4 { | |
| #[doc = " See |async_acquire_shared_ref| for details."] | |
| pub acquire_shared_ref: ::core::option::Option< | |
| unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_status_t, | |
| >, | |
| #[doc = " See |async_release_shared_ref| for details."] | |
| pub release_shared_ref: ::core::option::Option< | |
| unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_status_t, | |
| >, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_ops_v4"][::core::mem::size_of::<async_ops_v4>() - 16usize]; | |
| ["Alignment of async_ops_v4"][::core::mem::align_of::<async_ops_v4>() - 8usize]; | |
| ["Offset of field: async_ops_v4::acquire_shared_ref"] | |
| [::core::mem::offset_of!(async_ops_v4, acquire_shared_ref) - 0usize]; | |
| ["Offset of field: async_ops_v4::release_shared_ref"] | |
| [::core::mem::offset_of!(async_ops_v4, release_shared_ref) - 8usize]; | |
| }; | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_ops"][::core::mem::size_of::<async_ops>() - 128usize]; | |
| ["Alignment of async_ops"][::core::mem::align_of::<async_ops>() - 8usize]; | |
| ["Offset of field: async_ops::version"][::core::mem::offset_of!(async_ops, version) - 0usize]; | |
| ["Offset of field: async_ops::reserved"][::core::mem::offset_of!(async_ops, reserved) - 4usize]; | |
| ["Offset of field: async_ops::v1"][::core::mem::offset_of!(async_ops, v1) - 8usize]; | |
| ["Offset of field: async_ops::v2"][::core::mem::offset_of!(async_ops, v2) - 64usize]; | |
| ["Offset of field: async_ops::v3"][::core::mem::offset_of!(async_ops, v3) - 96usize]; | |
| ["Offset of field: async_ops::v4"][::core::mem::offset_of!(async_ops, v4) - 112usize]; | |
| }; | |
| pub type async_ops_t = async_ops; | |
| #[repr(C)] | |
| #[derive(Debug, Copy, Clone)] | |
| pub struct async_dispatcher { | |
| pub ops: *const async_ops_t, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_dispatcher"][::core::mem::size_of::<async_dispatcher>() - 8usize]; | |
| ["Alignment of async_dispatcher"][::core::mem::align_of::<async_dispatcher>() - 8usize]; | |
| ["Offset of field: async_dispatcher::ops"] | |
| [::core::mem::offset_of!(async_dispatcher, ops) - 0usize]; | |
| }; | |
| impl Default for async_dispatcher { | |
| fn default() -> Self { | |
| let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); | |
| unsafe { | |
| ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); | |
| s.assume_init() | |
| } | |
| } | |
| } | |
| unsafe extern "C" { | |
| #[doc = " If supported, acquires a shared dispatcher reference for this dispatcher.\n\n If successful, the internal reference count of the dispatcher object will be incremented so that\n it will not be deallocated for any other reason than the outstanding refcount reaching zero. If\n it fails there will be no guarantees about the lifetime of the dispatcher object.\n\n Note that this will not prevent the dispatcher from shutting down. Calls to dispatcher methods\n after shutting down will behave as if the dispatcher is still shutting down.\n\n The client MUST call |async_release_shared_ref| on the returned pointer when it is no\n longer in use if this call succeeds. Not doing so will result in memory leaks.\n\n Returns |ZX_OK| if a shared dispatcher object's reference count has been incremented and its\n memory won't be released before you have called a corresponding |async_release_shared_ref|.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_acquire_shared_ref(dispatcher: *mut async_dispatcher_t) -> zx_status_t; | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Releases a shared dispatcher reference for this dispatcher.\n\n The caller must call this to release a shared dispatcher object acquired by\n |async_acquire_shared_ref|. In general, this should always return ZX_OK if the\n api is used correctly.\n\n Returns |ZX_OK| if the dispatcher has been successfully released.\n Returns |ZX_ERR_NOT_SUPPORTED| if you have tried to call this on a dispatcher that\n does not support having shared references."] | |
| pub fn async_release_shared_ref(dispatcher: *mut async_dispatcher_t) -> zx_status_t; | |
| } | |
| #[doc = " Handles interrupt.\n\n The |status| is |ZX_OK| if the IRQ was signalled.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran or the task was canceled."] | |
| pub type async_irq_handler_t = ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| irq: *mut async_irq_t, | |
| status: zx_status_t, | |
| signal: *const zx_packet_interrupt_t, | |
| ), | |
| >; | |
| #[doc = " Similar to async_wait, but holds state for an interrupt."] | |
| #[repr(C)] | |
| pub struct async_irq { | |
| #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."] | |
| pub state: async_state_t, | |
| #[doc = " The wait's handler function."] | |
| pub handler: async_irq_handler_t, | |
| #[doc = " The object to wait for signals on."] | |
| pub object: zx_handle_t, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_irq"][::core::mem::size_of::<async_irq>() - 32usize]; | |
| ["Alignment of async_irq"][::core::mem::align_of::<async_irq>() - 8usize]; | |
| ["Offset of field: async_irq::state"][::core::mem::offset_of!(async_irq, state) - 0usize]; | |
| ["Offset of field: async_irq::handler"][::core::mem::offset_of!(async_irq, handler) - 16usize]; | |
| ["Offset of field: async_irq::object"][::core::mem::offset_of!(async_irq, object) - 24usize]; | |
| }; | |
| impl Default for async_irq { | |
| fn default() -> Self { | |
| let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); | |
| unsafe { | |
| ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); | |
| s.assume_init() | |
| } | |
| } | |
| } | |
| impl ::core::fmt::Debug for async_irq { | |
| fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { | |
| write!(f, "async_irq {{ state: {:?}, handler: {:?} }}", self.state, self.handler) | |
| } | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Begins asynchronously waiting on an IRQ specified in |irq|.\n Invokes the handler when the wait completes.\n The irq's handler will be invoked once for each interrupt packet received,\n until the irq object is unbound with |async_unbind_irq| or the dispatcher is\n shut down.\n When the dispatcher is shutting down (being destroyed), if the irq has not\n been unbound, the handlers of all remaining irqs will be invoked with a\n status of |ZX_ERR_CANCELED|.\n\n Returns |ZX_OK| if the wait was successfully begun.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_bind_irq( | |
| dispatcher: *mut async_dispatcher_t, | |
| irq: *mut async_irq_t, | |
| ) -> zx_status_t; | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Unbinds the IRQ associated with |irq|.\n\n If successful, the IRQ will be unbound from the async loop and no further\n handler callbacks will be called.\n\n Thread safety note: Since callbacks can be called any time while the irq\n is bound to the dispatcher, and a callback may be in flight when unbind is\n called, care must be taken when this API is used in a multithreaded\n dispatcher not to free the |async_irq_t| struct until after all callbacks\n have settled and unbind has been called. This is unlike the |async_wait| api,\n where |async_cancel_wait| will return |ZX_ERR_NOT_FOUND| if the callback\n has already been started. This can be avoided by using only a single threaded\n or otherwise synchronized dispatcher.\n\n Returns |ZX_OK| if the IRQ has been successfully unbound. |irq| can be\n destroyed as soon as there are no more callbacks in progress.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_unbind_irq( | |
| dispatcher: *mut async_dispatcher_t, | |
| irq: *mut async_irq_t, | |
| ) -> zx_status_t; | |
| } | |
| #[doc = " Handles port packets containing page requests.\n\n The |status| is |ZX_OK| if the packet was successfully delivered and |request|\n contains the information from the packet, otherwise |request| is null.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down."] | |
| pub type async_paged_vmo_handler_t = ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| paged_vmo: *mut async_paged_vmo_t, | |
| status: zx_status_t, | |
| request: *const zx_packet_page_request_t, | |
| ), | |
| >; | |
| #[doc = " Holds content for a paged request packet receiver and its handler.\n\n The client is responsible for retaining the structure in memory\n (and unmodified) until all packets have been received by the handler or the\n dispatcher shuts down."] | |
| #[repr(C)] | |
| pub struct async_paged_vmo { | |
| #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."] | |
| pub state: async_state_t, | |
| #[doc = " The handler to invoke when a packet is received."] | |
| pub handler: async_paged_vmo_handler_t, | |
| #[doc = " The associated pager when creating the VMO."] | |
| pub pager: zx_handle_t, | |
| #[doc = " The VMO for this request."] | |
| pub vmo: zx_handle_t, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_paged_vmo"][::core::mem::size_of::<async_paged_vmo>() - 32usize]; | |
| ["Alignment of async_paged_vmo"][::core::mem::align_of::<async_paged_vmo>() - 8usize]; | |
| ["Offset of field: async_paged_vmo::state"] | |
| [::core::mem::offset_of!(async_paged_vmo, state) - 0usize]; | |
| ["Offset of field: async_paged_vmo::handler"] | |
| [::core::mem::offset_of!(async_paged_vmo, handler) - 16usize]; | |
| ["Offset of field: async_paged_vmo::pager"] | |
| [::core::mem::offset_of!(async_paged_vmo, pager) - 24usize]; | |
| ["Offset of field: async_paged_vmo::vmo"] | |
| [::core::mem::offset_of!(async_paged_vmo, vmo) - 28usize]; | |
| }; | |
| impl Default for async_paged_vmo { | |
| fn default() -> Self { | |
| let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); | |
| unsafe { | |
| ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); | |
| s.assume_init() | |
| } | |
| } | |
| } | |
| impl ::core::fmt::Debug for async_paged_vmo { | |
| fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { | |
| write!(f, "async_paged_vmo {{ state: {:?}, handler: {:?} }}", self.state, self.handler) | |
| } | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Create a pager owned VMO.\n\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n Other error values are possible. See the documentation for\n |zx_pager_create_vmo()|."] | |
| pub fn async_create_paged_vmo( | |
| dispatcher: *mut async_dispatcher_t, | |
| paged_vmo: *mut async_paged_vmo_t, | |
| options: u32, | |
| pager: zx_handle_t, | |
| vmo_size: u64, | |
| vmo_out: *mut zx_handle_t, | |
| ) -> zx_status_t; | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Detach ownership of VMO from pager.\n\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n Returns |ZX_ERR_BAD_HANDLE| if pager or vmo is not a valid handle.\n Returns |ZX_ERR_WRONG_TYPE| if pager is not a pager handle or vmo is not a vmo handle.\n Returns |ZX_ERR_INVALID_ARGS| if vmo is not a vmo created from pager.\n Other error values are possible. See the documentation for\n |zx_detach_paged_vmo()|."] | |
| pub fn async_detach_paged_vmo( | |
| dispatcher: *mut async_dispatcher_t, | |
| paged_vmo: *mut async_paged_vmo_t, | |
| ) -> zx_status_t; | |
| } | |
| #[doc = " Handles receipt of packets containing user supplied data.\n\n The |status| is |ZX_OK| if the packet was successfully delivered and |data|\n contains the information from the packet, otherwise |data| is null."] | |
| pub type async_receiver_handler_t = ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| receiver: *mut async_receiver_t, | |
| status: zx_status_t, | |
| data: *const zx_packet_user_t, | |
| ), | |
| >; | |
| #[doc = " Holds content for a packet receiver and its handler.\n\n After successfully queuing packets to the receiver, the client is responsible\n for retaining the structure in memory (and unmodified) until all packets have\n been received by the handler or the dispatcher shuts down. There is no way\n to cancel a packet which has been queued.\n\n Multiple packets may be delivered to the same receiver concurrently."] | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_receiver { | |
| #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."] | |
| pub state: async_state_t, | |
| #[doc = " The handler to invoke when a packet is received."] | |
| pub handler: async_receiver_handler_t, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_receiver"][::core::mem::size_of::<async_receiver>() - 24usize]; | |
| ["Alignment of async_receiver"][::core::mem::align_of::<async_receiver>() - 8usize]; | |
| ["Offset of field: async_receiver::state"] | |
| [::core::mem::offset_of!(async_receiver, state) - 0usize]; | |
| ["Offset of field: async_receiver::handler"] | |
| [::core::mem::offset_of!(async_receiver, handler) - 16usize]; | |
| }; | |
| unsafe extern "C" { | |
| #[doc = " Enqueues a packet of data for delivery to a receiver.\n\n The |data| will be copied into the packet. May be NULL to create a\n zero-initialized packet payload.\n\n Returns |ZX_OK| if the packet was successfully enqueued.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_queue_packet( | |
| dispatcher: *mut async_dispatcher_t, | |
| receiver: *mut async_receiver_t, | |
| data: *const zx_packet_user_t, | |
| ) -> zx_status_t; | |
| } | |
| #[doc = " A dispatcher-specific sequence identifier, which identifies a set of actions\n with a total ordering of execution: each subsequent action will always\n observe side-effects from previous actions, if the thread(s) performing those\n actions have the same sequence identifier.\n\n For example, a dispatcher backed by a thread pool may choose to implement\n sequences by acquiring a sequence-specific lock before running any actions\n from that sequence, ensuring mutual exclusion within each sequence."] | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_sequence_id { | |
| pub value: u64, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_sequence_id"][::core::mem::size_of::<async_sequence_id>() - 8usize]; | |
| ["Alignment of async_sequence_id"][::core::mem::align_of::<async_sequence_id>() - 8usize]; | |
| ["Offset of field: async_sequence_id::value"] | |
| [::core::mem::offset_of!(async_sequence_id, value) - 0usize]; | |
| }; | |
| unsafe extern "C" { | |
| #[doc = " Gets the dispatcher-specific sequence identifier of the currently executing\n task.\n\n If the execution context of the calling thread is associated with a sequence,\n the dispatcher should populate the sequence identifier representing the\n current sequence. Otherwise, it should return an error code detailed below.\n\n Returns |ZX_OK| if the sequence identifier was successfully obtained.\n Returns |ZX_ERR_INVALID_ARGS| if the dispatcher supports sequences, but the\n calling thread is not executing a task managed by the dispatcher.\n Returns |ZX_ERR_WRONG_TYPE| if the calling thread is executing a task\n managed by the dispatcher, but that task is not part of a sequence.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n |out_error| will not be mutated when the return value is |ZX_OK|. Otherwise,\n it will be set to a NULL-terminated detailed explanation of the error, which\n may suggest corrective actions that are specific to that asynchronous\n runtime. If set, the error string will have static storage duration (for\n example, an implementation may return string literals).\n\n This operation is thread-safe."] | |
| pub fn async_get_sequence_id( | |
| dispatcher: *mut async_dispatcher_t, | |
| out_sequence_id: *mut async_sequence_id_t, | |
| out_error: *mut *const ::core::ffi::c_char, | |
| ) -> zx_status_t; | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Checks that the the dispatcher-specific sequence identifier of the currently\n executing task is equal to |sequence_id|.\n\n If the sequence identifier of the calling thread cannot be successfully\n obtained, it should return an error code detailed below:\n\n - Returns |ZX_ERR_INVALID_ARGS| if the dispatcher supports sequences, but the\n calling thread is not executing a task managed by the dispatcher.\n - Returns |ZX_ERR_WRONG_TYPE| if the calling thread is executing a task\n managed by the dispatcher, but that task is not part of a sequence.\n - Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n Otherwise, the dispatcher should check that the sequence identifier\n representing the current sequence equals to |sequence_id|:\n\n - Returns |ZX_OK| if the sequence identifiers are equal.\n - Returns |ZX_ERR_OUT_OF_RANGE| if the sequence identifiers are not equal.\n\n |out_error| will not be mutated when the return value is |ZX_OK|. Otherwise,\n it will be set to a NULL-terminated detailed explanation of the error, which\n may suggest corrective actions that are specific to that asynchronous\n runtime. If set, the error string will have static storage duration (for\n example, an implementation may return string literals).\n\n This operation is thread-safe."] | |
| pub fn async_check_sequence_id( | |
| dispatcher: *mut async_dispatcher_t, | |
| sequence_id: async_sequence_id_t, | |
| out_error: *mut *const ::core::ffi::c_char, | |
| ) -> zx_status_t; | |
| } | |
| #[doc = " Handles execution of a posted task.\n\n The |status| is |ZX_OK| if the task's deadline elapsed and the task should run.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran."] | |
| pub type async_task_handler_t = ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| task: *mut async_task_t, | |
| status: zx_status_t, | |
| ), | |
| >; | |
| #[doc = " Holds context for a task and its handler.\n\n After successfully posting the task, the client is responsible for retaining\n the structure in memory (and unmodified) until the task's handler runs, the task\n is successfully canceled, or the dispatcher shuts down. Thereafter, the task\n may be posted again or destroyed."] | |
| #[repr(C)] | |
| pub struct async_task { | |
| #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."] | |
| pub state: async_state_t, | |
| #[doc = " The task's handler function."] | |
| pub handler: async_task_handler_t, | |
| #[doc = " The task's deadline must be expressed in the time base used by the asynchronous\n dispatcher (usually |ZX_CLOCK_MONOTONIC| except in unit tests).\n See |async_now()| for details."] | |
| pub deadline: zx_time_t, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_task"][::core::mem::size_of::<async_task>() - 32usize]; | |
| ["Alignment of async_task"][::core::mem::align_of::<async_task>() - 8usize]; | |
| ["Offset of field: async_task::state"][::core::mem::offset_of!(async_task, state) - 0usize]; | |
| ["Offset of field: async_task::handler"] | |
| [::core::mem::offset_of!(async_task, handler) - 16usize]; | |
| ["Offset of field: async_task::deadline"] | |
| [::core::mem::offset_of!(async_task, deadline) - 24usize]; | |
| }; | |
| impl Default for async_task { | |
| fn default() -> Self { | |
| let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); | |
| unsafe { | |
| ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); | |
| s.assume_init() | |
| } | |
| } | |
| } | |
| impl ::core::fmt::Debug for async_task { | |
| fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { | |
| write!(f, "async_task {{ state: {:?}, handler: {:?} }}", self.state, self.handler) | |
| } | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Posts a task to run on or after its deadline following all posted\n tasks with lesser or equal deadlines.\n\n The task's handler will be invoked exactly once unless the task is canceled.\n When the dispatcher is shutting down (being destroyed), the handlers of\n all remaining tasks will be invoked with a status of |ZX_ERR_CANCELED|.\n\n Dispatcher implementations must treat |ZX_TIME_INFINITE_PAST| as a sentinel\n value meaning \"no deadline\". Tasks with expired deadlines must always be\n processed before tasks without deadlines (those posted with\n |ZX_TIME_INFINITE_PAST|).\n\n Note: If there are always tasks with expired deadlines, tasks without\n deadlines may be starved.\n\n Returns |ZX_OK| if the task was successfully posted.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_post_task( | |
| dispatcher: *mut async_dispatcher_t, | |
| task: *mut async_task_t, | |
| ) -> zx_status_t; | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Cancels the task associated with |task|.\n\n If successful, the task's handler will not run.\n\n Returns |ZX_OK| if the task was pending and it has been successfully\n canceled; its handler will not run again and can be released immediately.\n Returns |ZX_ERR_NOT_FOUND| if there was no pending task either because it\n already ran, had not been posted, or has been dequeued and is pending\n execution (perhaps on another thread).\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_cancel_task( | |
| dispatcher: *mut async_dispatcher_t, | |
| task: *mut async_task_t, | |
| ) -> zx_status_t; | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Returns the current time in the dispatcher's timebase.\n For most loops, this is generally obtained from |ZX_CLOCK_MONOTONIC|\n but certain loops may use a different tiembase, notably for testing."] | |
| pub fn async_now(dispatcher: *mut async_dispatcher_t) -> zx_time_t; | |
| } | |
| #[doc = " Handles an asynchronous trap access.\n\n The |status| is |ZX_OK| if the bell was received and |bell| contains the\n information from the packet, otherwise |bell| is null."] | |
| pub type async_guest_bell_trap_handler_t = ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| trap: *mut async_guest_bell_trap_t, | |
| status: zx_status_t, | |
| bell: *const zx_packet_guest_bell_t, | |
| ), | |
| >; | |
| #[doc = " Holds context for a bell trap and its handler.\n\n After successfully posting setting the trap, the client is responsible for retaining\n the structure in memory (and unmodified) until the guest has been destroyed or the\n dispatcher shuts down. There is no way to cancel a trap which has been set."] | |
| #[repr(C)] | |
| #[derive(Debug, Default, Copy, Clone)] | |
| pub struct async_guest_bell_trap { | |
| #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."] | |
| pub state: async_state_t, | |
| #[doc = " The handler to invoke to handle the trap access."] | |
| pub handler: async_guest_bell_trap_handler_t, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_guest_bell_trap"][::core::mem::size_of::<async_guest_bell_trap>() - 24usize]; | |
| ["Alignment of async_guest_bell_trap"] | |
| [::core::mem::align_of::<async_guest_bell_trap>() - 8usize]; | |
| ["Offset of field: async_guest_bell_trap::state"] | |
| [::core::mem::offset_of!(async_guest_bell_trap, state) - 0usize]; | |
| ["Offset of field: async_guest_bell_trap::handler"] | |
| [::core::mem::offset_of!(async_guest_bell_trap, handler) - 16usize]; | |
| }; | |
| unsafe extern "C" { | |
| #[doc = " Sets a bell trap in the guest to be handled asynchronously via a handler.\n\n |guest| is the handle of the guest the trap will be set on.\n |addr| is the base address for the trap in the guest's physical address space.\n |length| is the size of the trap in the guest's physical address space.\n\n Returns |ZX_OK| if the trap was successfully set.\n Returns |ZX_ERR_ACCESS_DENIED| if the guest does not have |ZX_RIGHT_WRITE|.\n Returns |ZX_ERR_ALREADY_EXISTS| if a bell trap with the same |addr| exists.\n Returns |ZX_ERR_INVALID_ARGS| if |addr| or |length| are invalid.\n Returns |ZX_ERR_OUT_OF_RANGE| if |addr| or |length| are out of range of the\n address space.\n Returns |ZX_ERR_WRONG_TYPE| if |guest| is not a handle to a guest.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_set_guest_bell_trap( | |
| dispatcher: *mut async_dispatcher_t, | |
| trap: *mut async_guest_bell_trap_t, | |
| guest: zx_handle_t, | |
| addr: zx_vaddr_t, | |
| length: usize, | |
| ) -> zx_status_t; | |
| } | |
| #[doc = " Handles completion of asynchronous wait operations.\n\n The |status| is |ZX_OK| if the wait was satisfied and |signal| is non-null.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran or the task was canceled."] | |
| pub type async_wait_handler_t = ::core::option::Option< | |
| unsafe extern "C" fn( | |
| dispatcher: *mut async_dispatcher_t, | |
| wait: *mut async_wait_t, | |
| status: zx_status_t, | |
| signal: *const zx_packet_signal_t, | |
| ), | |
| >; | |
| #[doc = " Holds context for an asynchronous wait operation and its handler.\n\n After successfully beginning the wait, the client is responsible for retaining\n the structure in memory (and unmodified) until the wait's handler runs, the wait\n is successfully canceled, or the dispatcher shuts down. Thereafter, the wait\n may be started begun or destroyed."] | |
| #[repr(C)] | |
| pub struct async_wait { | |
| #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."] | |
| pub state: async_state_t, | |
| #[doc = " The wait's handler function."] | |
| pub handler: async_wait_handler_t, | |
| #[doc = " The object to wait for signals on."] | |
| pub object: zx_handle_t, | |
| #[doc = " The set of signals to wait for."] | |
| pub trigger: zx_signals_t, | |
| #[doc = " Wait options, see zx_object_wait_async()."] | |
| pub options: u32, | |
| } | |
| #[allow(clippy::unnecessary_operation, clippy::identity_op)] | |
| const _: () = { | |
| ["Size of async_wait"][::core::mem::size_of::<async_wait>() - 40usize]; | |
| ["Alignment of async_wait"][::core::mem::align_of::<async_wait>() - 8usize]; | |
| ["Offset of field: async_wait::state"][::core::mem::offset_of!(async_wait, state) - 0usize]; | |
| ["Offset of field: async_wait::handler"] | |
| [::core::mem::offset_of!(async_wait, handler) - 16usize]; | |
| ["Offset of field: async_wait::object"][::core::mem::offset_of!(async_wait, object) - 24usize]; | |
| ["Offset of field: async_wait::trigger"] | |
| [::core::mem::offset_of!(async_wait, trigger) - 28usize]; | |
| ["Offset of field: async_wait::options"] | |
| [::core::mem::offset_of!(async_wait, options) - 32usize]; | |
| }; | |
| impl Default for async_wait { | |
| fn default() -> Self { | |
| let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); | |
| unsafe { | |
| ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); | |
| s.assume_init() | |
| } | |
| } | |
| } | |
| impl ::core::fmt::Debug for async_wait { | |
| fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { | |
| write!(f, "async_wait {{ state: {:?}, handler: {:?} }}", self.state, self.handler) | |
| } | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Begins asynchronously waiting for an object to receive one or more signals\n specified in |wait|. Invokes the handler when the wait completes.\n\n The wait's handler will be invoked exactly once unless the wait is canceled.\n When the dispatcher is shutting down (being destroyed), the handlers of\n all remaining waits will be invoked with a status of |ZX_ERR_CANCELED|.\n\n Returns |ZX_OK| if the wait was successfully begun.\n Returns |ZX_ERR_ACCESS_DENIED| if the object does not have |ZX_RIGHT_WAIT|.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_begin_wait( | |
| dispatcher: *mut async_dispatcher_t, | |
| wait: *mut async_wait_t, | |
| ) -> zx_status_t; | |
| } | |
| unsafe extern "C" { | |
| #[doc = " Cancels the wait associated with |wait|.\n\n If successful, the wait's handler will not run.\n\n Returns |ZX_OK| if the wait was pending and it has been successfully\n canceled; its handler will not run again and can be released immediately.\n Returns |ZX_ERR_NOT_FOUND| if there was no pending wait either because it\n already completed, had not been started, or its completion packet has been\n dequeued from the port and is pending delivery to its handler (perhaps on\n another thread).\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."] | |
| pub fn async_cancel_wait( | |
| dispatcher: *mut async_dispatcher_t, | |
| wait: *mut async_wait_t, | |
| ) -> zx_status_t; | |
| } |