From 693aba77f3e31b0ddfe4d3e51f47fd3441c45f92 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 18 Mar 2026 22:05:37 +0100 Subject: [CHORE] Rework the Nectar Core Libraries as NCSL (Nectar Core Support Libraries). Signed-off-by: Amlal El Mahrouss --- include/CoreRuntimeKit/C++/__abi | 21 ------ include/CoreRuntimeKit/C++/abi/abi.hpp | 20 +++++ include/CoreRuntimeKit/C++/abi/new.hpp | 57 ++++++++++++++ include/CoreRuntimeKit/C++/base_alloc | 42 ----------- include/CoreRuntimeKit/C++/base_exception | 36 --------- include/CoreRuntimeKit/C++/base_math | 88 ---------------------- include/CoreRuntimeKit/C++/base_process | 44 ----------- include/CoreRuntimeKit/C++/core/base_alloc.hpp | 42 +++++++++++ include/CoreRuntimeKit/C++/core/base_exception.hpp | 36 +++++++++ include/CoreRuntimeKit/C++/core/base_math.hpp | 88 ++++++++++++++++++++++ include/CoreRuntimeKit/C++/core/base_process.hpp | 44 +++++++++++ include/CoreRuntimeKit/C++/defines | 80 -------------------- include/CoreRuntimeKit/C++/defines.hpp | 80 ++++++++++++++++++++ include/CoreRuntimeKit/C++/filesystem | 18 ----- .../CoreRuntimeKit/C++/filesystem/filesystem.hpp | 18 +++++ include/CoreRuntimeKit/C++/new | 57 -------------- include/CoreRuntimeKit/C++/utility | 29 ------- include/CoreRuntimeKit/C++/utility.hpp | 29 +++++++ include/CoreRuntimeKit/Nectar/exports.hpp | 7 ++ include/CoreRuntimeKit/Nectar/ncl_exports.h | 7 -- include/CoreRuntimeKit/README.md | 8 +- 21 files changed, 427 insertions(+), 424 deletions(-) delete mode 100644 include/CoreRuntimeKit/C++/__abi create mode 100644 include/CoreRuntimeKit/C++/abi/abi.hpp create mode 100644 include/CoreRuntimeKit/C++/abi/new.hpp delete mode 100644 include/CoreRuntimeKit/C++/base_alloc delete mode 100644 include/CoreRuntimeKit/C++/base_exception delete mode 100644 include/CoreRuntimeKit/C++/base_math delete mode 100644 include/CoreRuntimeKit/C++/base_process create mode 100644 include/CoreRuntimeKit/C++/core/base_alloc.hpp create mode 100644 include/CoreRuntimeKit/C++/core/base_exception.hpp create mode 100644 include/CoreRuntimeKit/C++/core/base_math.hpp create mode 100644 include/CoreRuntimeKit/C++/core/base_process.hpp delete mode 100644 include/CoreRuntimeKit/C++/defines create mode 100644 include/CoreRuntimeKit/C++/defines.hpp delete mode 100644 include/CoreRuntimeKit/C++/filesystem create mode 100644 include/CoreRuntimeKit/C++/filesystem/filesystem.hpp delete mode 100644 include/CoreRuntimeKit/C++/new delete mode 100644 include/CoreRuntimeKit/C++/utility create mode 100644 include/CoreRuntimeKit/C++/utility.hpp create mode 100644 include/CoreRuntimeKit/Nectar/exports.hpp delete mode 100644 include/CoreRuntimeKit/Nectar/ncl_exports.h (limited to 'include') diff --git a/include/CoreRuntimeKit/C++/__abi b/include/CoreRuntimeKit/C++/__abi deleted file mode 100644 index 0252e0b..0000000 --- a/include/CoreRuntimeKit/C++/__abi +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#pragma once - -#include -#include - -__init_decl() - - static constexpr int32_t __unreachable_code = 34; - -inline void __compilerkit_unreachable(void) { - std::base_process::signal(__unreachable_code); - - while (1); -} - -__fini_decl() diff --git a/include/CoreRuntimeKit/C++/abi/abi.hpp b/include/CoreRuntimeKit/C++/abi/abi.hpp new file mode 100644 index 0000000..82ffd81 --- /dev/null +++ b/include/CoreRuntimeKit/C++/abi/abi.hpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nectar + +#pragma once + +#include +#include + +__init_decl() + + static constexpr int32_t __unreachable_code = 34; + +inline void __compilerkit_unreachable(void) { + std::base_process::signal(__unreachable_code); + while (true); +} + +__fini_decl() diff --git a/include/CoreRuntimeKit/C++/abi/new.hpp b/include/CoreRuntimeKit/C++/abi/new.hpp new file mode 100644 index 0000000..71afa28 --- /dev/null +++ b/include/CoreRuntimeKit/C++/abi/new.hpp @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2025-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nectar + +#pragma once + +#include + +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(size_t); +void operator _placement_delete(void*); + +/// \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 +void set_placement_policy(const PlaceableType&) 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; diff --git a/include/CoreRuntimeKit/C++/base_alloc b/include/CoreRuntimeKit/C++/base_alloc deleted file mode 100644 index 9e10f92..0000000 --- a/include/CoreRuntimeKit/C++/base_alloc +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#pragma once - -#include - -namespace std::base_alloc { -/// @brief allocate a new class. -/// @tparam KindClass the class type to allocate. -template -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 -inline KindClass* allocate_nothrow(Args&&... args) noexcept { - return allocate(forward(args)...); -} - -/// @brief free a class. -/// @tparam KindClass the class type to allocate. -template -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 -inline void release_nothrow(KindClass ptr) noexcept { - release(ptr); -} -} // namespace std::base_alloc diff --git a/include/CoreRuntimeKit/C++/base_exception b/include/CoreRuntimeKit/C++/base_exception deleted file mode 100644 index db1de01..0000000 --- a/include/CoreRuntimeKit/C++/base_exception +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#pragma once - -#include <__abi> -#include -#include -#include - -/// @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/include/CoreRuntimeKit/C++/base_math b/include/CoreRuntimeKit/C++/base_math deleted file mode 100644 index 6691c27..0000000 --- a/include/CoreRuntimeKit/C++/base_math +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#pragma once - -#include - -#ifndef NAN -#define NAN (__builtin_nanf("")) -#endif // !NAN - -/// @file Math -/// @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 -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 static kRootBase = 2; - auto constexpr static kNumberBase = 10; - - auto x = in / kRootBase; - - for (int i = 0; i < kNumberBase; ++i) { - x = (x + in / x) / kRootBase; - } - - return x; -} - -/// =========================================================== /// -/// @brief Square of function, with Base template argument. -/// @param of Base argument to find the square of. -/// =========================================================== /// -template -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/include/CoreRuntimeKit/C++/base_process b/include/CoreRuntimeKit/C++/base_process deleted file mode 100644 index 45de8fd..0000000 --- a/include/CoreRuntimeKit/C++/base_process +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#pragma once - -#include - -__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/include/CoreRuntimeKit/C++/core/base_alloc.hpp b/include/CoreRuntimeKit/C++/core/base_alloc.hpp new file mode 100644 index 0000000..9e10f92 --- /dev/null +++ b/include/CoreRuntimeKit/C++/core/base_alloc.hpp @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nectar + +#pragma once + +#include + +namespace std::base_alloc { +/// @brief allocate a new class. +/// @tparam KindClass the class type to allocate. +template +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 +inline KindClass* allocate_nothrow(Args&&... args) noexcept { + return allocate(forward(args)...); +} + +/// @brief free a class. +/// @tparam KindClass the class type to allocate. +template +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 +inline void release_nothrow(KindClass ptr) noexcept { + release(ptr); +} +} // namespace std::base_alloc diff --git a/include/CoreRuntimeKit/C++/core/base_exception.hpp b/include/CoreRuntimeKit/C++/core/base_exception.hpp new file mode 100644 index 0000000..c103da5 --- /dev/null +++ b/include/CoreRuntimeKit/C++/core/base_exception.hpp @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nectar + +#pragma once + +#include +#include +#include +#include + +/// @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/include/CoreRuntimeKit/C++/core/base_math.hpp b/include/CoreRuntimeKit/C++/core/base_math.hpp new file mode 100644 index 0000000..6691c27 --- /dev/null +++ b/include/CoreRuntimeKit/C++/core/base_math.hpp @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nectar + +#pragma once + +#include + +#ifndef NAN +#define NAN (__builtin_nanf("")) +#endif // !NAN + +/// @file Math +/// @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 +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 static kRootBase = 2; + auto constexpr static kNumberBase = 10; + + auto x = in / kRootBase; + + for (int i = 0; i < kNumberBase; ++i) { + x = (x + in / x) / kRootBase; + } + + return x; +} + +/// =========================================================== /// +/// @brief Square of function, with Base template argument. +/// @param of Base argument to find the square of. +/// =========================================================== /// +template +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/include/CoreRuntimeKit/C++/core/base_process.hpp b/include/CoreRuntimeKit/C++/core/base_process.hpp new file mode 100644 index 0000000..84354a9 --- /dev/null +++ b/include/CoreRuntimeKit/C++/core/base_process.hpp @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nectar + +#pragma once + +#include + +__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/include/CoreRuntimeKit/C++/defines b/include/CoreRuntimeKit/C++/defines deleted file mode 100644 index 3cd1ee1..0000000 --- a/include/CoreRuntimeKit/C++/defines +++ /dev/null @@ -1,80 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-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/CoreRuntimeKit/C++/defines.hpp b/include/CoreRuntimeKit/C++/defines.hpp new file mode 100644 index 0000000..3cd1ee1 --- /dev/null +++ b/include/CoreRuntimeKit/C++/defines.hpp @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-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/CoreRuntimeKit/C++/filesystem b/include/CoreRuntimeKit/C++/filesystem deleted file mode 100644 index 917dd0f..0000000 --- a/include/CoreRuntimeKit/C++/filesystem +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#ifndef __NECTAR_FS_H__ -#define __NECTAR_FS_H__ - -#include - -namespace std { -class path; -class filesystem_error; -class directory_entry; -class directory_iterator; -} // namespace std - -#endif // __NECTAR_FS_H__ diff --git a/include/CoreRuntimeKit/C++/filesystem/filesystem.hpp b/include/CoreRuntimeKit/C++/filesystem/filesystem.hpp new file mode 100644 index 0000000..917dd0f --- /dev/null +++ b/include/CoreRuntimeKit/C++/filesystem/filesystem.hpp @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nectar + +#ifndef __NECTAR_FS_H__ +#define __NECTAR_FS_H__ + +#include + +namespace std { +class path; +class filesystem_error; +class directory_entry; +class directory_iterator; +} // namespace std + +#endif // __NECTAR_FS_H__ diff --git a/include/CoreRuntimeKit/C++/new b/include/CoreRuntimeKit/C++/new deleted file mode 100644 index 71afa28..0000000 --- a/include/CoreRuntimeKit/C++/new +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2025-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#pragma once - -#include - -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(size_t); -void operator _placement_delete(void*); - -/// \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 -void set_placement_policy(const PlaceableType&) 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; diff --git a/include/CoreRuntimeKit/C++/utility b/include/CoreRuntimeKit/C++/utility deleted file mode 100644 index a427c44..0000000 --- a/include/CoreRuntimeKit/C++/utility +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-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 -inline auto forward(Args& arg) -> Args&& { - return static_cast(arg); -} - -/// @brief Move object. -/// @tparam Args the object type. -/// @param arg the object. -/// @return object's rvalue -template -inline auto move(Args&& arg) -> Args&& { - return static_cast(arg); -} -} // namespace std - -#endif // LIBCXX_UTILITY_H diff --git a/include/CoreRuntimeKit/C++/utility.hpp b/include/CoreRuntimeKit/C++/utility.hpp new file mode 100644 index 0000000..a427c44 --- /dev/null +++ b/include/CoreRuntimeKit/C++/utility.hpp @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-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 +inline auto forward(Args& arg) -> Args&& { + return static_cast(arg); +} + +/// @brief Move object. +/// @tparam Args the object type. +/// @param arg the object. +/// @return object's rvalue +template +inline auto move(Args&& arg) -> Args&& { + return static_cast(arg); +} +} // namespace std + +#endif // LIBCXX_UTILITY_H diff --git a/include/CoreRuntimeKit/Nectar/exports.hpp b/include/CoreRuntimeKit/Nectar/exports.hpp new file mode 100644 index 0000000..115484f --- /dev/null +++ b/include/CoreRuntimeKit/Nectar/exports.hpp @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026, 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/ne-foss-org/nectar + +#pragma once diff --git a/include/CoreRuntimeKit/Nectar/ncl_exports.h b/include/CoreRuntimeKit/Nectar/ncl_exports.h deleted file mode 100644 index 115484f..0000000 --- a/include/CoreRuntimeKit/Nectar/ncl_exports.h +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2026, 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/ne-foss-org/nectar - -#pragma once diff --git a/include/CoreRuntimeKit/README.md b/include/CoreRuntimeKit/README.md index 356eaf5..84d50bb 100644 --- a/include/CoreRuntimeKit/README.md +++ b/include/CoreRuntimeKit/README.md @@ -1,8 +1,12 @@ -# The NectarCoreLibrary +# The Nectar Core Support Libraries: ## Abstract: -The NCL is a kit used to interact with other programs using the FFI of Nectar. +The NCSL is a framework used to interact with other programs using the concept of FFI in Nectar. The implmentation is still in progress, feel free to open a PR to propose a new function. +## Example: + +**No examples are available right now, we're working on some.** + -- cgit v1.2.3