This commit is contained in:
David CARLIER 2022-11-21 14:45:38 -08:00 committed by GitHub
commit b164f6cde3
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 1 deletions

View file

@ -82,6 +82,7 @@ void* _mi_os_alloc(size_t size, mi_stats_t* stats); // to allocat
void _mi_os_free(void* p, size_t size, mi_stats_t* stats); // to free thread local data
size_t _mi_os_good_alloc_size(size_t size);
bool _mi_os_has_overcommit(void);
bool _mi_os_alloc_named(void* p, size_t size, const char *name);
void* _mi_os_alloc_aligned_offset(size_t size, size_t alignment, size_t align_offset, bool commit, bool* large, mi_stats_t* tld_stats);
void _mi_os_free_aligned(void* p, size_t size, size_t alignment, size_t align_offset, bool was_committed, mi_stats_t* tld_stats);

View file

@ -394,6 +394,8 @@ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_n(size_t count, s
mi_decl_nodiscard mi_decl_export void* mi_new_realloc(void* p, size_t newsize) mi_attr_alloc_size(2);
mi_decl_nodiscard mi_decl_export void* mi_new_reallocn(void* p, size_t newcount, size_t size) mi_attr_alloc_size2(2, 3);
mi_decl_export bool mi_alloc_named(void* p, size_t size, const char *name);
#ifdef __cplusplus
}
#endif

View file

@ -45,6 +45,7 @@ terms of the MIT license. A copy of the license can be found in the file
#else
#include <sys/mman.h>
#endif
#include <sys/prctl.h>
#endif
#if defined(__APPLE__)
#include <TargetConditionals.h>
@ -1483,3 +1484,20 @@ int _mi_os_numa_node_get(mi_os_tld_t* tld) {
if (numa_node >= numa_count) { numa_node = numa_node % numa_count; }
return (int)numa_node;
}
bool _mi_os_alloc_named(void* p, size_t size, const char *name) {
mi_assert_internal(p != NULL);
mi_assert_internal(name != NULL);
#if defined(__linux__)
#if !defined(PR_SET_VMA)
#define PR_SET_VMA 0x53564d41
#define PR_SET_VMA_ANON_NAME 0
#endif
return (prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)p, size, (unsigned long)name) == 0);
#else
MI_UNUSED(p);
MI_UNUSED(size);
MI_UNUSED(name);
return false;
#endif
}

View file

@ -893,3 +893,7 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_al
return _mi_page_malloc(heap, page, size, zero);
}
}
bool mi_alloc_named(void* p, size_t size, const char *name) {
return _mi_os_alloc_named(p, size, name);
}

View file

@ -163,7 +163,6 @@ static bool mi_memid_is_arena(size_t id, mem_region_t** region, mi_bitmap_index_
}
}
/* ----------------------------------------------------------------------------
Allocate a region is allocated from the OS (or an arena)
-----------------------------------------------------------------------------*/