XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
allocator.h
浏览该文件的文档.
1
13#ifndef __xwos_mm_mempool_allocator_h__
14#define __xwos_mm_mempool_allocator_h__
15
16#include <xwos/standard.h>
17#include <xwos/mm/common.h>
18
45
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!"
70#endif
71
77// cppcheck-suppress [misra-c2012-20.7]
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)])]
82
87 const char * name;
105};
106
135xwer_t xwmm_mempool_init(struct xwmm_mempool * mp, const char * name,
136 xwptr_t origin, xwsz_t size, xwsz_t pgodr,
137 xwsz_t pre, void ** membuf);
138
160 void ** membuf);
161
179xwer_t xwmm_mempool_free(struct xwmm_mempool * mp, void * mem);
180
208 void ** membuf);
209
233 xwsz_t alignment, xwsz_t size,
234 void ** membuf);
235
240#endif /* xwos/mm/mempool/allocator.h */
xwer_t xwmm_mempool_malloc(struct xwmm_mempool *mp, xwsz_t size, void **membuf)
XWMM API:从内存池中申请内存
Definition allocator.c:260
xwer_t xwmm_mempool_memalign(struct xwmm_mempool *mp, xwsz_t alignment, xwsz_t size, void **membuf)
XWMM API:从内存池中申请对齐的内存
Definition allocator.c:467
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:初始化内存池
Definition allocator.c:200
xwer_t xwmm_mempool_free(struct xwmm_mempool *mp, void *mem)
XWMM API:释放内存
Definition allocator.c:342
xwer_t xwmm_mempool_realloc(struct xwmm_mempool *mp, xwsz_t size, void **membuf)
XWMM API:调整内存大小
Definition allocator.c:418
signed long xwer_t
Definition type.h:554
unsigned long xwsz_t
Definition type.h:339
uint8_t xwu8_t
Definition type.h:194
unsigned long xwptr_t
Definition type.h:375
XWOS内存管理:内存池:对象缓存
XWOS内存管理:内存池:页分配器
对象缓存
Definition objcache.h:34
const char * name
Definition objcache.h:37
内存池
Definition allocator.h:86
struct xwmm_mempool_page_allocator pa
Definition allocator.h:88
xwu8_t rem[0]
Definition allocator.h:104
struct xwmm_mempool_objcache oc_512
Definition allocator.h:100
struct xwmm_mempool_objcache oc_32
Definition allocator.h:91
struct xwmm_mempool_objcache oc_1024
Definition allocator.h:102
struct xwmm_mempool_objcache oc_768
Definition allocator.h:101
struct xwmm_mempool_objcache oc_160
Definition allocator.h:95
struct xwmm_mempool_objcache oc_8
Definition allocator.h:89
struct xwmm_mempool_objcache oc_192
Definition allocator.h:96
struct xwmm_mempool_objcache oc_96
Definition allocator.h:93
struct xwmm_mempool_objcache oc_2048
Definition allocator.h:103
struct xwmm_mempool_objcache oc_256
Definition allocator.h:97
struct xwmm_mempool_objcache oc_128
Definition allocator.h:94
struct xwmm_mempool_objcache oc_384
Definition allocator.h:99
struct xwmm_mempool_objcache oc_320
Definition allocator.h:98
struct xwmm_mempool_objcache oc_64
Definition allocator.h:92
struct xwmm_mempool_objcache oc_16
Definition allocator.h:90
const char * name
Definition allocator.h:87
XWOS内存管理:通用定义
XWOS的标准头文件