implemented ErrorCodePage

This commit is contained in:
2025-11-10 11:42:25 +05:00
parent 6a1067a612
commit 972f244ae5
5 changed files with 82 additions and 5 deletions

View File

@@ -3,10 +3,14 @@
#define ERRMSG_LENGTH 1024
Error* Error_create(const char* msg, bool is_msg_on_heap, ErrorCallPos p){
Error* Error_create(const char* msg, bool is_msg_on_heap, ErrorCallPos p,
u16 error_code_page, u32 error_code)
{
Error* e = (Error*)malloc(sizeof(Error));
e->msg = str_construct((char*)(void*)msg, strlen(msg), true);
e->is_msg_on_heap = is_msg_on_heap;
e->error_code_page = error_code_page;
e->error_code = error_code;
e->call_stack = List_alloc(ErrorCallPos, 16);
Error_addCallPos(e, p);
return e;
@@ -51,3 +55,12 @@ void Error_printAndExit(Error* e){
Error_free(e);
exit(111);
}
ErrorCodePage_define(TLIBC_ERROR);
ErrorCodePage_define(LIBC_ERRNO);
static u16 _error_code_page_last = 0;
void _ErrorCodePage_register(u16* error_code_page_ptr){
*error_code_page_ptr = ++_error_code_page_last;
}

14
src/tlibc.c Normal file
View File

@@ -0,0 +1,14 @@
#include "tlibc/tlibc.h"
Result(void) tlibc_init(){
Deferral(8);
ErrorCodePage_register(TLIBC_ERROR);
ErrorCodePage_register(LIBC_ERRNO);
Return RESULT_VOID;
}
void tlibc_deinit(){
}