diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-27 01:43:44 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-27 01:43:44 +0100 |
| commit | 2174548c1cd0695399275dc59f1e4e3f726b4a6f (patch) | |
| tree | f4f3ae198e311686be8d13ba7c9e6d28c49177f5 /include/CoreRuntime/cplusplus/abi | |
| parent | 81c082643568ef4507c92c6f8c4d7f2778274aa6 (diff) | |
[FEAT] Refactor CoreRuntimeKit to CoreRuntime and its design.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/CoreRuntime/cplusplus/abi')
| -rw-r--r-- | include/CoreRuntime/cplusplus/abi/abi.hpp | 20 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/abi/new.hpp | 59 |
2 files changed, 79 insertions, 0 deletions
diff --git a/include/CoreRuntime/cplusplus/abi/abi.hpp b/include/CoreRuntime/cplusplus/abi/abi.hpp new file mode 100644 index 0000000..fe60401 --- /dev/null +++ b/include/CoreRuntime/cplusplus/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 <CoreRuntime/cplusplus/core/base_process.hpp> +#include <CoreRuntime/cplusplus/defines.hpp> + +__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/CoreRuntime/cplusplus/abi/new.hpp b/include/CoreRuntime/cplusplus/abi/new.hpp new file mode 100644 index 0000000..6592567 --- /dev/null +++ b/include/CoreRuntime/cplusplus/abi/new.hpp @@ -0,0 +1,59 @@ +// 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 <CoreRuntime/cplusplus/defines.hpp> + +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; |
