13#ifndef __xwos_mm_mempool_allocator_h__
14#define __xwos_mm_mempool_allocator_h__
51#define XWMM_MEMPOOL_PAGE_SIZE (4096U)
52#define XWMM_MEMPOOL_OC_8_PAGE_ODR (0U)
53#define XWMM_MEMPOOL_OC_16_PAGE_ODR (0U)
54#define XWMM_MEMPOOL_OC_32_PAGE_ODR (0U)
55#define XWMM_MEMPOOL_OC_64_PAGE_ODR (0U)
56#define XWMM_MEMPOOL_OC_96_PAGE_ODR (1U)
57#define XWMM_MEMPOOL_OC_128_PAGE_ODR (0U)
58#define XWMM_MEMPOOL_OC_160_PAGE_ODR (0U)
59#define XWMM_MEMPOOL_OC_192_PAGE_ODR (0U)
60#define XWMM_MEMPOOL_OC_256_PAGE_ODR (0U)
61#define XWMM_MEMPOOL_OC_320_PAGE_ODR (1U)
62#define XWMM_MEMPOOL_OC_384_PAGE_ODR (1U)
63#define XWMM_MEMPOOL_OC_512_PAGE_ODR (1U)
64#define XWMM_MEMPOOL_OC_768_PAGE_ODR (0U)
65#define XWMM_MEMPOOL_OC_1024_PAGE_ODR (0U)
66#define XWMM_MEMPOOL_OC_2048_PAGE_ODR (1U)
68#if (XWMM_MEMPOOL_PAGE_SIZE & XWMM_UNALIGNED_MASK)
69# error "Page size must be aligned to XWMM_ALIGNMENT!"
78#define XWMM_MEMPOOL_RAWOBJ_DEF(name, pgodr) \
79 xwu8_t name[sizeof(struct xwmm_mempool) + \
80 sizeof(struct xwmm_mempool_page_odrbtree[(pgodr) + 1U]) + \
81 sizeof(struct xwmm_mempool_page[1U << (pgodr)])]
137 xwsz_t pre,
void ** membuf);
xwer_t xwmm_mempool_malloc(struct xwmm_mempool *mp, xwsz_t size, void **membuf)
XWMM API:从内存池中申请内存
xwer_t xwmm_mempool_memalign(struct xwmm_mempool *mp, xwsz_t alignment, xwsz_t size, void **membuf)
XWMM API:从内存池中申请对齐的内存
xwer_t xwmm_mempool_init(struct xwmm_mempool *mp, const char *name, xwptr_t origin, xwsz_t size, xwsz_t pgodr, xwsz_t pre, void **membuf)
XWMM API:初始化内存池
xwer_t xwmm_mempool_free(struct xwmm_mempool *mp, void *mem)
XWMM API:释放内存
xwer_t xwmm_mempool_realloc(struct xwmm_mempool *mp, xwsz_t size, void **membuf)
XWMM API:调整内存大小
struct xwmm_mempool_page_allocator pa
struct xwmm_mempool_objcache oc_512
struct xwmm_mempool_objcache oc_32
struct xwmm_mempool_objcache oc_1024
struct xwmm_mempool_objcache oc_768
struct xwmm_mempool_objcache oc_160
struct xwmm_mempool_objcache oc_8
struct xwmm_mempool_objcache oc_192
struct xwmm_mempool_objcache oc_96
struct xwmm_mempool_objcache oc_2048
struct xwmm_mempool_objcache oc_256
struct xwmm_mempool_objcache oc_128
struct xwmm_mempool_objcache oc_384
struct xwmm_mempool_objcache oc_320
struct xwmm_mempool_objcache oc_64
struct xwmm_mempool_objcache oc_16