diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-26 22:26:48 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-26 22:27:09 +0100 |
| commit | eba8b7ddd0a455d9e49f32dcae712c5612c0093c (patch) | |
| tree | 749a3d34546d055507a920bce4ab10e8a9945719 /Private/CRT | |
| parent | dd192787a70a973f2474720aea49af3f6ddabb7a (diff) | |
Kernel: Major repository refactor.
Rework the repo into Private and Public modules.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/CRT')
| -rw-r--r-- | Private/CRT/__cxxkit_alloca.h | 15 | ||||
| -rw-r--r-- | Private/CRT/__cxxkit_cookie.asm | 23 | ||||
| -rw-r--r-- | Private/CRT/__cxxkit_defines.h | 89 |
3 files changed, 127 insertions, 0 deletions
diff --git a/Private/CRT/__cxxkit_alloca.h b/Private/CRT/__cxxkit_alloca.h new file mode 100644 index 00000000..283ce791 --- /dev/null +++ b/Private/CRT/__cxxkit_alloca.h @@ -0,0 +1,15 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +typedef void* ptr_type; +typedef __SIZE_TYPE__ size_type; + +inline void* __cxxkit_alloca_gcc(size_type sz) { return __builtin_alloca(sz); } diff --git a/Private/CRT/__cxxkit_cookie.asm b/Private/CRT/__cxxkit_cookie.asm new file mode 100644 index 00000000..9e2292fa --- /dev/null +++ b/Private/CRT/__cxxkit_cookie.asm @@ -0,0 +1,23 @@ +[bits 64] +[global runtime_cookie_check] + +%define LIBALLOC_COOKIE 0x77ccdd + +runtime_cookie_check: + ret + +runtime_cookie_install: + push LIBALLOC_COOKIE ;; the cookie + jmp rdi + cmp rsp, LIBALLOC_COOKIE + jne _runtime_cookie_fail + ret + +_runtime_cookie_fail: + mov rsi, 1 + mov rdi, 33 + syscall + +;; we shouldn't get here if the host has exit (rsi = 1) implemented. +L0: + jmp $
\ No newline at end of file diff --git a/Private/CRT/__cxxkit_defines.h b/Private/CRT/__cxxkit_defines.h new file mode 100644 index 00000000..46110369 --- /dev/null +++ b/Private/CRT/__cxxkit_defines.h @@ -0,0 +1,89 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#ifndef __CXKIT_DEF_H +#define __CXKIT_DEF_H + +typedef __SIZE_TYPE__ size_t; + +#ifdef __LP64__ +typedef long int ssize_t; +#else +typedef int ssize_t; +#endif // __LP64__ + +typedef size_t ptrdiff_t; +typedef size_t uintptr_t; +typedef void* voidptr_t; +typedef void* any_t; +typedef char* caddr_t; + +#ifndef NULL +#define NULL ((voidptr_t)0) +#endif // !null + +#ifdef __GNUC__ +# include <CRT/__cxxkit_alloca.h> +# define __cxxkit_alloca(sz) __cxxkit_alloca_gcc(sz) +#elif defined(__HISYS__) + +# define __alloca(SZ) __cxxkit_alloca(SZ) + +# define __deref(ptr) (*(PTR)) + +# define __libexport __lib(export) +# define __libimport __lib(import) + +#ifdef __cplusplus +# define __init_decl() extern "C" { +# define __fini_decl() }; +#else +# define __init_decl() +# define __fini_decl() +#endif +#endif + +#if __has_builtin(__builtin_alloca) +# define alloca(sz) __builtin_alloca(sz) +#ifdef __alloca +# undef __alloca +#endif +#define __alloca alloca +#else +# warning alloca not detected +#endif + +typedef long long off_t; +typedef unsigned long long uoff_t; + +typedef union +{ + struct + { + unsigned int mantisa : 23; + unsigned int exponent : 8; + unsigned int sign : 1; + }; + + float f; +} __attribute__((packed)) float_cast_t; + +typedef union +{ + struct + { + unsigned long int mantisa : 52; + unsigned int exponent : 11; + unsigned int sign : 1; + }; + + double f; +} __attribute__((packed)) double_cast_t; + +#endif /* __CXKIT_DEF_H */ |
