summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2022-09-14 11:59:22 +0200
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-09-16 05:39:28 +0000
commit88ff01bb1718ad6342ebd769fc31147f9cc5806f (patch)
treeaa3e530670f21ad5e508d99dd54d8238a5678c85 /Userland/Libraries/LibC
parent119567e1760e9bf8ec7967464bac63c08ab20a89 (diff)
downloadserenity-88ff01bb1718ad6342ebd769fc31147f9cc5806f.zip
LibC: Remove `_aligned_malloc` and `_aligned_free`
We now have a proper aligned allocation implementation, and the toolchain patch to make Clang use the intermediary implementation has already been removed in an earlier iteration.
Diffstat (limited to 'Userland/Libraries/LibC')
-rw-r--r--Userland/Libraries/LibC/malloc.cpp37
-rw-r--r--Userland/Libraries/LibC/stdlib.h2
2 files changed, 0 insertions, 39 deletions
diff --git a/Userland/Libraries/LibC/malloc.cpp b/Userland/Libraries/LibC/malloc.cpp
index e03b2ce26e..e0d2925a8d 100644
--- a/Userland/Libraries/LibC/malloc.cpp
+++ b/Userland/Libraries/LibC/malloc.cpp
@@ -554,37 +554,6 @@ void* malloc(size_t size)
return ptr_or_error.value();
}
-// This is a Microsoft extension, and is not found on other Unix-like systems.
-// FIXME: Remove this when all patches have been switched to aligned_alloc()
-//
-// This is used in libc++ to implement C++17 aligned new/delete.
-//
-// Both Unix-y alternatives to _aligned_malloc(), the C11 aligned_alloc() and
-// posix_memalign() say that the resulting pointer can be deallocated with
-// regular free(), which means that the allocator has to keep track of the
-// requested alignments. By contrast, _aligned_malloc() is paired with
-// _aligned_free(), so it can be easily implemented on top of malloc().
-void* _aligned_malloc(size_t size, size_t alignment)
-{
- if (popcount(alignment) != 1) {
- errno = EINVAL;
- return nullptr;
- }
- alignment = max(alignment, sizeof(void*));
- if (Checked<size_t>::addition_would_overflow(size, alignment)) {
- errno = ENOMEM;
- return nullptr;
- }
- void* ptr = malloc(size + alignment);
- if (!ptr) {
- errno = ENOMEM;
- return nullptr;
- }
- auto aligned_ptr = (void*)(((FlatPtr)ptr + alignment) & ~(alignment - 1));
- ((void**)aligned_ptr)[-1] = ptr;
- return aligned_ptr;
-}
-
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html
void free(void* ptr)
{
@@ -595,12 +564,6 @@ void free(void* ptr)
free_impl(ptr);
}
-void _aligned_free(void* ptr)
-{
- if (ptr)
- free(((void**)ptr)[-1]);
-}
-
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/calloc.html
void* calloc(size_t count, size_t size)
{
diff --git a/Userland/Libraries/LibC/stdlib.h b/Userland/Libraries/LibC/stdlib.h
index bdf9a56252..9166205b40 100644
--- a/Userland/Libraries/LibC/stdlib.h
+++ b/Userland/Libraries/LibC/stdlib.h
@@ -25,8 +25,6 @@ size_t malloc_good_size(size_t);
void serenity_dump_malloc_stats(void);
void free(void*);
__attribute__((alloc_size(2))) void* realloc(void* ptr, size_t);
-__attribute__((malloc, alloc_size(1), alloc_align(2))) void* _aligned_malloc(size_t size, size_t alignment);
-void _aligned_free(void* memblock);
char* getenv(char const* name);
char* secure_getenv(char const* name);
int putenv(char*);