diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:05:29 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:05:29 +0100 |
| commit | bbe2c77243c541ca7e0075149f5be3262eb89523 (patch) | |
| tree | ae5d59d299344fd19584a2c3642bacd788e841d4 /dev/LibC++ | |
| parent | b5adf16a96b9cbb80c74cf30404ed5bcff03ac34 (diff) | |
feat! breaking changes on necti sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibC++')
| -rw-r--r-- | dev/LibC++/.gitignore | 1 | ||||
| -rw-r--r-- | dev/LibC++/__abi+unreachable.cc | 17 | ||||
| -rw-r--r-- | dev/LibC++/__abi.h | 15 | ||||
| -rw-r--r-- | dev/LibC++/__power64.inc | 39 | ||||
| -rw-r--r-- | dev/LibC++/base_alloc.h | 43 | ||||
| -rw-r--r-- | dev/LibC++/base_exception.h | 37 | ||||
| -rw-r--r-- | dev/LibC++/base_math.h | 88 | ||||
| -rw-r--r-- | dev/LibC++/base_process.h | 45 | ||||
| -rw-r--r-- | dev/LibC++/defines.h | 76 | ||||
| -rw-r--r-- | dev/LibC++/filesystem.h | 21 | ||||
| -rwxr-xr-x | dev/LibC++/make_hdrs.sh | 13 | ||||
| -rw-r--r-- | dev/LibC++/new.cc | 7 | ||||
| -rw-r--r-- | dev/LibC++/new.h | 44 | ||||
| -rw-r--r-- | dev/LibC++/utility.h | 30 |
14 files changed, 0 insertions, 476 deletions
diff --git a/dev/LibC++/.gitignore b/dev/LibC++/.gitignore deleted file mode 100644 index 5fa1170..0000000 --- a/dev/LibC++/.gitignore +++ /dev/null @@ -1 +0,0 @@ -stdcxx/ diff --git a/dev/LibC++/__abi+unreachable.cc b/dev/LibC++/__abi+unreachable.cc deleted file mode 100644 index 1fc9830..0000000 --- a/dev/LibC++/__abi+unreachable.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* ======================================== - - Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#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++/__abi.h b/dev/LibC++/__abi.h deleted file mode 100644 index 70afae5..0000000 --- a/dev/LibC++/__abi.h +++ /dev/null @@ -1,15 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <LibC++/defines.h> - -__init_decl() - -extern void __compilerkit_unreachable(void); - -__fini_decl()
\ No newline at end of file diff --git a/dev/LibC++/__power64.inc b/dev/LibC++/__power64.inc deleted file mode 100644 index c06863a..0000000 --- a/dev/LibC++/__power64.inc +++ /dev/null @@ -1,39 +0,0 @@ -# Path: LibC++/__power64.inc -# Language: CompilerKit POWER Assembly support for GNU. -# Build Date: 2024-6-4 - -#ifdef __NECTI__ - -#ifdef __ASSEMBLER__ - -#define lda li -#define sta stw -#define ldw li - -#define r0 0 -#define r1 1 -#define r2 2 -#define r3 3 -#define r4 4 -#define r5 5 -#define r6 6 -#define r7 7 -#define r8 8 -#define r9 9 -#define r10 10 -#define r11 11 -#define r12 12 -#define r13 13 -#define r14 14 -#define r15 15 -#define r16 16 -#define r17 17 -#define r18 18 -#define r19 19 -#define r20 20 - -#define nop mr 0, 0 - -#endif - -#endif diff --git a/dev/LibC++/base_alloc.h b/dev/LibC++/base_alloc.h deleted file mode 100644 index ea5b5b2..0000000 --- a/dev/LibC++/base_alloc.h +++ /dev/null @@ -1,43 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <LibC++/defines.h> - -namespace std::base_alloc { -/// @brief allocate a new class. -/// @tparam KindClass the class type to allocate. -template <typename KindClass, typename... Args> -inline KindClass* allocate(Args&&... args) { - return new KindClass(forward(args)...); -} - -/// @brief allocate a new class. -/// @note aborts on error. -/// @tparam KindClass the class type to allocate. -template <typename KindClass, typename... Args> -inline KindClass* allocate_nothrow(Args&&... args) noexcept { - return allocate(forward(args)...); -} - -/// @brief free a class. -/// @tparam KindClass the class type to allocate. -template <typename KindClass> -inline void release(KindClass ptr) { - if (!ptr) return; - - delete ptr; -} - -/// @brief destroy and free a class. -/// @note aborts on error. -/// @tparam KindClass the class type to allocate. -template <typename KindClass> -inline void release_nothrow(KindClass ptr) noexcept { - release(ptr); -} -} // namespace std::base_alloc diff --git a/dev/LibC++/base_exception.h b/dev/LibC++/base_exception.h deleted file mode 100644 index 8747688..0000000 --- a/dev/LibC++/base_exception.h +++ /dev/null @@ -1,37 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <LibC++/__abi.h> -#include <LibC++/base_process.h> -#include <LibC++/defines.h> -#include <iostream> - -/// @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* what) { - __throw_general(what); - __builtin_unreachable(); // prevent from continuing. -} - -inline void __throw_bad_array_new_length(const char* what) { - __throw_general(what); - __builtin_unreachable(); // prevent from continuing. -} -} // namespace std::base_exception::abi diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h deleted file mode 100644 index 60b260e..0000000 --- a/dev/LibC++/base_math.h +++ /dev/null @@ -1,88 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <LibC++/defines.h> - -#ifndef NAN -#define NAN (__builtin_nanf("")) -#endif // !NAN - -/// @file Math.h -/// @brief Math functions. - -#ifdef __LIBCXX_USE_DOUBLE__ -typedef double real_type; -#else -typedef float real_type; -#endif - -namespace std::base_math { -inline constexpr static auto not_a_number = NAN; - -/// =========================================================== /// -/// @brief Power function, with Repeat argument. -/// =========================================================== /// -template <size_t Exponent> -inline real_type pow(real_type in) { - if (Exponent == 0) return 1; // Any number to the power of 0 is 1. - - if (Exponent == 1) return in; // Any number to the power of 1 is itself. - - size_t cnt = Exponent; - - real_type result = 1; - - for (auto i = 0; i < cnt; ++i) result *= in; - - return result; -} - -/// =========================================================== /// -/// @brief Square root function. -/// =========================================================== /// -inline real_type sqrt(real_type in) { - if (in == 0) return 0; - if (in == not_a_number) return not_a_number; - - auto constexpr const static Base = 2; - - auto x = in / Base; - - for (int i = 0; i < 10; ++i) { - x = (x + in / x) / Base; - } - - return x; -} - -/// =========================================================== /// -/// @brief Square of function, with Base template argument. -/// @param of Base argument to find the square of. -/// =========================================================== /// -template <size_t Base> -inline real_type surd(real_type in) { - if (in == 0) return 0; - if (in == 1) return 1; - - if (Base == 1) return in; - if (Base == 2) return sqrt(in); - - return not_a_number; -} - -/// =========================================================== /// -/// @brief Linear interpolation equation solver. -/// @param from where? -/// @param to to? -/// @param Updated diff value according to difference. -/// =========================================================== /// -inline real_type lerp(real_type to, real_type from, real_type stat) { - real_type diff = (to - from); - return from + (diff * stat); -} -} // namespace std::base_math diff --git a/dev/LibC++/base_process.h b/dev/LibC++/base_process.h deleted file mode 100644 index f9b0596..0000000 --- a/dev/LibC++/base_process.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <LibC++/defines.h> - -__init_decl() - -/// @brief CRT exit, with exit code (!!! exits all threads. !!!) -/// @param code the exit code. -/// @return the return > 0 for non successful. -extern int exit_(int code); - -/// @brief CRT signal handler. -/// @param code the signal code. -extern void signal_(int code); - -extern void (*__atexit_cdecl_ptr)(void); -extern void (**__atexit_lst_ptr)(void); -extern size_t __atexit_lst_cnt; - -__fini_decl() - -/// @brief Standard C++ namespace -namespace std::base_process { -inline int signal(int code) { - signal_(code); - return -1; -} - -inline int32_t exit(const int32_t& code) { - for (auto idx = 0UL; idx < __atexit_lst_cnt; ++idx) { - __atexit_lst_ptr[idx](); - } - - if (__atexit_cdecl_ptr) __atexit_cdecl_ptr(); - - exit_(code); - return -1; -} -} // namespace std::base_process diff --git a/dev/LibC++/defines.h b/dev/LibC++/defines.h deleted file mode 100644 index b8ef10c..0000000 --- a/dev/LibC++/defines.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#ifndef __NECTI_DEFINES_H__ -#define __NECTI_DEFINES_H__ - -#define __ATTRIBUTE(X) __attribute__((X)) - -typedef __SIZE_TYPE__ size_t; -typedef __INT64_TYPE__ ssize_t; -typedef __INT32_TYPE__ int32_t; - -typedef void* ptr_type; -typedef __SIZE_TYPE__ size_type; - -typedef __INT64_TYPE__ 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 - -#define __alloca(sz) __ck_alloca(sz) - -#define __deref(ptr) (*(ptr)) - -#ifdef __cplusplus -#define __init_decl() extern "C" { -#define __fini_decl() \ - } \ - ; -#else -#define __init_decl() -#define __fini_decl() -#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 float_cast { - struct { - unsigned int mantissa : 23; - unsigned int exponent : 8; - unsigned int sign : 1; - }; - - float f; -} __ATTRIBUTE(packed) float_cast_t; - -typedef union double_cast { - struct { - unsigned long long int mantissa : 52; - unsigned int exponent : 11; - unsigned int sign : 1; - }; - - double f; -} __ATTRIBUTE(packed) double_cast_t; - -#endif /* __NECTI_DEFINES_H__ */ diff --git a/dev/LibC++/filesystem.h b/dev/LibC++/filesystem.h deleted file mode 100644 index 807ab0d..0000000 --- a/dev/LibC++/filesystem.h +++ /dev/null @@ -1,21 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#ifndef __NECTI_FS_H__ -#define __NECTI_FS_H__ - -#include <LibC++/defines.h> - -/// @brief Filesystem module for LibC++ - -namespace std { -class path; -class filesystem_error; -class directory_entry; -class directory_iterator; -} // namespace std - -#endif // __NECTI_FS_H__
\ No newline at end of file diff --git a/dev/LibC++/make_hdrs.sh b/dev/LibC++/make_hdrs.sh deleted file mode 100755 index 5e8907e..0000000 --- a/dev/LibC++/make_hdrs.sh +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh - -outputDir=libCxx/ - -mkdir -p $outputDir - -for f in *.h; do - -#This line splits the file name on the delimiter "." -baseName=`echo $f | cut -d "." -f 1` -cp $f $outputDir$baseName - -done diff --git a/dev/LibC++/new.cc b/dev/LibC++/new.cc deleted file mode 100644 index 85ae82e..0000000 --- a/dev/LibC++/new.cc +++ /dev/null @@ -1,7 +0,0 @@ -/* ======================================== - - Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -#include <LibC++/new.h> diff --git a/dev/LibC++/new.h b/dev/LibC++/new.h deleted file mode 100644 index 37e2a26..0000000 --- a/dev/LibC++/new.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ======================================== - - Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <LibC++/defines.h> - -namespace std { -struct placement_new; - -/// ========================================================= -/// @brief Disambugate non-throwing allocation functions. -/// ========================================================= -struct nothrow_t { - explicit nothrow_t() = default; -}; - -/// ========================================================= -/// @brief Placement new metadata. -/// ========================================================= -struct placement_new final { - void* __base{}; - int32_t __align{}; - size_t __size{}; -}; - -using placement_new_t = placement_new; -} // namespace std - -void* operator new(size_t); -void* operator new[](size_t); - -void* operator new(size_t, const std::nothrow_t&) noexcept; -void* operator new(size_t, void*) noexcept; -void* operator new[](size_t, const std::nothrow_t&) noexcept; -void* operator new[](size_t, void*) noexcept; - -void operator delete(void*) noexcept; -void operator delete(void*, size_t) noexcept; - -void operator delete[](void*) noexcept; diff --git a/dev/LibC++/utility.h b/dev/LibC++/utility.h deleted file mode 100644 index 62096f5..0000000 --- a/dev/LibC++/utility.h +++ /dev/null @@ -1,30 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license. - -======================================== */ - -#ifndef LIBCXX_UTILITY_H -#define LIBCXX_UTILITY_H - -namespace std { -/// @brief Forward object. -/// @tparam Args the object type. -/// @param arg the object. -/// @return object's rvalue -template <typename Args> -inline auto forward(Args& arg) -> Args&& { - return static_cast<const Args&&>(arg); -} - -/// @brief Move object. -/// @tparam Args the object type. -/// @param arg the object. -/// @return object's rvalue -template <typename Args> -inline auto move(Args&& arg) -> Args&& { - return static_cast<Args&&>(arg); -} -} // namespace std - -#endif // LIBCXX_UTILITY_H |
