diff --git a/headers/os/BeBuild.h b/headers/os/BeBuild.h index 71736c8e8b..dcfba80924 100644 --- a/headers/os/BeBuild.h +++ b/headers/os/BeBuild.h @@ -84,9 +84,11 @@ __attribute__((format(__printf__, _format_, _args_))) #if __GNUC__ >= 4 +# define _ALIGNED_BY_ARG(_no_) __attribute__((alloc_align(_no_))) # define _EXPORT __attribute__((visibility("default"))) # define B_ALWAYS_INLINE __attribute__((always_inline)) inline #else +# define _ALIGNED_BY_ARG(_no_) # define _EXPORT #endif #define _IMPORT diff --git a/headers/posix/malloc.h b/headers/posix/malloc.h index 7754038311..5f8d2d804d 100644 --- a/headers/posix/malloc.h +++ b/headers/posix/malloc.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. + * Copyright 2002-2021 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _MALLOC_H @@ -17,7 +17,7 @@ extern void *malloc(size_t numBytes); extern void *realloc(void *oldPointer, size_t newSize); extern void *calloc(size_t numElements, size_t size); extern void free(void *pointer); -extern void *memalign(size_t alignment, size_t numBytes); +extern void *memalign(size_t alignment, size_t numBytes) _ALIGNED_BY_ARG(1); extern void *valloc(size_t numBytes); #ifdef _GNU_SOURCE diff --git a/headers/posix/stdlib.h b/headers/posix/stdlib.h index ebaa9ec96a..9ab024e472 100644 --- a/headers/posix/stdlib.h +++ b/headers/posix/stdlib.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. + * Copyright 2002-2021 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDLIB_H_ @@ -50,7 +50,7 @@ extern void free(void *pointer); extern void *malloc(size_t size); extern int posix_memalign(void **_pointer, size_t alignment, size_t size); #ifdef _ISOC11_SOURCE -extern void *aligned_alloc(size_t alignment, size_t size); +extern void *aligned_alloc(size_t alignment, size_t size) _ALIGNED_BY_ARG(1); #endif extern void *realloc(void *oldPointer, size_t newSize); diff --git a/headers/private/kernel/heap.h b/headers/private/kernel/heap.h index 3ac8b8a6e6..7955a8ffa5 100644 --- a/headers/private/kernel/heap.h +++ b/headers/private/kernel/heap.h @@ -59,10 +59,10 @@ extern "C" { #endif -void* memalign_etc(size_t alignment, size_t size, uint32 flags); +void* memalign_etc(size_t alignment, size_t size, uint32 flags) _ALIGNED_BY_ARG(1); void free_etc(void* address, uint32 flags); -void* memalign(size_t alignment, size_t size); +void* memalign(size_t alignment, size_t size) _ALIGNED_BY_ARG(1); void deferred_free(void* block); @@ -74,7 +74,7 @@ void heap_add_area(heap_allocator* heap, area_id areaID, addr_t base, size_t size); heap_allocator* heap_create_allocator(const char* name, addr_t base, size_t size, const heap_class* heapClass, bool allocateOnHeap); -void* heap_memalign(heap_allocator* heap, size_t alignment, size_t size); +void* heap_memalign(heap_allocator* heap, size_t alignment, size_t size) _ALIGNED_BY_ARG(2); status_t heap_free(heap_allocator* heap, void* address); #if KERNEL_HEAP_LEAK_CHECK