45#define LOOMC_STATUS_FEATURE_SOURCE_LOCATION (1 << 0)
48#define LOOMC_STATUS_FEATURE_ANNOTATIONS (1 << 1)
51#define LOOMC_STATUS_FEATURE_STACK_TRACE (1 << 2)
59#if !defined(LOOMC_STATUS_MODE)
60#if defined(IREE_STATUS_MODE)
61#define LOOMC_STATUS_MODE IREE_STATUS_MODE
63#define LOOMC_STATUS_MODE 2
65#define LOOMC_STATUS_MODE 3
70#if !defined(LOOMC_STATUS_FEATURES)
71#if defined(LOOMC_STATUS_MODE) && LOOMC_STATUS_MODE == 1
72#define LOOMC_STATUS_FEATURES (LOOMC_STATUS_FEATURE_SOURCE_LOCATION)
73#elif defined(LOOMC_STATUS_MODE) && LOOMC_STATUS_MODE == 2
74#define LOOMC_STATUS_FEATURES \
75 (LOOMC_STATUS_FEATURE_SOURCE_LOCATION | LOOMC_STATUS_FEATURE_ANNOTATIONS)
76#elif defined(LOOMC_STATUS_MODE) && LOOMC_STATUS_MODE == 3
77#define LOOMC_STATUS_FEATURES \
78 (LOOMC_STATUS_FEATURE_SOURCE_LOCATION | LOOMC_STATUS_FEATURE_ANNOTATIONS | \
79 LOOMC_STATUS_FEATURE_STACK_TRACE)
81#define LOOMC_STATUS_FEATURES 0
90typedef enum loomc_status_code_e {
218#define loomc_make_status(code, message) \
219 loomc_status_allocate((code), __FILE__, __LINE__, \
220 loomc_make_cstring_view(message))
292#define LOOMC_RETURN_IF_ERROR(expr) \
294 loomc_status_t status__ = (expr); \
295 if (!loomc_status_is_ok(status__)) { \
Base types, descriptors, spans, and host allocation helpers.
#define LOOMC_API_EXPORT
Exports a public Loom C API symbol from a shared library build.
Definition base.h:34
size_t loomc_host_size_t
Host allocation and container size type.
Definition base.h:45
struct iree_status_handle_t * loomc_status_t
Opaque status handle.
Definition base.h:55
loomc_status_code_t
Stable status codes shared by all Loom status modes.
Definition status.h:90
@ LOOMC_STATUS_PERMISSION_DENIED
The caller does not have permission for the requested operation.
Definition status.h:113
@ LOOMC_STATUS_INVALID_ARGUMENT
The caller provided an invalid argument.
Definition status.h:101
@ LOOMC_STATUS_INCOMPATIBLE
The program or environment is incompatible with the request.
Definition status.h:146
@ LOOMC_STATUS_CODE_MASK
Mask covering all status code bits in a loomc_status_t value.
Definition status.h:149
@ LOOMC_STATUS_UNKNOWN
Unknown error or unmapped failure.
Definition status.h:98
@ LOOMC_STATUS_UNAUTHENTICATED
The requested operation does not have proper authentication.
Definition status.h:140
@ LOOMC_STATUS_OK
Successful operation.
Definition status.h:92
@ LOOMC_STATUS_NOT_FOUND
A referenced resource could not be found.
Definition status.h:107
@ LOOMC_STATUS_DEADLINE_EXCEEDED
A deadline was exceeded before the call completed.
Definition status.h:104
@ LOOMC_STATUS_INTERNAL
An internal invariant was violated.
Definition status.h:131
@ LOOMC_STATUS_FAILED_PRECONDITION
The system is not in a required state for the operation.
Definition status.h:119
@ LOOMC_STATUS_DEFERRED
The operation has been deferred and must be resumed later.
Definition status.h:143
@ LOOMC_STATUS_RESOURCE_EXHAUSTED
A required resource was exhausted.
Definition status.h:116
@ LOOMC_STATUS_DATA_LOSS
Unrecoverable data loss or corruption occurred.
Definition status.h:137
@ LOOMC_STATUS_CANCELLED
Operation was cancelled by the caller.
Definition status.h:95
@ LOOMC_STATUS_ABORTED
The operation was aborted by the system.
Definition status.h:122
@ LOOMC_STATUS_ALREADY_EXISTS
The resource the caller attempted to create already exists.
Definition status.h:110
@ LOOMC_STATUS_UNIMPLEMENTED
The operation has not been implemented or is not supported.
Definition status.h:128
@ LOOMC_STATUS_OUT_OF_RANGE
The operation was attempted outside a valid range.
Definition status.h:125
@ LOOMC_STATUS_UNAVAILABLE
The underlying system is currently unavailable.
Definition status.h:134
loomc_status_code_t loomc_status_consume_code(loomc_status_t status)
Frees status storage and returns its code.
bool loomc_status_format(loomc_status_t status, loomc_host_size_t buffer_capacity, char *buffer, loomc_host_size_t *out_length)
Formats status into buffer using the two-pass pattern.
loomc_status_t loomc_status_allocate(loomc_status_code_t code, const char *file, uint32_t line, loomc_string_view_t message)
Allocates a rich status when enabled by LOOMC_STATUS_MODE.
const char * loomc_status_code_string(loomc_status_code_t code)
Returns a stable C string naming code.
loomc_status_t loomc_status_join(loomc_status_t base_status, loomc_status_t new_status)
Joins two statuses without discarding cleanup failures.
loomc_status_source_location_t loomc_status_source_location(loomc_status_t status)
Returns the source location captured by status, when available.
loomc_string_view_t loomc_status_message(loomc_status_t status)
Returns the primary message stored in status.
void loomc_status_free(loomc_status_t status)
Frees status storage, if any.
Source location captured when rich status mode supports it.
Definition status.h:153
loomc_string_view_t file
Source file path, or empty when unavailable.
Definition status.h:155
uint32_t line
One-based source line, or zero when unavailable.
Definition status.h:158
Non-owning string view over bytes that need not be NUL-terminated.
Definition base.h:63