summaryrefslogtreecommitdiffhomepage
path: root/include/LibC++
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-01-09 02:31:16 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-01-09 02:31:16 +0100
commit365e1851ab1b2f2e7eca2fb0697e5b7ff1023b60 (patch)
tree4f82da02b080a6de9ba0756bf1f21c319569831f /include/LibC++
parent3550c29636d9a46f40d02908605144221bb7eb9b (diff)
chore: Nectar grunt work on runtime library and test code.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/LibC++')
-rw-r--r--include/LibC++/.gitignore1
-rw-r--r--include/LibC++/__abi.h24
-rw-r--r--include/LibC++/__power64.inc40
-rw-r--r--include/LibC++/base_alloc.h45
-rw-r--r--include/LibC++/base_exception.h39
-rw-r--r--include/LibC++/base_math.h100
-rw-r--r--include/LibC++/base_process.h47
-rw-r--r--include/LibC++/defines.h80
-rw-r--r--include/LibC++/filesystem.h23
-rwxr-xr-xinclude/LibC++/make-stdcpp-hdrs.sh14
-rw-r--r--include/LibC++/new.h67
-rw-r--r--include/LibC++/utility.h29
12 files changed, 0 insertions, 509 deletions
diff --git a/include/LibC++/.gitignore b/include/LibC++/.gitignore
deleted file mode 100644
index e3f10ea..0000000
--- a/include/LibC++/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-libc++/
diff --git a/include/LibC++/__abi.h b/include/LibC++/__abi.h
deleted file mode 100644
index 86e5cda..0000000
--- a/include/LibC++/__abi.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef NECTAR_LIBCXX_ABI_H
-#define NECTAR_LIBCXX_ABI_H
-
-#include <LibC++/base_process.h>
-#include <LibC++/defines.h>
-
-__init_decl()
-
- static constexpr int32_t __unreachable_code = 34;
-
-inline void __compilerkit_unreachable(void) {
- std::base_process::signal(__unreachable_code);
-
- while (1);
-}
-
-__fini_decl()
-
-#endif // NECTAR_LIBCXX_ABI_H
diff --git a/include/LibC++/__power64.inc b/include/LibC++/__power64.inc
deleted file mode 100644
index 8b65ad7..0000000
--- a/include/LibC++/__power64.inc
+++ /dev/null
@@ -1,40 +0,0 @@
-# Path: LibC++/__power64.inc
-# Language: CompilerKit POWER Assembly support for GNU.
-# Build Date: 2024-6-4
-
-#ifdef __NECTAR__
-
-#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/include/LibC++/base_alloc.h b/include/LibC++/base_alloc.h
deleted file mode 100644
index 6c7ad06..0000000
--- a/include/LibC++/base_alloc.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef NECTAR_LIBCXX_BASE_ALLOC_H
-#define NECTAR_LIBCXX_BASE_ALLOC_H
-
-#include <LibC++/defines.h>
-
-namespace std::base_alloc {
-/// @brief allocate a new class.
-/// @tparam KindClass the class type to allocate.
-template <class 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 <class 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 <class 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 <class KindClass>
-inline void release_nothrow(KindClass ptr) noexcept {
- release(ptr);
-}
-} // namespace std::base_alloc
-
-#endif // NECTAR_LIBCXX_BASE_ALLOC_H
diff --git a/include/LibC++/base_exception.h b/include/LibC++/base_exception.h
deleted file mode 100644
index ddddda9..0000000
--- a/include/LibC++/base_exception.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef NECTAR_LIBCXX_BASE_EXCEPTION_H
-#define NECTAR_LIBCXX_BASE_EXCEPTION_H
-
-#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
-
-#endif // NECTAR_LIBCXX_BASE_EXCEPTION_H
diff --git a/include/LibC++/base_math.h b/include/LibC++/base_math.h
deleted file mode 100644
index e4370eb..0000000
--- a/include/LibC++/base_math.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef NECTAR_LIBCXX_BASE_MATH_H
-#define NECTAR_LIBCXX_BASE_MATH_H
-
-#include <defines>
-
-#ifndef NAN
-#define NAN (__builtin_nanf(""))
-#endif // !NAN
-
-/// @file base_math.h
-/// @brief Base Mathematic 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 of Exponent function.
-/// =========================================================== ///
-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.
-
- real_type result = 1;
-
- for (auto i = 0UL; i < Exponent; ++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);
-}
-
-using real_domain = double;
-
-struct complex_domain final {
- double Re;
- double Im;
-};
-
-typename<class Result> using callable_type = Result (*)(size_t n, ...);
-} // namespace std::base_math
-
-#ifdef __cpp_lib_base_math
-#define __cpp_lib_base_math 1
-#endif
-
-#endif // NECTAR_LIBCXX_BASE_MATH_H
diff --git a/include/LibC++/base_process.h b/include/LibC++/base_process.h
deleted file mode 100644
index ccda74c..0000000
--- a/include/LibC++/base_process.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef NECTAR_LIBCXX_BASE_PROCESS_H
-#define NECTAR_LIBCXX_BASE_PROCESS_H
-
-#include <defines>
-
-__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
-
-#endif // NECTAR_LIBCXX_BASE_PROCESS_H
diff --git a/include/LibC++/defines.h b/include/LibC++/defines.h
deleted file mode 100644
index 061769c..0000000
--- a/include/LibC++/defines.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef __NECTAR_DEFINES_H__
-#define __NECTAR_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;
-
-namespace std {
-struct placement_t;
-struct nothrow_t;
-} // namespace std
-
-#endif /* __NECTAR_DEFINES_H__ */
diff --git a/include/LibC++/filesystem.h b/include/LibC++/filesystem.h
deleted file mode 100644
index 9667a78..0000000
--- a/include/LibC++/filesystem.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef __NECTAR_FS_H__
-#define __NECTAR_FS_H__
-
-#include <chrono>
-#include <defines>
-
-namespace std {
-class path;
-class filesystem_error;
-class directory_entry;
-class directory_iterator;
-} // namespace std
-
-#ifndef __cpp_lib_filesystem
-#define __cpp_lib_filesystem 201703L
-#endif
-
-#endif // __NECTAR_FS_H__
diff --git a/include/LibC++/make-stdcpp-hdrs.sh b/include/LibC++/make-stdcpp-hdrs.sh
deleted file mode 100755
index 09d5616..0000000
--- a/include/LibC++/make-stdcpp-hdrs.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /bin/sh
-
-outputDir=libc++/nectar/
-
-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/include/LibC++/new.h b/include/LibC++/new.h
deleted file mode 100644
index f7e3abb..0000000
--- a/include/LibC++/new.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#ifndef NECTAR_LIBCXX_NEW_H
-#define NECTAR_LIBCXX_NEW_H
-
-#include <defines>
-
-namespace std {
-struct nothrow_t final {
- explicit nothrow_t() = default;
- ~nothrow_t() = default;
-};
-
-struct placement_t final {
- explicit placement_t() = default;
- ~placement_t() = default;
-
- void* __base{};
- int32_t __align{};
- size_t __size{};
-};
-} // namespace std
-
-// AMLALE: Define the placement_t feature.
-#ifndef __cpp_has_placement
-#define __cpp_has_placement 1
-#endif
-
-// AMLALE: Define nothrow
-#ifndef __cpp_has_nothrow
-#define __cpp_has_nothrow 1
-#endif
-
-void* operator new(size_t);
-void* operator new[](size_t);
-
-/// \brief placement_t new and delete operators. Governs how the memory shall be placed.
-/// \note This is a feature that shall be used wisely, failure to do so will produce Undefined
-/// Behaviors at runtime.
-void* operator _placement_new(struct placement_t*);
-void operator _placement_delete(struct placement_t*, void*);
-
-/// \brief For all offsets within the base range and alignement 'align'
-/// \brief Allocate offsets with respect to the `base` interval, apply alignement of `align` value.
-/// Return `offsets` of length n as an aligned value within the domain of `base`.
-using placeable_callable_type = void* /*offsets*/ (*) (void* base, size_t n, const int& align);
-
-/// \note This should NOT fail, failure to meet the conditions will cause the program's state to be
-/// aborted.
-/// \brief Set the placement policy of future memory allocations.
-template <class PlaceableCallable>
-void set_placement_policy(const PlaceableCallable&) noexcept;
-
-void* operator new(size_t, const nothrow_t&) noexcept;
-void* operator new(size_t, void*) noexcept;
-void* operator new[](size_t, const 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;
-
-#endif // NECTAR_LIBCXX_NEW_H
diff --git a/include/LibC++/utility.h b/include/LibC++/utility.h
deleted file mode 100644
index 45000c3..0000000
--- a/include/LibC++/utility.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-#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