mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 07:28:38 +08:00
Compare commits
2 commits
ba15ff173d
...
610348a38f
Author | SHA1 | Date | |
---|---|---|---|
|
610348a38f | ||
|
0f70c44b4a |
2 changed files with 39 additions and 3 deletions
|
@ -69,6 +69,14 @@ config MM_DEFAULT_ALIGNMENT
|
|||
memory default alignment is equal to sizoef(uintptr), if this value
|
||||
is not 0, this value must be 2^n and at least sizeof(uintptr).
|
||||
|
||||
config MM_NODE_PENDING
|
||||
bool "Enable pending memory node"
|
||||
default n
|
||||
---help---
|
||||
Pending memory block node precding and the entire struct,
|
||||
After turning on this bit, the size of each memory block
|
||||
will be aligned to MM_ALIGN
|
||||
|
||||
config MM_SMALL
|
||||
bool "Small memory model"
|
||||
default n
|
||||
|
|
|
@ -143,7 +143,17 @@
|
|||
* previous freenode
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_MM_NODE_PENDING
|
||||
# define MM_NODE_STRUCT_PENDING aligned_data(MM_ALIGN)
|
||||
#else
|
||||
# define MM_NODE_STRUCT_PENDING
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MM_NODE_PENDING
|
||||
# define MM_ALLOCNODE_OVERHEAD (MM_SIZEOF_ALLOCNODE - MM_ALIGN)
|
||||
#else
|
||||
# define MM_ALLOCNODE_OVERHEAD (MM_SIZEOF_ALLOCNODE - sizeof(mmsize_t))
|
||||
#endif
|
||||
|
||||
/* Get the node size */
|
||||
|
||||
|
@ -172,8 +182,17 @@ typedef size_t mmsize_t;
|
|||
/* This describes an allocated chunk */
|
||||
|
||||
struct mm_allocnode_s
|
||||
{
|
||||
#ifdef CONFIG_MM_NODE_PENDING
|
||||
union
|
||||
{
|
||||
mmsize_t preceding; /* Physical preceding chunk size */
|
||||
uint8_t align[MM_ALIGN];
|
||||
};
|
||||
#else
|
||||
mmsize_t preceding; /* Physical preceding chunk size */
|
||||
#endif
|
||||
|
||||
mmsize_t size; /* Size of this chunk */
|
||||
#if CONFIG_MM_BACKTRACE >= 0
|
||||
pid_t pid; /* The pid for caller */
|
||||
|
@ -182,13 +201,22 @@ struct mm_allocnode_s
|
|||
FAR void *backtrace[CONFIG_MM_BACKTRACE]; /* The backtrace buffer for caller */
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
}MM_NODE_STRUCT_PENDING;
|
||||
|
||||
/* This describes a free chunk */
|
||||
|
||||
struct mm_freenode_s
|
||||
{
|
||||
#ifdef CONFIG_MM_NODE_PENDING
|
||||
union
|
||||
{
|
||||
mmsize_t preceding; /* Physical preceding chunk size */
|
||||
uint8_t align[MM_ALIGN];
|
||||
};
|
||||
#else
|
||||
mmsize_t preceding; /* Physical preceding chunk size */
|
||||
#endif
|
||||
|
||||
mmsize_t size; /* Size of this chunk */
|
||||
#if CONFIG_MM_BACKTRACE >= 0
|
||||
pid_t pid; /* The pid for caller */
|
||||
|
@ -199,7 +227,7 @@ struct mm_freenode_s
|
|||
#endif
|
||||
FAR struct mm_freenode_s *flink; /* Supports a doubly linked list */
|
||||
FAR struct mm_freenode_s *blink;
|
||||
};
|
||||
}MM_NODE_STRUCT_PENDING;
|
||||
|
||||
static_assert(MM_SIZEOF_ALLOCNODE <= MM_MIN_CHUNK,
|
||||
"Error size for struct mm_allocnode_s\n");
|
||||
|
|
Loading…
Reference in a new issue