diff options
Diffstat (limited to 'include/kpl/value.h')
| -rw-r--r-- | include/kpl/value.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/include/kpl/value.h b/include/kpl/value.h index e0bf0c7..d6120ee 100644 --- a/include/kpl/value.h +++ b/include/kpl/value.h @@ -4,6 +4,16 @@ #pragma once +/* + * Enum values need to fit within in 3 bits + */ +typedef enum : uint8_t { + KPL_VALUE_BIT_WIDTH8 = 1, + KPL_VALUE_BIT_WIDTH16 = 2, + KPL_VALUE_BIT_WIDTH32 = 3, + KPL_VALUE_BIT_WIDTH64 = 4 +} kpl_value_bit_width; + #define _KPL_VALUE8 \ uint8_t u8; \ int8_t i8 @@ -45,11 +55,15 @@ typedef union { void *ptr; } kpl_value64; +#define KPL_VALUE64_EMPTY ((kpl_value64) { .ptr = NULL }) + typedef struct { kpl_value64 value; int64_t tag; } kpl_result; +#define KPL_RESULT_EMPTY ((kpl_result) { .value = KPL_VALUE64_EMPTY, .tag = 0 }) + typedef struct { void *async, *sync; } kpl_function; @@ -59,9 +73,11 @@ typedef struct { * if code != KPL_EXIT_CODE_SUCCESS then return code */ typedef enum : int32_t { - KPL_EXIT_CODE_SUCCESS = 0, - KPL_EXIT_CODE_ERROR = 1, - KPL_EXIT_CODE_HELP = 2, - KPL_EXIT_CODE_IO_ERROR = 3, - KPL_EXIT_CODE_THREAD_ERROR = 4 + KPL_EXIT_CODE_SUCCESS, + KPL_EXIT_CODE_ERROR, + KPL_EXIT_CODE_HELP, + KPL_EXIT_CODE_MEMORY_ERROR, + KPL_EXIT_CODE_IO_ERROR, + KPL_EXIT_CODE_THREAD_ERROR, + KPL_EXIT_CODE_GC_ERROR } kpl_exit_code; |
