diff options
Diffstat (limited to 'dev/LibC++')
| -rw-r--r-- | dev/LibC++/__abi+unreachable.cc | 16 | ||||
| -rw-r--r-- | dev/LibC++/__abi.h (renamed from dev/LibC++/lc_runtime.h) | 12 | ||||
| -rw-r--r-- | dev/LibC++/__power64.inc (renamed from dev/LibC++/power64.inc) | 6 | ||||
| -rw-r--r-- | dev/LibC++/base_exception.h | 29 | ||||
| -rw-r--r-- | dev/LibC++/base_process.h | 12 | ||||
| -rw-r--r-- | dev/LibC++/defines.h | 25 | ||||
| -rw-r--r-- | dev/LibC++/filesystem.h | 6 | ||||
| -rw-r--r-- | dev/LibC++/lc_runtime+unreachable.cc | 12 | ||||
| -rwxr-xr-x | dev/LibC++/make_stdcc.sh (renamed from dev/LibC++/make_cxx_headers.sh) | 0 |
9 files changed, 67 insertions, 51 deletions
diff --git a/dev/LibC++/__abi+unreachable.cc b/dev/LibC++/__abi+unreachable.cc new file mode 100644 index 0000000..fb1d336 --- /dev/null +++ b/dev/LibC++/__abi+unreachable.cc @@ -0,0 +1,16 @@ +/* ------------------------------------------- + + Copyright (C) 2025 Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#include <LibC++/__abi.h> +#include <LibC++/base_process.h> + +static const int32_t __unreachable_code = 34; + +extern "C" void __compilerkit_unreachable(void) { + std::base_process::signal(__unreachable_code); + + while (1); +}
\ No newline at end of file diff --git a/dev/LibC++/lc_runtime.h b/dev/LibC++/__abi.h index d3d331f..9e46689 100644 --- a/dev/LibC++/lc_runtime.h +++ b/dev/LibC++/__abi.h @@ -1,13 +1,9 @@ /* ------------------------------------------- - \ - Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. \ - \ -------------------------------------------- */ -#pragma once + Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. -#ifdef __LIBCOMPILER__ +------------------------------------------- */ -extern "C" void __libcompiler_unreachable(void); +#pragma once -#endif
\ No newline at end of file +extern "C" void __compilerkit_unreachable(void); diff --git a/dev/LibC++/power64.inc b/dev/LibC++/__power64.inc index 79dc923..c06863a 100644 --- a/dev/LibC++/power64.inc +++ b/dev/LibC++/__power64.inc @@ -1,8 +1,8 @@ -# Path: LibC++/power.inc -# Language: LibCompiler POWER Assembly support for GNU. +# Path: LibC++/__power64.inc +# Language: CompilerKit POWER Assembly support for GNU. # Build Date: 2024-6-4 -#ifdef __LIBCOMPILER__ +#ifdef __NECTI__ #ifdef __ASSEMBLER__ diff --git a/dev/LibC++/base_exception.h b/dev/LibC++/base_exception.h index 314ac12..29f996b 100644 --- a/dev/LibC++/base_exception.h +++ b/dev/LibC++/base_exception.h @@ -6,21 +6,32 @@ #pragma once +#include <LibC++/__abi.h> +#include <LibC++/base_process.h> #include <LibC++/defines.h> -#include <LibC++/process_base.h> +#include <iostream> -namespace std::base_exception { -inline void __throw_general(void) { - exit(33); +/// @author Amlal El Mahrouss (amlal@nekernel.org) + +namespace std::base_exception::abi { +inline constexpr int __terminate_id = 33; + +/// @note This function is internal, don't call it. +extern void __unwind_object_list(); + +inline void __throw_general(const char* what) { + std::cout << "LibC++: Unwinding exception of kind: " << what << ", aborting here..." << std::endl; + __unwind_object_list(); + base_process::exit(__terminate_id); } -inline void __throw_domain_error(const char* error) { - __throw_general(); +inline void __throw_domain_error(const char* what) { + __throw_general(what); __builtin_unreachable(); // prevent from continuing. } -inline void __throw_bad_array_new_length(void) { - __throw_general(); +inline void __throw_bad_array_new_length(const char* what) { + __throw_general(what); __builtin_unreachable(); // prevent from continuing. } -} // namespace std::base_exception +} // namespace std::base_exception::abi diff --git a/dev/LibC++/base_process.h b/dev/LibC++/base_process.h index 757e592..126ac60 100644 --- a/dev/LibC++/base_process.h +++ b/dev/LibC++/base_process.h @@ -6,15 +6,23 @@ #pragma once +#include <LibC++/defines.h> + /// @brief CRT exit, with exit code (!!! exits all threads. !!!) /// @param code the exit code. /// @return the return > 0 for non successful. -extern "C" int exit(int code); +extern "C" int exit_(int code); +extern "C" int signal_(int code); /// @brief Standard C++ namespace namespace std::base_process { +inline int signal(int code) { + signal_(code); + return -1; +} + inline int exit(int code) { - exit(code); + exit_(code); return -1; } } // namespace std::base_process diff --git a/dev/LibC++/defines.h b/dev/LibC++/defines.h index c0459ac..21c43e4 100644 --- a/dev/LibC++/defines.h +++ b/dev/LibC++/defines.h @@ -4,23 +4,20 @@ ------------------------------------------- */ -#ifndef __LIBCOMPILER_DEFINES_H__ -#define __LIBCOMPILER_DEFINES_H__ +#ifndef __NECTI_DEFINES_H__ +#define __NECTI_DEFINES_H__ extern "C" { #include <stddef.h> #include <stdint.h> } -#ifndef __GNUC__ +#define __ATTRIBUTE(X) __attribute__((X)) -typedef __SIZE_TYPE__ size_t; +#ifndef __GNUC__ -#ifdef __LP64__ -typedef long int ssize_t; -#else -typedef int ssize_t; -#endif // __LP64__ +typedef __SIZE_TYPE__ size_t; +typedef __SSIZE_TYPE__ ssize_t; typedef void* ptr_type; typedef __SIZE_TYPE__ size_type; @@ -37,7 +34,7 @@ typedef char* caddr_t; #ifdef __GNUC__ #include <LibC++/alloca.h> -#elif defined(__LIBCOMPILER__) +#elif defined(__NECTI__) #define __alloca(sz) __lc_alloca(sz) #endif @@ -60,7 +57,7 @@ typedef char* caddr_t; #endif #define __alloca alloca #else -#warning ! alloca not detected ! +#warning !! alloca not detected !! #endif typedef long long off_t; @@ -74,7 +71,7 @@ typedef union float_cast { }; float f; -} __attribute__((packed)) float_cast_t; +} __ATTRIBUTE(packed) float_cast_t; typedef union double_cast { struct { @@ -84,8 +81,8 @@ typedef union double_cast { }; double f; -} __attribute__((packed)) double_cast_t; +} __ATTRIBUTE(packed) double_cast_t; #endif // ifndef __GNUC__ -#endif /* __LIBCOMPILER_DEFINES_H__ */ +#endif /* __NECTI_DEFINES_H__ */ diff --git a/dev/LibC++/filesystem.h b/dev/LibC++/filesystem.h index 254bfab..1095da1 100644 --- a/dev/LibC++/filesystem.h +++ b/dev/LibC++/filesystem.h @@ -4,8 +4,8 @@ ------------------------------------------- */ -#ifndef __LIBCOMPILER_FS_H__ -#define __LIBCOMPILER_FS_H__ +#ifndef __NECTI_FS_H__ +#define __NECTI_FS_H__ namespace std { class path; @@ -14,4 +14,4 @@ class directory_entry; class directory_iterator; } // namespace std -#endif // __LIBCOMPILER_FS_H__
\ No newline at end of file +#endif // __NECTI_FS_H__
\ No newline at end of file diff --git a/dev/LibC++/lc_runtime+unreachable.cc b/dev/LibC++/lc_runtime+unreachable.cc deleted file mode 100644 index 39115a1..0000000 --- a/dev/LibC++/lc_runtime+unreachable.cc +++ /dev/null @@ -1,12 +0,0 @@ -/* ------------------------------------------- - \ - Copyright (C) 2025 Amlal El Mahrouss, all rights reserved. \ - \ -------------------------------------------- */ - -#include <LibC++/lc_runtime.h> - -extern "C" void __libcompiler_unreachable(void) { - while (true) - ; -}
\ No newline at end of file diff --git a/dev/LibC++/make_cxx_headers.sh b/dev/LibC++/make_stdcc.sh index 7e23e2c..7e23e2c 100755 --- a/dev/LibC++/make_cxx_headers.sh +++ b/dev/LibC++/make_stdcc.sh |
