From 87a30d95dddc0cfcdf77e9d7406c1eea717865ff Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 19 Dec 2025 10:09:39 +0100 Subject: chore: new LibC++ version, updated file structure. Signed-off-by: Amlal El Mahrouss --- include/LibC++/base_alloc.h | 8 ++++---- include/LibC++/make-stdcpp-hdrs.sh | 2 +- include/LibC++/new.h | 24 ++++++++++++++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/LibC++/base_alloc.h b/include/LibC++/base_alloc.h index 7ae03df..cd95806 100644 --- a/include/LibC++/base_alloc.h +++ b/include/LibC++/base_alloc.h @@ -11,7 +11,7 @@ namespace std::base_alloc { /// @brief allocate a new class. /// @tparam KindClass the class type to allocate. -template +template inline KindClass* allocate(Args&&... args) { return new KindClass(forward(args)...); } @@ -19,14 +19,14 @@ inline KindClass* allocate(Args&&... args) { /// @brief allocate a new class. /// @note aborts on error. /// @tparam KindClass the class type to allocate. -template +template inline KindClass* allocate_nothrow(Args&&... args) noexcept { return allocate(forward(args)...); } /// @brief free a class. /// @tparam KindClass the class type to allocate. -template +template inline void release(KindClass ptr) { if (!ptr) return; @@ -36,7 +36,7 @@ inline void release(KindClass ptr) { /// @brief destroy and free a class. /// @note aborts on error. /// @tparam KindClass the class type to allocate. -template +template inline void release_nothrow(KindClass ptr) noexcept { release(ptr); } diff --git a/include/LibC++/make-stdcpp-hdrs.sh b/include/LibC++/make-stdcpp-hdrs.sh index a3730de..880f227 100755 --- a/include/LibC++/make-stdcpp-hdrs.sh +++ b/include/LibC++/make-stdcpp-hdrs.sh @@ -1,6 +1,6 @@ #! /bin/sh -outputDir=libc++/ +outputDir=libc++/nectar/ mkdir -p $outputDir diff --git a/include/LibC++/new.h b/include/LibC++/new.h index faa9da4..23bfa50 100644 --- a/include/LibC++/new.h +++ b/include/LibC++/new.h @@ -24,16 +24,32 @@ struct placement_t final { }; } // namespace std -#ifndef __has_placement -#define placement +// 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); -void* operator new(size_t, const std::nothrow_t&) noexcept; +/// \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 std::nothrow_t&) noexcept; +void* operator new[](size_t, const nothrow_t&) noexcept; void* operator new[](size_t, void*) noexcept; void operator delete(void*) noexcept; -- cgit v1.2.3