mm: Unified memory management alignment length
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
parent
da845163a3
commit
b27dc9ee7f
3 changed files with 8 additions and 12 deletions
|
@ -41,16 +41,10 @@
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if CONFIG_MM_DEFAULT_ALIGNMENT == 0
|
|
||||||
# define MEMPOOL_ALIGN (2 * sizeof(uintptr_t))
|
|
||||||
#else
|
|
||||||
# define MEMPOOL_ALIGN CONFIG_MM_DEFAULT_ALIGNMENT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_MM_BACKTRACE >= 0
|
#if CONFIG_MM_BACKTRACE >= 0
|
||||||
# define MEMPOOL_REALBLOCKSIZE(pool) (ALIGN_UP((pool)->blocksize + \
|
# define MEMPOOL_REALBLOCKSIZE(pool) (ALIGN_UP((pool)->blocksize + \
|
||||||
sizeof(struct mempool_backtrace_s), \
|
sizeof(struct mempool_backtrace_s), \
|
||||||
MEMPOOL_ALIGN))
|
MM_ALIGN))
|
||||||
#else
|
#else
|
||||||
# define MEMPOOL_REALBLOCKSIZE(pool) ((pool)->blocksize)
|
# define MEMPOOL_REALBLOCKSIZE(pool) ((pool)->blocksize)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -156,6 +156,12 @@
|
||||||
# define MM_DUMP_LEAK(dump,pid) (false)
|
# define MM_DUMP_LEAK(dump,pid) (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_MM_DEFAULT_ALIGNMENT == 0
|
||||||
|
# define MM_ALIGN (2 * sizeof(uintptr_t))
|
||||||
|
#else
|
||||||
|
# define MM_ALIGN CONFIG_MM_DEFAULT_ALIGNMENT
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MM_INIT_MAGIC 0xcc
|
#define MM_INIT_MAGIC 0xcc
|
||||||
#define MM_ALLOC_MAGIC 0xaa
|
#define MM_ALLOC_MAGIC 0xaa
|
||||||
#define MM_FREE_MAGIC 0x55
|
#define MM_FREE_MAGIC 0x55
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <nuttx/fs/procfs.h>
|
#include <nuttx/fs/procfs.h>
|
||||||
#include <nuttx/lib/math32.h>
|
#include <nuttx/lib/math32.h>
|
||||||
#include <nuttx/mm/mempool.h>
|
#include <nuttx/mm/mempool.h>
|
||||||
|
#include <nuttx/mm/mm.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -114,11 +115,6 @@
|
||||||
#define MM_MAX_CHUNK (1 << MM_MAX_SHIFT)
|
#define MM_MAX_CHUNK (1 << MM_MAX_SHIFT)
|
||||||
#define MM_NNODES (MM_MAX_SHIFT - MM_MIN_SHIFT + 1)
|
#define MM_NNODES (MM_MAX_SHIFT - MM_MIN_SHIFT + 1)
|
||||||
|
|
||||||
#if CONFIG_MM_DEFAULT_ALIGNMENT == 0
|
|
||||||
# define MM_ALIGN (2 * sizeof(uintptr_t))
|
|
||||||
#else
|
|
||||||
# define MM_ALIGN CONFIG_MM_DEFAULT_ALIGNMENT
|
|
||||||
#endif
|
|
||||||
#define MM_GRAN_MASK (MM_ALIGN - 1)
|
#define MM_GRAN_MASK (MM_ALIGN - 1)
|
||||||
#define MM_ALIGN_UP(a) (((a) + MM_GRAN_MASK) & ~MM_GRAN_MASK)
|
#define MM_ALIGN_UP(a) (((a) + MM_GRAN_MASK) & ~MM_GRAN_MASK)
|
||||||
#define MM_ALIGN_DOWN(a) ((a) & ~MM_GRAN_MASK)
|
#define MM_ALIGN_DOWN(a) ((a) & ~MM_GRAN_MASK)
|
||||||
|
|
Loading…
Reference in a new issue