fix alignment_max for 32-bit systems (unfortunately, we need to include stdint.h now)

This commit is contained in:
daan 2022-10-30 19:47:54 -07:00
parent 24aac114e9
commit c128cf69be

View File

@ -95,6 +95,7 @@ terms of the MIT license. A copy of the license can be found in the file
#include <stddef.h> // size_t #include <stddef.h> // size_t
#include <stdbool.h> // bool #include <stdbool.h> // bool
#include <stdint.h> // INTPTR_MAX
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -166,7 +167,11 @@ mi_decl_export void mi_process_info(size_t* elapsed_msecs, size_t* user_msecs, s
// Note that `alignment` always follows `size` for consistency with unaligned // Note that `alignment` always follows `size` for consistency with unaligned
// allocation, but unfortunately this differs from `posix_memalign` and `aligned_alloc`. // allocation, but unfortunately this differs from `posix_memalign` and `aligned_alloc`.
// ------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------
#if (INTPTR_MAX > INT32_MAX)
#define MI_ALIGNMENT_MAX (16*1024*1024UL) // maximum supported alignment is 16MiB #define MI_ALIGNMENT_MAX (16*1024*1024UL) // maximum supported alignment is 16MiB
#else
#define MI_ALIGNMENT_MAX (1024*1024UL) // maximum supported alignment for 32-bit systems is 1MiB
#endif
mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2); mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2);
mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);