mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
add base and size to OS memid
This commit is contained in:
parent
5e95ebc7a0
commit
fe5a314114
9 changed files with 104 additions and 40 deletions
|
@ -237,6 +237,30 @@ static inline uint32_t mi_ctz32(uint32_t x) {
|
|||
#define MI_HAS_FAST_BITSCAN 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static inline size_t mi_popcount(size_t x) {
|
||||
#if mi_has_builtin_size(popcount)
|
||||
return mi_builtin_size(popcount)(x);
|
||||
#elif defined(_MSC_VER) && (MI_ARCH_X64 || MI_ARCH_X86 || MI_ARCH_ARM64 || MI_ARCH_ARM32)
|
||||
#if MI_SIZE_BITS==32
|
||||
return __popcnt(x);
|
||||
#else
|
||||
return __popcnt64(x);
|
||||
#endif
|
||||
#elif MI_ARCH_X64 && defined(__BMI1__)
|
||||
return (size_t)_mm_popcnt_u64(x);
|
||||
#else
|
||||
#define MI_HAS_FAST_POPCOUNT 0
|
||||
error define generic popcount
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef MI_HAS_FAST_POPCOUNT
|
||||
#define MI_HAS_FAST_POPCOUNT 1
|
||||
#endif
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------
|
||||
find trailing/leading zero (bit scan forward/reverse)
|
||||
-------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -844,8 +844,10 @@ static inline mi_memid_t _mi_memid_none(void) {
|
|||
return _mi_memid_create(MI_MEM_NONE);
|
||||
}
|
||||
|
||||
static inline mi_memid_t _mi_memid_create_os(bool committed, bool is_zero, bool is_large) {
|
||||
static inline mi_memid_t _mi_memid_create_os(void* base, size_t size, bool committed, bool is_zero, bool is_large) {
|
||||
mi_memid_t memid = _mi_memid_create(MI_MEM_OS);
|
||||
memid.mem.os.base = base;
|
||||
memid.mem.os.size = size;
|
||||
memid.initially_committed = committed;
|
||||
memid.initially_zero = is_zero;
|
||||
memid.is_pinned = is_large;
|
||||
|
|
|
@ -171,6 +171,7 @@ static inline bool mi_memkind_is_os(mi_memkind_t memkind) {
|
|||
typedef struct mi_memid_os_info {
|
||||
void* base; // actual base address of the block (used for offset aligned allocations)
|
||||
size_t alignment; // alignment at allocation
|
||||
size_t size; // allocated full size
|
||||
} mi_memid_os_info_t;
|
||||
|
||||
typedef struct mi_memid_arena_info {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue