diff --git a/headers/private/kernel/util/kernel_cpp.h b/headers/private/kernel/util/kernel_cpp.h index a59ad9ff92..0b493c4ab9 100644 --- a/headers/private/kernel/util/kernel_cpp.h +++ b/headers/private/kernel/util/kernel_cpp.h @@ -23,14 +23,21 @@ typedef struct {} mynothrow_t; extern const mynothrow_t mynothrow; #ifndef __clang__ -extern void* operator new(size_t size) throw (std::bad_alloc); -extern void* operator new[](size_t size) throw (std::bad_alloc); -extern void* operator new(size_t size, const std::nothrow_t &) throw (); -extern void* operator new[](size_t size, const std::nothrow_t &) throw (); -extern void* operator new(size_t size, const mynothrow_t &) throw (); -extern void* operator new[](size_t size, const mynothrow_t &) throw (); -extern void operator delete(void *ptr) throw (); -extern void operator delete[](void *ptr) throw (); +#if __cplusplus >= 201402L +#define _THROW(x) +#define _NOEXCEPT noexcept +#else +#define _THROW(x) throw (x) +#define _NOEXCEPT throw () +#endif +extern void* operator new(size_t size) _THROW(std::bad_alloc); +extern void* operator new[](size_t size) _THROW(std::bad_alloc); +extern void* operator new(size_t size, const std::nothrow_t &) _NOEXCEPT; +extern void* operator new[](size_t size, const std::nothrow_t &) _NOEXCEPT; +extern void* operator new(size_t size, const mynothrow_t &) _NOEXCEPT; +extern void* operator new[](size_t size, const mynothrow_t &) _NOEXCEPT; +extern void operator delete(void *ptr) _NOEXCEPT; +extern void operator delete[](void *ptr) _NOEXCEPT; #endif #if __cplusplus >= 201402L diff --git a/src/system/kernel/slab/allocator.cpp b/src/system/kernel/slab/allocator.cpp index e863991897..ec8bef5e59 100644 --- a/src/system/kernel/slab/allocator.cpp +++ b/src/system/kernel/slab/allocator.cpp @@ -220,6 +220,16 @@ memalign_etc(size_t alignment, size_t size, uint32 flags) } +int +posix_memalign(void** _pointer, size_t alignment, size_t size) +{ + if ((alignment & (sizeof(void*) - 1)) != 0 || _pointer == NULL) + return B_BAD_VALUE; + *_pointer = block_alloc(size, alignment, 0); + return 0; +} + + void free_etc(void *address, uint32 flags) { diff --git a/src/system/kernel/util/kernel_cpp.cpp b/src/system/kernel/util/kernel_cpp.cpp index 8c25bbe1d1..4a55f693b7 100644 --- a/src/system/kernel/util/kernel_cpp.cpp +++ b/src/system/kernel/util/kernel_cpp.cpp @@ -40,6 +40,14 @@ const nothrow_t std::nothrow = {}; # endif #endif +#if __cplusplus >= 201402L +#define _THROW(x) +#define _NOEXCEPT noexcept +#else +#define _THROW(x) throw (x) +#define _NOEXCEPT throw () +#endif + const mynothrow_t mynothrow = {}; #if __GNUC__ == 2 @@ -76,7 +84,7 @@ __cxa_finalize(void* dsoHandle) // full C++ support in the kernel #if (defined(_KERNEL_MODE) || defined(_LOADER_MODE)) void * -operator new(size_t size) throw (std::bad_alloc) +operator new(size_t size) _THROW(std::bad_alloc) { // we don't actually throw any exceptions, but we have to // keep the prototype as specified in , or else GCC 3 @@ -86,49 +94,49 @@ operator new(size_t size) throw (std::bad_alloc) void * -operator new[](size_t size) throw (std::bad_alloc) +operator new[](size_t size) { return malloc(size); } void * -operator new(size_t size, const std::nothrow_t &) throw () +operator new(size_t size, const std::nothrow_t &) _NOEXCEPT { return malloc(size); } void * -operator new[](size_t size, const std::nothrow_t &) throw () +operator new[](size_t size, const std::nothrow_t &) _NOEXCEPT { return malloc(size); } void * -operator new(size_t size, const mynothrow_t &) throw () +operator new(size_t size, const mynothrow_t &) _NOEXCEPT { return malloc(size); } void * -operator new[](size_t size, const mynothrow_t &) throw () +operator new[](size_t size, const mynothrow_t &) _NOEXCEPT { return malloc(size); } void -operator delete(void *ptr) throw () +operator delete(void *ptr) _NOEXCEPT { free(ptr); } void -operator delete[](void *ptr) throw () +operator delete[](void *ptr) _NOEXCEPT { free(ptr); }