From 7bd050ccf74222e1b659f2fd6826a86e6afbcc94 Mon Sep 17 00:00:00 2001 From: nodist Date: Tue, 6 Oct 2026 17:13:01 -0400 Subject: basic tests --- include/kpl/object.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/kpl/object.h (limited to 'include/kpl/object.h') diff --git a/include/kpl/object.h b/include/kpl/object.h new file mode 100644 index 0000000..0f54a5e --- /dev/null +++ b/include/kpl/object.h @@ -0,0 +1,33 @@ +/* + * KPL specific objects + */ + +#pragma once + +// for atomic linked list queue +// size in bytes, index on the kpl_threads array +#define KPL_OBJECT_HEADER(STRUCT_NAME) \ + struct STRUCT_NAME *_Atomic queue_next; \ + int32_t obj_size, thread_id + +typedef struct _kpl_object { + KPL_OBJECT_HEADER(_kpl_object); +} kpl_object; // all kpl objects allocated by the kpl allocator extend this header + +typedef struct { + kpl_object *_Atomic head, *tail; // head is modified with atomic exchange + struct { + kpl_object *_Atomic queue_next; + } dummy; // head and tail are never null will always point to this +} kpl_object_queue; // atomic linked list queue any thread can add, only owner thread can remove + +typedef struct _kpl_task kpl_task; + +typedef struct _kpl_env kpl_env; + +typedef void kpl_task_fn(kpl_task *task, kpl_env *env); + +typedef struct _kpl_task { + KPL_OBJECT_HEADER(_kpl_task); + // TODO +} kpl_task; -- cgit v1.2.3