diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-19 10:09:39 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-19 10:09:39 +0100 |
| commit | 87a30d95dddc0cfcdf77e9d7406c1eea717865ff (patch) | |
| tree | ca52b9e425046e137aea267515b32149d22c4545 /include/LibC++ | |
| parent | 228479a454d325340326f4fd23e13d780884fd2a (diff) | |
chore: new LibC++ version, updated file structure.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/LibC++')
| -rw-r--r-- | include/LibC++/base_alloc.h | 8 | ||||
| -rwxr-xr-x | include/LibC++/make-stdcpp-hdrs.sh | 2 | ||||
| -rw-r--r-- | include/LibC++/new.h | 24 |
3 files changed, 25 insertions, 9 deletions
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 <typename KindClass, typename... Args> +template <class KindClass, typename... Args> 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 <typename KindClass, typename... Args> +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 <typename KindClass> +template <class KindClass> 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 <typename KindClass> +template <class KindClass> 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 <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 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; |
