aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-10-03 08:50:07 -0400
committernodist <kevin.comas.git@gmail.com>2026-10-03 08:50:07 -0400
commitde65adbc1b2d1b3efdbe6a023bb7435f84b2f3a7 (patch)
tree2851060d2cf464146d0fb67a50dc52f710076e05 /include
parent2e908a7be31558cc98a9f0e97556e49ee5748c16 (diff)
redesign
Diffstat (limited to 'include')
-rw-r--r--include/README9
-rw-r--r--include/kpl.h39
-rw-r--r--include/kpl/code.h25
-rw-r--r--include/kpl/color.h119
-rw-r--r--include/kpl/io.h25
-rw-r--r--include/kpl/macro.h15
-rw-r--r--include/kpl/process.h39
-rw-r--r--include/kpl/queue.h53
-rw-r--r--include/kpl/system.h21
-rw-r--r--include/kpl/type.h53
-rw-r--r--include/kpl_test.h45
11 files changed, 0 insertions, 443 deletions
diff --git a/include/README b/include/README
deleted file mode 100644
index b182099..0000000
--- a/include/README
+++ /dev/null
@@ -1,9 +0,0 @@
-Headers
-
----
-
-Complier Flags:
-
-KPL_COLOR_OFF # Turn off colored pretty printing
-
----
diff --git a/include/kpl.h b/include/kpl.h
deleted file mode 100644
index 833c18b..0000000
--- a/include/kpl.h
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#pragma once
-
-#define KPL_VERSION "0.0.0"
-
-// All headers in one file for including
-
-#include "kpl/queue.h"
-#include "kpl/io.h"
-#include "kpl/process.h"
-#include "kpl/code.h"
-
-typedef enum : uint32_t {
- KPL_CONFIG_FLAG_EVAL = 1 << 0,
- KPL_CONFIG_FLAG_REPL = 1 << 1
-} kpl_config_flags;
-
-typedef struct {
- uint32_t flags;
- int32_t argc, main_module_arg_index;
- const char **argv, *module_extension, *version;
- kpl_config_io io;
- kpl_config_thread thread;
- kpl_config_code code;
-} kpl_config;
-
-void kpl_config_init(kpl_config *config);
-
-bool kpl_config_valid_module_exension(kpl_config *config, const char *module_name);
-
-int32_t kpl_config_parse_args(kpl_config *config, const int32_t argc, const char *argv[]);
-
-typedef struct _kpl_env {
- kpl_config config;
- _Atomic ssize_t total_priority;
- kpl_io io;
- kpl_process process;
- kpl_code code;
-} kpl_env;
diff --git a/include/kpl/code.h b/include/kpl/code.h
deleted file mode 100644
index 1902c42..0000000
--- a/include/kpl/code.h
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#pragma once
-
-// Queues and trees for code life cycle
-
-#include "kpl/queue.h"
-
-typedef enum : int8_t {
- KPL_CONFIG_CODE_QUEUE_POW2_MIN = 4,
- KPL_CONFIG_CODE_QUEUE_POW2_DEFAULT = 7,
- KPL_CONFIG_CODE_QUEUE_POW2_MAX = 10,
-} kpl_config_code_queue_pow;
-
-typedef struct {
- int8_t queue_pow2;
-} kpl_config_code;
-
-// TODO namespace tree
-
-// TODO module tree
-
-typedef struct {
- kpl_config_code *config_code;
- kpl_ring_queue code_queue;
-} kpl_code;
diff --git a/include/kpl/color.h b/include/kpl/color.h
deleted file mode 100644
index 1f77dcb..0000000
--- a/include/kpl/color.h
+++ /dev/null
@@ -1,119 +0,0 @@
-
-#pragma once
-
-// C string pretty printing macros
-
-#define KPL_COLOR_CONCAT(COLOR) KPL_COLOR_ ## COLOR
-
-#ifndef KPL_COLOR_OFF
-
-#define KPL_COLOR(A) "\e[" KPL_COLOR_CONCAT(A) "m"
-#define KPL_COLOR2(A, B) "\e[" KPL_COLOR_CONCAT(A) ";" KPL_COLOR_CONCAT(B) "m"
-#define KPL_COLOR3(A, B, C) "\e[" KPL_COLOR_CONCAT(A) ";" KPL_COLOR_CONCAT(B) ";" KPL_COLOR_CONCAT(C) "m"
-
-#define KPL_COLOR_RESET "0"
-#define KPL_COLOR_BOLD "1"
-#define KPL_COLOR_FAINT "2"
-#define KPL_COLOR_ITALIC "3"
-#define KPL_COLOR_UNDERLINE "4"
-#define KPL_COLOR_BLINK "5"
-#define KPL_COLOR_REVERSE "7"
-#define KPL_COLOR_HIDDEN "8"
-#define KPL_COLOR_RESET_BOLD "21"
-#define KPL_COLOR_RESET_FAINT "22"
-#define KPL_COLOR_RESET_ITALIC "23"
-#define KPL_COLOR_RESET_UNDERLINE "24"
-#define KPL_COLOR_RESET_BLINK "25"
-#define KPL_COLOR_RESET_REVERSE "27"
-#define KPL_COLOR_RESET_HIDDEN "28"
-#define KPL_COLOR_BLACK "30"
-#define KPL_COLOR_RED "31"
-#define KPL_COLOR_GREEN "32"
-#define KPL_COLOR_YELLOW "33"
-#define KPL_COLOR_BLUE "34"
-#define KPL_COLOR_MAGENTA "35"
-#define KPL_COLOR_CYAN "36"
-#define KPL_COLOR_GREY "37"
-#define KPL_COLOR_DEFAULT "39"
-#define KPL_COLOR_BG_BLACK "30"
-#define KPL_COLOR_BG_RED "41"
-#define KPL_COLOR_BG_GREEN "42"
-#define KPL_COLOR_BG_YELLOW "43"
-#define KPL_COLOR_BG_BLUE "44"
-#define KPL_COLOR_BG_MAGENTA "45"
-#define KPL_COLOR_BG_CYAN "46"
-#define KPL_COLOR_BG_GREY "47"
-#define KPL_COLOR_DARK_GREY "90"
-#define KPL_COLOR_LIGHT_RED "91"
-#define KPL_COLOR_LIGHT_GREEN "92"
-#define KPL_COLOR_LIGHT_YELLOW "93"
-#define KPL_COLOR_LIGHT_BLUE "94"
-#define KPL_COLOR_LIGHT_MAGENTA "95"
-#define KPL_COLOR_LIGHT_CYAN "96"
-#define KPL_COLOR_WHITE "97"
-#define KPL_COLOR_BG_DARK_GREY "100"
-#define KPL_COLOR_BG_LIGHT_RED "101"
-#define KPL_COLOR_BG_LIGHT_GREEN "102"
-#define KPL_COLOR_BG_LIGHT_YELLOW "103"
-#define KPL_COLOR_BG_LIGHT_BLUE "104"
-#define KPL_COLOR_BG_LIGHT_MAGENTA "105"
-#define KPL_COLOR_BG_LIGHT_CYAN "106"
-#define KPL_COLOR_BG_WHITE "107"
-
-#else
-
-#define KPL_COLOR(A) KPL_COLOR_CONCAT(A)
-#define KPL_COLOR2(A, B) KPL_COLOR_CONCAT(A) KPL_COLOR_CONCAT(B)
-#define KPL_COLOR3(A, B, C) KPL_COLOR_CONCAT(A) KPL_COLOR_CONCAT(B) KPL_COLOR_CONCAT(C)
-
-
-#define KPL_COLOR_RESET ""
-#define KPL_COLOR_BOLD ""
-#define KPL_COLOR_FAINT ""
-#define KPL_COLOR_ITALIC ""
-#define KPL_COLOR_UNDERLINE ""
-#define KPL_COLOR_BLINK ""
-#define KPL_COLOR_REVERSE ""
-#define KPL_COLOR_HIDDEN ""
-#define KPL_COLOR_RESET_BOLD ""
-#define KPL_COLOR_RESET_FAINT ""
-#define KPL_COLOR_RESET_ITALIC ""
-#define KPL_COLOR_RESET_UNDERLINE ""
-#define KPL_COLOR_RESET_BLINK ""
-#define KPL_COLOR_RESET_REVERSE ""
-#define KPL_COLOR_RESET_HIDDEN ""
-#define KPL_COLOR_BLACK ""
-#define KPL_COLOR_RED ""
-#define KPL_COLOR_GREEN ""
-#define KPL_COLOR_YELLOW ""
-#define KPL_COLOR_BLUE ""
-#define KPL_COLOR_MAGENTA ""
-#define KPL_COLOR_CYAN ""
-#define KPL_COLOR_GREY ""
-#define KPL_COLOR_DEFAULT ""
-#define KPL_COLOR_BG_BLACK ""
-#define KPL_COLOR_BG_RED ""
-#define KPL_COLOR_BG_GREEN ""
-#define KPL_COLOR_BG_YELLOW ""
-#define KPL_COLOR_BG_BLUE ""
-#define KPL_COLOR_BG_MAGENTA ""
-#define KPL_COLOR_BG_CYAN ""
-#define KPL_COLOR_BG_GREY ""
-#define KPL_COLOR_DARK_GREY ""
-#define KPL_COLOR_LIGHT_RED ""
-#define KPL_COLOR_LIGHT_GREEN ""
-#define KPL_COLOR_LIGHT_YELLOW ""
-#define KPL_COLOR_LIGHT_BLUE ""
-#define KPL_COLOR_LIGHT_MAGENTA ""
-#define KPL_COLOR_LIGHT_CYAN ""
-#define KPL_COLOR_WHITE ""
-#define KPL_COLOR_BG_DARK_GREY ""
-#define KPL_COLOR_BG_LIGHT_RED ""
-#define KPL_COLOR_BG_LIGHT_GREEN ""
-#define KPL_COLOR_BG_LIGHT_YELLOW ""
-#define KPL_COLOR_BG_LIGHT_BLUE ""
-#define KPL_COLOR_BG_LIGHT_MAGENTA ""
-#define KPL_COLOR_BG_LIGHT_CYAN ""
-#define KPL_COLOR_BG_WHITE ""
-
-#endif
diff --git a/include/kpl/io.h b/include/kpl/io.h
deleted file mode 100644
index a1b4b3f..0000000
--- a/include/kpl/io.h
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#pragma once
-
-// Io through io_uring
-
-#include "kpl/macro.h"
-
-typedef enum : int8_t {
- KPL_CONFIG_IO_QUEUE_POW2_MIN = 4,
- KPL_CONFIG_IO_QUEUE_POW2_DEFAULT = 10,
- KPL_CONFIG_IO_QUEUE_POW2_MAX = 16
-} kpl_io_queue_pow_options;
-
-typedef struct {
- int8_t queue_pow2;
-} kpl_config_io;
-
-typedef struct {
- kpl_config_io *config_io;
- // TODO
-} kpl_io;
-
-bool kpl_io_init(kpl_io *io);
-
-void kpl_io_free(kpl_io *io);
diff --git a/include/kpl/macro.h b/include/kpl/macro.h
deleted file mode 100644
index e0b59e5..0000000
--- a/include/kpl/macro.h
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#pragma once
-
-// KPL specific macros
-
-#include "color.h"
-#include "type.h"
-
-#define _KPL_PRINT_(MESSAGE_COLOR, MESSAGE) printf(KPL_COLOR2(BOLD, MESSAGE_COLOR) "TODO " KPL_COLOR(RESET) KPL_COLOR(BOLD) "%s" KPL_COLOR(RESET) ":" KPL_COLOR(LIGHT_BLUE) "%s" KPL_COLOR(RESET) ":" KPL_COLOR(LIGHT_MAGENTA) "%d" KPL_COLOR(RESET) "::" KPL_COLOR(MESSAGE_COLOR) "%s\n" KPL_COLOR(RESET), __FILE__, __FUNCTION__, __LINE__, MESSAGE)
-
-#define KPL_PRINT_TODO(MESSAGE) _KPL_PRINT_(LIGHT_YELLOW, MESSAGE)
-
-#define KPL_PRINT_ERROR(MESSAGE) _KPL_PRINT_(LIGHT_RED, MESSAGE)
-
-#define KPL_PAGE_SIZE_ROUND(SIZE) ((SIZE + (getpagesize() - 1)) & ~(getpagesize() - 1))
diff --git a/include/kpl/process.h b/include/kpl/process.h
deleted file mode 100644
index 528365a..0000000
--- a/include/kpl/process.h
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#pragma once
-
-// Kpl threads, allocators, atomic queues and garbage collection
-
-#include "kpl/queue.h"
-
-typedef enum : int8_t {
- KPL_CONFIG_THREAD_COUNT_AFFINITY = -1,
- KPL_CONFIG_THREAD_COUNT_MAX = 127
-} kpl_config_thread_count;
-
-typedef enum : uint8_t {
- KPL_CONFIG_THREAD_RING_POOL_COUNT = 28,
- KPL_CONFIG_THREAD_RING_POOL_MIN_OBJECT_SIZE_POW2 = 5,
- KPL_CONFIG_THREAD_RING_POOL_MAX_OBJECT_SIZE_POW2 = 27,
- KPL_CONFIG_THREAD_RING_POOL_MIN_RING_SIZE_POW2 = 6,
- KPL_CONFIG_THREAD_RING_POOL_MAX_RING_SIZE_POW2 = 20
-} kpl_config_thread_ring_pool;
-
-typedef struct {
- int8_t count, ring_pool_entries_pow2[KPL_CONFIG_THREAD_RING_POOL_COUNT];
-} kpl_config_thread;
-
-typedef struct {
- int32_t thread_id;
- _Atomic ssize_t priority;
- kpl_env *env;
- kpl_task_queue task_queue;
- // TODO
- sem_t sem;
- pthread_t pthread;
-} kpl_thread;
-
-typedef struct {
- kpl_config_thread *config_thread;
- kpl_thread *threads;
- kpl_ring_queue memory_pool[KPL_CONFIG_THREAD_RING_POOL_COUNT];
-} kpl_process;
diff --git a/include/kpl/queue.h b/include/kpl/queue.h
deleted file mode 100644
index 0107434..0000000
--- a/include/kpl/queue.h
+++ /dev/null
@@ -1,53 +0,0 @@
-
-#pragma once
-
-// KPL atomic queues
-
-#include "kpl/macro.h"
-
-typedef struct {
- kpl_task *_Atomic head, *tail;
- struct {
- kpl_task *_Atomic next;
- } dummy;
-} kpl_task_queue;
-
-inline void kpl_task_queue_init(kpl_task_queue *task_queue) {
- __atomic_store_n(&task_queue->dummy.next, NULL, __ATOMIC_RELAXED);
- __atomic_store_n(&task_queue->head, &task_queue->dummy, __ATOMIC_RELAXED);
- task_queue->tail = (kpl_task*) &task_queue->dummy;
-}
-
-inline void kpl_task_queue_add(kpl_task_queue *task_queue, kpl_task *task) {
- __atomic_store_n(&task->next, NULL, __ATOMIC_RELAXED);
- kpl_task *head = __atomic_exchange_n(&task_queue->head, task, __ATOMIC_SEQ_CST);
- __atomic_store_n(&head->next, task, __ATOMIC_RELEASE);
-}
-
-kpl_task *kpl_task_queue_next(kpl_task_queue *task_queue);
-
-typedef enum : int8_t {
- KPL_RING_QUEUE_MIN_POW2 = 4,
- KPL_RING_QUEUE_MAX_POW2 = 30
-} kpl_ring_queue_pow2_sizes;
-
-typedef struct {
- _Atomic ssize_t index;
- void *data;
-} kpl_ring_queue_item;
-
-typedef struct {
- size_t mmap_size, items_mask;
- _Atomic ssize_t head_index, tail_index;
- kpl_ring_queue_item *items;
-} kpl_ring_queue;
-
-bool kpl_ring_queue_init(kpl_ring_queue *ring_queue, int8_t size_pow2);
-
-inline void kpl_ring_queue_free(kpl_ring_queue *ring_queue) {
- munmap(ring_queue->items, ring_queue->mmap_size);
-}
-
-bool kpl_ring_queue_add(kpl_ring_queue *ring_queue, void *data);
-
-void *kpl_ring_queue_next(kpl_ring_queue *ring_queue);
diff --git a/include/kpl/system.h b/include/kpl/system.h
deleted file mode 100644
index 2d1ec48..0000000
--- a/include/kpl/system.h
+++ /dev/null
@@ -1,21 +0,0 @@
-
-#pragma once
-
-// System headers
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-#include <ctype.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/uio.h>
-#include <linux/fs.h>
-#include <linux/io_uring.h>
diff --git a/include/kpl/type.h b/include/kpl/type.h
deleted file mode 100644
index 5003cf0..0000000
--- a/include/kpl/type.h
+++ /dev/null
@@ -1,53 +0,0 @@
-
-#pragma once
-
-// KPL specific types
-
-#include "system.h"
-
-typedef enum : int32_t {
- KPL_EXIT_CODE_SUCCESS = 0,
- KPL_EXIT_CODE_ERROR = 1,
- KPL_EXIT_CODE_HELP = 2
-} kpl_exit_code;
-
-typedef uint8_t kpl_utf8[4];
-
-typedef union {
- uint8_t u8;
- int8_t i8;
- uint16_t u16;
- int16_t i16;
- uint32_t u32;
- int32_t i32;
- uint64_t u64;
- int64_t i64;
- kpl_utf8 utf8;
- float f32;
- double f64;
- void *ptr;
-} kpl_value;
-
-typedef struct {
- kpl_value value;
- int64_t tag;
-} kpl_result;
-
-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 {
- struct _kpl_task *_Atomic next, *join;
- kpl_task_fn *task_fn;
- int32_t io_res;
- uint32_t io_flags;
- int32_t thread_id;
- _Atomic bool canceled __attribute__((aligned(4))), join_ready __attribute__((aligned(8)));
- kpl_result result;
- // TODO TASK ARGUMENTS
-} kpl_task;
-
-
diff --git a/include/kpl_test.h b/include/kpl_test.h
deleted file mode 100644
index c1645e2..0000000
--- a/include/kpl_test.h
+++ /dev/null
@@ -1,45 +0,0 @@
-
-#pragma once
-
-// KPL testing framework
-
-#include "kpl.h"
-
-typedef struct _kpl_test kpl_test;
-
-typedef void kpl_test_function(__attribute__((unused)) kpl_test *_test);
-
-typedef struct _kpl_test {
- int32_t error_line_number; // -1 for no error
- char *file_name, *test_name, *error_message;
- kpl_test_function *test_function;
- struct _kpl_test *next_test;
-} kpl_test;
-
-void kpl_test_add(kpl_test *_test);
-
-#define _KPL_TEST_FN_NAME(NAME) _kpl_test_function_ ## NAME
-
-#define _KPL_TEST_FN(NAME) static void _KPL_TEST_FN_NAME(NAME)(__attribute__((unused)) kpl_test *_test)
-
-#define KPL_TEST(NAME) _KPL_TEST_FN(NAME); \
-static void __attribute__((constructor)) _kpl_test_constructor_ ## NAME(void) { \
- static kpl_test _test = { \
- .error_line_number = -1, \
- .file_name = __FILE__, .test_name = #NAME, .error_message = NULL, \
- .test_function = _KPL_TEST_FN_NAME(NAME), \
- .next_test = NULL \
- }; \
- kpl_test_add(&_test); \
-} \
-_KPL_TEST_FN(NAME)
-
-#define KPL_FAIL(MESSAGE) do { \
- _test->error_line_number = __LINE__; \
- _test->error_message = MESSAGE; \
-} while (0)
-
-#define KPL_ASSERT(CONDITION, MESSAGE) do { \
- if (!(CONDITION)) \
- KPL_FAIL(#CONDITION "; " MESSAGE); \
-} while (0)