23#ifdef XWMM_MEMPOOLLOGF
24# define xwmm_mempoollogf(lv, thd, fmt, ...) \
25 xwlogf(lv, "Thd:%s", fmt, thd->stack.name, ##__VA_ARGS__)
27# define xwmm_mempoollogf(lv, thd, fmt, ...)
128 for (i = 0; i < nr; i++) {
234 pg_offset = 1U << pg_odr;
235 while (pg_odr > target_odr) {
239 buddy = &pa->
pgarray[pg_seq + pg_offset];
259 odr = pg->
order + 1U;
260 while (odr < pa->max_order) {
321 if (
NULL == leftmost) {
323 }
else if (pgseq < leftmost->
attr.free.seq) {
329 while (
NULL != rbn) {
332 if (pgseq < b->
attr.free.seq) {
426 if (
NULL == leftmost) {
525 if (((
xwptr_t)mem < pa->zone.origin) ||
588 if (((
xwptr_t)mem < pa->zone.origin) ||
#define XWMM_UNALIGNED_MASK
xwer_t xwmm_mempool_page_free(struct xwmm_mempool_page_allocator *pa, struct xwmm_mempool_page *pg)
XWMM API:释放一页内存
#define XWMM_MEMPOOL_PAGE_ORDER_CMB
#define XWMM_MEMPOOL_PAGE_MAPPING_FREE
xwer_t xwmm_mempool_page_allocate(struct xwmm_mempool_page_allocator *pa, xwsq_t order, struct xwmm_mempool_page **pgbuf)
XWMM API:申请一页内存
#define XWMM_MEMPOOL_PAGE_MAPPING_INVAILD
xwer_t xwmm_mempool_page_find(struct xwmm_mempool_page_allocator *pa, void *mem, struct xwmm_mempool_page **pgbuf)
依据内存地址查找页
xwer_t xwmm_mempool_page_allocator_init(struct xwmm_mempool_page_allocator *pa, const char *name, xwptr_t origin, xwsz_t size, xwsz_t pgsize, struct xwmm_mempool_page_odrbtree *odrbtree, struct xwmm_mempool_page *pgarray)
XWMM API:初始化页分配器
#define EEXIST
File exists
#define ESRCH
No such process
#define EALIGN
Not aligned
#define ENOMEM
Not enough space
#define EBUSY
Device or resource busy
#define ERANGE
Result too large
#define EALREADY
Socket already connected
static void xwlib_rbtree_init_node(struct xwlib_rbtree_node *rbn)
初始化红黑树节点
static struct xwlib_rbtree_node * xwlib_rbtree_get_parent(struct xwlib_rbtree_node *node)
返回节点的父节点指针
void xwlib_rbtree_insert_color(struct xwlib_rbtree *tree, struct xwlib_rbtree_node *node)
插入一个红色节点后修正红黑树的颜色
static void xwlib_rbtree_init(struct xwlib_rbtree *rbt)
初始化红黑树
#define xwlib_rbtree_entry(ptr, type, member)
从红黑树节点指针值计算出包含该节点成员的外层结构体的指针值
void xwlib_rbtree_remove(struct xwlib_rbtree *tree, struct xwlib_rbtree_node *node)
删除一个节点,并修正红黑树的颜色
static void xwlib_rbtree_link(struct xwlib_rbtree_node *node, xwptr_t lpc)
链接节点,并设置位置及颜色信息
#define xwbop_fls(type, data)
XWOS BOPLIB:在数据中从最高位起查找第一个被置1的位
static void xwos_sqlk_init(struct xwos_sqlk *sql)
XWOS API:初始化顺序锁
static void xwos_sqlk_wr_lock_cpuirqsv(struct xwos_sqlk *sql, xwreg_t *cpuirq)
XWOS API:开启写临界区,保存本地CPU的中断标志并关闭
static void xwos_sqlk_wr_unlock_cpuirqrs(struct xwos_sqlk *sql, xwreg_t cpuirq)
XWOS API:关闭写临界区,恢复本地CPU的中断标志
static xwer_t xwmm_mempool_page_odrbtree_remove(struct xwmm_mempool_page_odrbtree *ot, struct xwmm_mempool_page *pg)
从阶红黑树中删除页
static xwer_t xwmm_mempool_page_i_a_malloc(void *this, xwsz_t size, void **membuf)
i_allocator接口函数:申请内存
static xwer_t xwmm_mempool_page_i_a_free(void *this, void *mem)
i_allocator接口函数:释放内存
static struct xwmm_mempool_page * xwmm_mempool_mem_to_page(struct xwmm_mempool_page_allocator *pa, void *mem)
从页内存地址获得其页控制块的指针
static void xwmm_mempool_page_divide_page(struct xwmm_mempool_page_allocator *pa, struct xwmm_mempool_page *pg, xwsq_t target_odr, struct xwmm_mempool_page_odrbtree *ot)
将大的页拆分成小的页
static void xwmm_mempool_page_combine(struct xwmm_mempool_page_allocator *pa, struct xwmm_mempool_page *pg)
合并空闲的伙伴页
static struct xwmm_mempool_page * xwmm_mempool_page_odrbtree_choose(struct xwmm_mempool_page_odrbtree *ot)
从阶红黑树中选择一页
static xwer_t xwmm_mempool_page_odrbtree_add(struct xwmm_mempool_page_odrbtree *ot, struct xwmm_mempool_page *pg)
增加页到阶红黑树中
static struct xwmm_mempool_page * xwmm_mempool_page_get_buddy(struct xwmm_mempool_page_allocator *pa, struct xwmm_mempool_page *pg)
找到页的伙伴页
static xwsq_t xwmm_mempool_page_get_seq(struct xwmm_mempool_page_allocator *pa, struct xwmm_mempool_page *pg)
获取页的序列值
struct xwlib_rbtree_node * left
struct xwlib_rbtree_node * right
union xwlib_rbtree_node::@5 lpc
struct xwlib_rbtree_node * root
xwer_t(* free)(void *, void *)
xwer_t(* malloc)(void *, xwsz_t, void **)
struct xwmm_mempool_i_allocator i_a
struct xwmm_mempool_page * pgarray
struct xwmm_mempool_page_odrbtree * odrbtree
struct xwmm_mempool_page * leftmost
struct xwmm_mempool_page_allocator * owner
struct xwlib_rbtree_node rbnode
union xwmm_mempool_page::@1 attr
union xwmm_mempool_page::@2 data
struct xwmm_mempool_page::@1::@3 free