1 Star 0 Fork 16

chzfmx/xmem

forked from 牧梦追马/xmem 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
xconfig.h 2.86 KB
一键复制 编辑 原始数据 按行查看 历史
牧梦追马 提交于 2018-09-17 11:19 . 1.更新到1.0.2。
/*
* xmem configurations
* Copyright (c) 2016, Shoowing <420260138@qq.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of Apache License Version 2.0
*
* See README for more details.
*/
#ifndef __XCONFIG_H__
#define __XCONFIG_H__
#define XMEM_DEBUG 0
#define CPU_64_BIT 0
#define XMEM_SUPERBLOCK_ENABLE 1
#define XMEM_SUPERBLOCK_BLKS_MAX 32
/*****************************************************************************
*MACRO
*XMEM_CORRUPT_CHECK
*DESCRIPTION
*corrupt check, for debug purpose
*0
*------------------------------------------------------------------------------
*|Header List| xMemHdrEnd--->| ... |<---xMemBlkStart |Blocks,Super Blocks|
*------------------------------------------------------------------------------
*1
*--------------------------------------------------------------
*| | prev | blk | next | |
*| ... |--------------|--------------|--------------| ... |
*| |header| mem |header| mem |header| mem | |
--------------------------------------------------------------
*******************************************************************************/
#define XMEM_CORRUPT_CHECK 0
#if CPU_64_BIT
#define XMEM_META_BLOCK_SIZE ((u32)8)
#define XMEM_8META_ENABLE 0
#define XMEM_SUPERBLOCK_LIST_COUNT 3
#else
#define XMEM_META_BLOCK_SIZE ((u32)4)
#define XMEM_8META_ENABLE 1
#if XMEM_8META_ENABLE
#define XMEM_SUPERBLOCK_LIST_COUNT 4
#else
#define XMEM_SUPERBLOCK_LIST_COUNT 3
#endif
#endif
#define XMEM_BALLANCE_SIZE (XMEM_META_BLOCK_SIZE*4)
/******************************************************************************************
* on 32-bit cpu, xMemMgrHdr requires 8 bytes, xMemBlock requires 16 bytes, to manage a
* block will spend 24 bytes for a header
*
* on 64-bit cpu, xMemMgrHdr requires 12 bytes, xMemBlock requires 24 bytes, to manage a
* block will spend 36 bytes for a header
*
* ballance size determined waste size when a free block lager than requrired
*******************************************************************************************/
#define XMEM_2META_BLOCK_SIZE (XMEM_META_BLOCK_SIZE*2)
#define XMEM_4META_BLOCK_SIZE (XMEM_META_BLOCK_SIZE*4)
#define XMEM_8META_BLOCK_SIZE (XMEM_META_BLOCK_SIZE*8)
#define XMEM_SUPERBLOCK_1META_CNT ((u32)16)
#define XMEM_SUPERBLOCK_2META_CNT ((u32)32)
#define XMEM_SUPERBLOCK_4META_CNT ((u32)16)
#define XMEM_SUPERBLOCK_8META_CNT ((u32)16)
#define XMEM_SUPERBLOCK_1META_MIN_SIZE (XMEM_META_BLOCK_SIZE*XMEM_SUPERBLOCK_1META_CNT)
#define XMEM_SUPERBLOCK_2META_MIN_SIZE (XMEM_2META_BLOCK_SIZE*XMEM_SUPERBLOCK_2META_CNT)
#define XMEM_SUPERBLOCK_4META_MIN_SIZE (XMEM_4META_BLOCK_SIZE*XMEM_SUPERBLOCK_4META_CNT)
#define XMEM_SUPERBLOCK_8META_MIN_SIZE (XMEM_8META_BLOCK_SIZE*XMEM_SUPERBLOCK_8META_CNT)
#endif // __XCONFIG_H__
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/chzfmx/xmem.git
git@gitee.com:chzfmx/xmem.git
chzfmx
xmem
xmem
master

搜索帮助