/* * Copyright (C) 2015-2017 Alibaba Group Holding Limited */ #ifndef K_MM_BLK_H #define K_MM_BLK_H #ifdef __cplusplus extern "C" { #endif /** @addtogroup aos_rhino mm * Pool memory management. Pool memory can be part of heap. * Pool is used to manage the little fixed-size block * * @{ */ #define MM_BLK_SLICE_BIT 10 #define MM_BLK_SLICE_SIZE (1<= ((mblk_pool_t*)(pool))->pool_start) \ && ((uintptr_t)(blk) < ((mblk_pool_t*)(pool))->pool_end)) /** * get blk size, should followed by krhino_mblk_check * @param[in] pool pointer to the pool * @param[in] blk pointer to the blk * @return the len of blk */ RHINO_INLINE size_t krhino_mblk_get_size(mblk_pool_t *pool, void *blk) { uint32_t slice_idx; uint32_t blk_type; mblk_list_t *blk_list; slice_idx = ((uintptr_t)blk - pool->pool_start) >> MM_BLK_SLICE_BIT; blk_type = pool->slice_type[slice_idx]; blk_list = &(pool->blk_list[blk_type]); return blk_list->blk_size; } /** @} */ #ifdef __cplusplus } #endif #endif /* K_MM_BLK_H */