initial implementation of klibc

fix linker error about ctx_switch
This commit is contained in:
Borna Šoštarić
2025-12-27 11:19:42 +01:00
parent d83e247bbd
commit f30be3ddd5
15 changed files with 198 additions and 135 deletions

14
klibc/include/stdarg.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef CLASSICOS_KLIBC_STDARG_H
#define CLASSICOS_KLIBC_STDARG_H
typedef __builtin_va_list va_list;
#ifndef va_start
#define va_start(ap, param) __builtin_va_start(ap, param)
#endif
#define va_end(ap) __builtin_va_end(ap)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define va_copy(dest, src) __builtin_va_copy(dest, src)
#endif // CLASSICOS_KLIBC_STDARG_H

6
klibc/include/stdbool.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef CLASSICOS_KLIBC_STDBOOL_H
#define CLASSICOS_KLIBC_STDBOOL_H
typedef enum { false = 0, true = 1 } bool;
#endif // CLASSICOS_KLIBC_STDBOOL_H

10
klibc/include/stddef.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef CLASSICOS_KLIBC_STDDEF_H
#define CLASSICOS_KLIBC_STDDEF_H
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#undef NULL
#define NULL ((void*)0)
#endif // CLASSICOS_KLIBC_STDDEF_H

16
klibc/include/stdint.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef CLASSICOS_KLIBC_STDINT_H
#define CLASSICOS_KLIBC_STDINT_H
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef long long int int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef unsigned int uintptr_t;
#endif // CLASSICOS_KLIBC_STDINT_H

4
klibc/include/stdio.h Normal file
View File

@@ -0,0 +1,4 @@
#ifndef CLASSICOS_KLIBC_STDIO_H
#define CLASSICOS_KLIBC_STDIO_H
#endif // CLASSICOS_KLIBC_STDIO_H

4
klibc/include/stdlib.h Normal file
View File

@@ -0,0 +1,4 @@
#ifndef CLASSICOS_KLIBC_STDLIB_H
#define CLASSICOS_KLIBC_STDLIB_H
#endif // CLASSICOS_KLIBC_STDLIB_H

14
klibc/include/string.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef CLASSICOS_KLIBC_STRING_H
#define CLASSICOS_KLIBC_STRING_H
#include <stddef.h>
extern int memcmp(const void* s1, const void* s2, size_t n);
extern void* memmove(void* dst, const void* src, size_t n);
extern void* memcpy(void* dst, const void* src, size_t n);
extern void* memset(void* dst, int c, size_t n);
extern size_t strlen(const char* s);
extern int strcmp(const char* s1, const char* s2);
#endif // CLASSICOS_KLIBC_STRING_H