|
Loom C API
Public Loom compiler C API
|
Base types, descriptors, spans, and host allocation helpers. More...
Go to the source code of this file.
Data Structures | |
| struct | loomc_string_view_t |
| Non-owning string view over bytes that need not be NUL-terminated. More... | |
| struct | loomc_byte_span_t |
| Non-owning view over immutable bytes. More... | |
| struct | loomc_dimension3_t |
| Three-dimensional unsigned extent used by Loom C API structs. More... | |
| struct | loomc_option_entry_t |
| One loose string option entry. More... | |
| struct | loomc_option_dict_t |
| Ordered loose string option dictionary. More... | |
| struct | loomc_allocator_alloc_params_t |
| Allocation parameters passed to loomc_allocator_ctl_fn_t callbacks. More... | |
| struct | loomc_allocator_t |
| Host allocator used for persistent Loom object storage. More... | |
Macros | |
| #define | LOOMC_API_EXPORT |
| Exports a public Loom C API symbol from a shared library build. | |
| #define | LOOMC_API_PTR |
| Marks a public callback function pointer type. | |
| #define | LOOMC_HOST_SIZE_MAX ((loomc_host_size_t)(SIZE_MAX)) |
| Largest representable loomc_host_size_t value. | |
| #define | IREE_ALLOCATOR_ALLOC_PARAMS_T_DEFINED_ |
| Indicates that the shared allocator parameter structure has been declared. | |
Typedefs | |
| typedef size_t | loomc_host_size_t |
| Host allocation and container size type. | |
| typedef struct iree_status_handle_t * | loomc_status_t |
| Opaque status handle. | |
| typedef uint32_t | loomc_allocator_command_t |
| Controls the behavior of a loomc_allocator_ctl_fn_t callback. | |
| typedef loomc_status_t(* | loomc_allocator_ctl_fn_t) (void *self, loomc_allocator_command_t command, const void *params, void **inout_ptr) |
| Host allocation control callback. | |
Functions | |
| loomc_allocator_t | loomc_allocator_system (void) |
| Returns a process-global system allocator. | |
| loomc_status_t | loomc_allocator_malloc (loomc_allocator_t allocator, loomc_host_size_t byte_length, void **out_ptr) |
| Allocates zero-initialized memory from allocator. | |
| loomc_status_t | loomc_allocator_malloc_uninitialized (loomc_allocator_t allocator, loomc_host_size_t byte_length, void **out_ptr) |
| Allocates uninitialized memory from allocator. | |
| loomc_status_t | loomc_string_view_clone (loomc_string_view_t source, loomc_allocator_t allocator, loomc_string_view_t *out_string) |
| Copies a string view into allocator-owned storage. | |
| void | loomc_allocator_free (loomc_allocator_t allocator, void *ptr) |
| Frees memory previously returned by allocator. | |
Base types, descriptors, spans, and host allocation helpers.
This header contains the small C ABI building blocks used by all other Loom C API headers. The types here avoid exposing implementation dependencies and are designed to be straightforward to mirror from foreign-function bindings.
| typedef loomc_status_t(* loomc_allocator_ctl_fn_t) (void *self, loomc_allocator_command_t command, const void *params, void **inout_ptr) |
Host allocation control callback.
| self | Callback-owned allocator state pointer. |
| command | Allocation command to perform. |
| params | Command-specific parameter structure. |
| inout_ptr | Pointer to allocation storage. Allocation commands write the allocated pointer. Free commands read the pointer to free. |
| typedef size_t loomc_host_size_t |
Host allocation and container size type.
Values have the same range as C size_t. Public ABI fields use this spelling so bindings can mirror one Loom-specific type name rather than repeating the C standard library type across the API.
| typedef struct iree_status_handle_t* loomc_status_t |
Opaque status handle.
Small status codes are encoded directly in the pointer value. Rich status modes may allocate storage behind the handle and require loomc_status_free or loomc_status_consume_code.
| anonymous enum |
Structure type values used by extensible public descriptors.
Extensible descriptors store one of these values in their type field and store sizeof(descriptor_type) in structure_size. Callers zero-initialize descriptors and set the fields they use.
| void loomc_allocator_free | ( | loomc_allocator_t | allocator, |
| void * | ptr ) |
Frees memory previously returned by allocator.
| allocator | Allocator that returned ptr. |
| ptr | Allocation to free. Passing NULL is allowed. |
When ptr is non-NULL, allocator.ctl must also be non-NULL. Invalid allocator values are programmer errors because this function has no status channel.
| loomc_status_t loomc_allocator_malloc | ( | loomc_allocator_t | allocator, |
| loomc_host_size_t | byte_length, | ||
| void ** | out_ptr ) |
Allocates zero-initialized memory from allocator.
| allocator | Allocator used for the allocation. |
| byte_length | Number of bytes to allocate. |
| out_ptr | Receives the allocated memory on success. |
| loomc_status_t loomc_allocator_malloc_uninitialized | ( | loomc_allocator_t | allocator, |
| loomc_host_size_t | byte_length, | ||
| void ** | out_ptr ) |
Allocates uninitialized memory from allocator.
| allocator | Allocator used for the allocation. |
| byte_length | Number of bytes to allocate. |
| out_ptr | Receives the allocated memory on success. |
| loomc_allocator_t loomc_allocator_system | ( | void | ) |
Returns a process-global system allocator.
| loomc_status_t loomc_string_view_clone | ( | loomc_string_view_t | source, |
| loomc_allocator_t | allocator, | ||
| loomc_string_view_t * | out_string ) |
Copies a string view into allocator-owned storage.
| source | Borrowed source string view to copy. |
| allocator | Allocator used for the copied storage. |
| out_string | Receives the owned string view on success. |
Empty source views produce an empty output view without allocating. The copied bytes are not NUL-terminated.