diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-18 22:05:37 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-18 22:06:44 +0100 |
| commit | 693aba77f3e31b0ddfe4d3e51f47fd3441c45f92 (patch) | |
| tree | 60bfbc77082b20e32c4a16885d8421413500e206 /include/CoreRuntimeKit/C++/abi | |
| parent | 25ba4e852d6ad15d91095e844bde858383c6b1e3 (diff) | |
[CHORE] Rework the Nectar Core Libraries as NCSL (Nectar Core Support Libraries).
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/CoreRuntimeKit/C++/abi')
| -rw-r--r-- | include/CoreRuntimeKit/C++/abi/abi.hpp | 20 | ||||
| -rw-r--r-- | include/CoreRuntimeKit/C++/abi/new.hpp | 57 |
2 files changed, 77 insertions, 0 deletions
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 <base_process> +#include <defines> + +__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 <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(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 <class PlaceableType> +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; |
