Skip to content

Commit b27dc9e

Browse files
W-M-Rxiaoxiang781216
authored andcommitted
mm: Unified memory management alignment length
Signed-off-by: wangmingrong1 <[email protected]>
1 parent da84516 commit b27dc9e

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

include/nuttx/mm/mempool.h

+1-7
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,10 @@
4141
* Pre-processor Definitions
4242
****************************************************************************/
4343

44-
#if CONFIG_MM_DEFAULT_ALIGNMENT == 0
45-
# define MEMPOOL_ALIGN (2 * sizeof(uintptr_t))
46-
#else
47-
# define MEMPOOL_ALIGN CONFIG_MM_DEFAULT_ALIGNMENT
48-
#endif
49-
5044
#if CONFIG_MM_BACKTRACE >= 0
5145
# define MEMPOOL_REALBLOCKSIZE(pool) (ALIGN_UP((pool)->blocksize + \
5246
sizeof(struct mempool_backtrace_s), \
53-
MEMPOOL_ALIGN))
47+
MM_ALIGN))
5448
#else
5549
# define MEMPOOL_REALBLOCKSIZE(pool) ((pool)->blocksize)
5650
#endif

include/nuttx/mm/mm.h

+6
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@
156156
# define MM_DUMP_LEAK(dump,pid) (false)
157157
#endif
158158

159+
#if CONFIG_MM_DEFAULT_ALIGNMENT == 0
160+
# define MM_ALIGN (2 * sizeof(uintptr_t))
161+
#else
162+
# define MM_ALIGN CONFIG_MM_DEFAULT_ALIGNMENT
163+
#endif
164+
159165
#define MM_INIT_MAGIC 0xcc
160166
#define MM_ALLOC_MAGIC 0xaa
161167
#define MM_FREE_MAGIC 0x55

mm/mm_heap/mm.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <nuttx/fs/procfs.h>
3535
#include <nuttx/lib/math32.h>
3636
#include <nuttx/mm/mempool.h>
37+
#include <nuttx/mm/mm.h>
3738

3839
#include <assert.h>
3940
#include <sys/types.h>
@@ -114,11 +115,6 @@
114115
#define MM_MAX_CHUNK (1 << MM_MAX_SHIFT)
115116
#define MM_NNODES (MM_MAX_SHIFT - MM_MIN_SHIFT + 1)
116117

117-
#if CONFIG_MM_DEFAULT_ALIGNMENT == 0
118-
# define MM_ALIGN (2 * sizeof(uintptr_t))
119-
#else
120-
# define MM_ALIGN CONFIG_MM_DEFAULT_ALIGNMENT
121-
#endif
122118
#define MM_GRAN_MASK (MM_ALIGN - 1)
123119
#define MM_ALIGN_UP(a) (((a) + MM_GRAN_MASK) & ~MM_GRAN_MASK)
124120
#define MM_ALIGN_DOWN(a) ((a) & ~MM_GRAN_MASK)

0 commit comments

Comments
 (0)