aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/value.h
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-11-05 15:22:02 -0500
committernodist <kevin.comas.git@gmail.com>2026-11-05 15:22:02 -0500
commit7b9204a8680539bc4795a14f3d9a34e47981d0c3 (patch)
tree7aa69bba0c9cbee0cafb638fd49af64958dbb228 /include/kpl/value.h
parentfaa937cb09cd01f4ea94f5d7722a20e9c1246df0 (diff)
more objects and special slab for gc
Diffstat (limited to 'include/kpl/value.h')
-rw-r--r--include/kpl/value.h26
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;