summaryrefslogtreecommitdiff
path: root/nuttx/mm
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-02-21 21:55:16 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-02-21 21:55:16 +0000
commitefc2cf23a849f7be1d65c4cdd7767f88917c46a7 (patch)
treefbe3518a364d6b9d811e00f7201e082d50ead7e3 /nuttx/mm
parent94e5b72f50f3096b83fe50c7b57324a08e318f29 (diff)
downloadpx4-nuttx-efc2cf23a849f7be1d65c4cdd7767f88917c46a7.tar.gz
px4-nuttx-efc2cf23a849f7be1d65c4cdd7767f88917c46a7.tar.bz2
px4-nuttx-efc2cf23a849f7be1d65c4cdd7767f88917c46a7.zip
Progress toward clean SDCC compilation
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@18 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/mm')
-rw-r--r--nuttx/mm/Makefile7
-rw-r--r--nuttx/mm/mm_environment.h4
-rw-r--r--nuttx/mm/mm_initialize.c6
-rw-r--r--nuttx/mm/mm_internal.h42
-rw-r--r--nuttx/mm/mm_mallinfo.c6
-rw-r--r--nuttx/mm/mm_malloc.c2
-rw-r--r--nuttx/mm/mm_memalign.c18
-rw-r--r--nuttx/mm/mm_realloc.c12
-rw-r--r--nuttx/mm/mm_shrinkchunk.c2
-rw-r--r--nuttx/mm/mm_size2ndx.c2
-rw-r--r--nuttx/mm/mm_test.c1
11 files changed, 59 insertions, 43 deletions
diff --git a/nuttx/mm/Makefile b/nuttx/mm/Makefile
index 79460a34a..ce32beea5 100644
--- a/nuttx/mm/Makefile
+++ b/nuttx/mm/Makefile
@@ -47,7 +47,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-BIN = libmm.a
+BIN = libmm$(LIBEXT)
all: $(BIN)
@@ -58,7 +58,10 @@ $(COBJS): %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS)
- $(AR) rcs $@ $(OBJS)
+ ( for obj in $(OBJS) ; do \
+ $(AR) $@ $${obj} || \
+ { echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
+ done ; )
.depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
diff --git a/nuttx/mm/mm_environment.h b/nuttx/mm/mm_environment.h
index 15f692486..8d4816bd0 100644
--- a/nuttx/mm/mm_environment.h
+++ b/nuttx/mm/mm_environment.h
@@ -69,10 +69,6 @@
#ifdef MM_TEST
-/* Standard types */
-
-typedef unsigned int uint32;
-
/* Use the real system errno */
# define mm_errno errno
diff --git a/nuttx/mm/mm_initialize.c b/nuttx/mm/mm_initialize.c
index a16ac9b0e..4bf24a70b 100644
--- a/nuttx/mm/mm_initialize.c
+++ b/nuttx/mm/mm_initialize.c
@@ -50,7 +50,7 @@
/* This is the size of the heap provided to mm */
-uint32 g_heapsize;
+size_t g_heapsize;
/* This is the first and last nodes of the heap */
@@ -97,8 +97,8 @@ void mm_initialize(void *heapstart, size_t heapsize)
* both aligned with the MM_MIN_CHUNK size.
*/
- uint32 heapbase = MM_ALIGN_UP((uint32)heapstart);
- uint32 heapend = MM_ALIGN_DOWN((uint32)heapstart + (uint32)heapsize);
+ size_t heapbase = MM_ALIGN_UP((size_t)heapstart);
+ size_t heapend = MM_ALIGN_DOWN((size_t)heapstart + (size_t)heapsize);
/* Save the size of the heap */
diff --git a/nuttx/mm/mm_internal.h b/nuttx/mm/mm_internal.h
index fe519ab2e..27c9f1f3b 100644
--- a/nuttx/mm/mm_internal.h
+++ b/nuttx/mm/mm_internal.h
@@ -61,8 +61,13 @@
* losses.
*/
-#define MM_MIN_SHIFT 4 /* 16 bytes */
-#define MM_MAX_SHIFT 22 /* 4 Mb */
+#ifdef CONFIG_SMALL_MEMORY
+# define MM_MIN_SHIFT 4 /* 16 bytes */
+# define MM_MAX_SHIFT 15 /* 32 Kb */
+#else
+# define MM_MIN_SHIFT 4 /* 16 bytes */
+# define MM_MAX_SHIFT 22 /* 4 Mb */
+#endif
/* All other definitions derive from these two */
@@ -79,7 +84,11 @@
* an allocated chunk.
*/
-#define MM_ALLOC_BIT 0x80000000
+#ifdef CONFIG_SMALL_MEMORY
+# define MM_ALLOC_BIT 0x8000
+#else
+# define MM_ALLOC_BIT 0x80000000
+#endif
#define MM_IS_ALLOCATED(n) \
((int)((struct mm_allocnode_s*)(n)->preceding) < 0))
@@ -94,11 +103,16 @@
struct mm_allocnode_s
{
- uint32 size; /* Size of this chunk */
- uint32 preceding; /* Size of the preceding chunk */
+ size_t size; /* Size of this chunk */
+ size_t preceding; /* Size of the preceding chunk */
};
-#define SIZEOF_MM_ALLOCNODE 8
+#ifdef CONFIG_SMALL_MEMORY
+# define SIZEOF_MM_ALLOCNODE 4
+#else
+# define SIZEOF_MM_ALLOCNODE 8
+#endif
+
#define CHECK_ALLOCNODE_SIZE \
DEBUGASSERT(sizeof(struct mm_allocnode_s) == SIZEOF_MM_ALLOCNODE)
@@ -106,13 +120,17 @@ struct mm_allocnode_s
struct mm_freenode_s
{
- uint32 size; /* Size of this chunk */
- uint32 preceding; /* Size of the preceding chunk */
+ size_t size; /* Size of this chunk */
+ size_t preceding; /* Size of the preceding chunk */
struct mm_freenode_s *flink; /* Supports a doubly linked list */
struct mm_freenode_s *blink;
};
-#define SIZEOF_MM_FREENODE 16
+#ifdef CONFIG_SMALL_MEMORY
+# define SIZEOF_MM_FREENODE 10
+#else
+# define SIZEOF_MM_FREENODE 16
+#endif
#define CHECK_FREENODE_SIZE \
DEBUGASSERT(sizeof(struct mm_freenode_s) == SIZEOF_MM_FREENODE)
@@ -138,7 +156,7 @@ struct mallinfo
/* This is the size of the heap provided to mm */
-extern uint32 g_heapsize;
+extern size_t g_heapsize;
/* This is the first and last nodes of the heap */
@@ -168,9 +186,9 @@ extern struct mm_freenode_s g_nodelist[MM_NNODES];
extern struct mallinfo mallinfo(void);
#endif
-extern void mm_shrinkchunk(struct mm_allocnode_s *node, uint32 size);
+extern void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size);
extern void mm_addfreechunk(struct mm_freenode_s *node);
-extern int mm_size2ndx(uint32 size);
+extern int mm_size2ndx(size_t size);
extern void mm_seminitialize(void);
extern void mm_takesemaphore(void);
extern void mm_givesemaphore(void);
diff --git a/nuttx/mm/mm_mallinfo.c b/nuttx/mm/mm_mallinfo.c
index 7b242b4ea..4aba9770c 100644
--- a/nuttx/mm/mm_mallinfo.c
+++ b/nuttx/mm/mm_mallinfo.c
@@ -69,10 +69,10 @@ struct mallinfo mallinfo(void)
{
static struct mallinfo stats;
struct mm_allocnode_s *node;
- uint32 mxordblk = 0;
+ size_t mxordblk = 0;
int ordblks = 0; /* Number of non-inuse chunks */
- uint32 uordblks = 0; /* Total allocated space */
- uint32 fordblks = 0; /* Total non-inuse space */
+ size_t uordblks = 0; /* Total allocated space */
+ size_t fordblks = 0; /* Total non-inuse space */
/* Visit each node in physical memory */
diff --git a/nuttx/mm/mm_malloc.c b/nuttx/mm/mm_malloc.c
index 222aca3b2..80a89222b 100644
--- a/nuttx/mm/mm_malloc.c
+++ b/nuttx/mm/mm_malloc.c
@@ -144,7 +144,7 @@ void *malloc(size_t size)
{
struct mm_freenode_s *remainder;
struct mm_freenode_s *next;
- uint32 remaining;
+ size_t remaining;
/* Remove the node. There must be a predecessor, but there may
* not be a successor node.
diff --git a/nuttx/mm/mm_memalign.c b/nuttx/mm/mm_memalign.c
index 18f3b295a..1f5c07727 100644
--- a/nuttx/mm/mm_memalign.c
+++ b/nuttx/mm/mm_memalign.c
@@ -66,10 +66,10 @@
void *memalign(size_t alignment, size_t size)
{
struct mm_allocnode_s *node;
- uint32 rawchunk;
- uint32 alignedchunk;
- uint32 mask = (uint32)(alignment - 1);
- uint32 allocsize;
+ size_t rawchunk;
+ size_t alignedchunk;
+ size_t mask = (size_t)(alignment - 1);
+ size_t allocsize;
/* If this requested alignement less than or equal to the
* natural alignment of malloc, then just let malloc do the
@@ -99,7 +99,7 @@ void *memalign(size_t alignment, size_t size)
/* Then malloc that size */
- rawchunk = (uint32)malloc(allocsize);
+ rawchunk = (size_t)malloc(allocsize);
if (!rawchunk)
{
return NULL;
@@ -127,7 +127,7 @@ void *memalign(size_t alignment, size_t size)
{
struct mm_allocnode_s *newnode;
struct mm_allocnode_s *next;
- uint32 precedingsize;
+ size_t precedingsize;
/* Get the node the next node after the allocation. */
@@ -145,7 +145,7 @@ void *memalign(size_t alignment, size_t size)
* SIZEOF_MM_ALLOCNODE
*/
- precedingsize = (uint32)newnode - (uint32)node;
+ precedingsize = (size_t)newnode - (size_t)node;
/* If we were unlucky, then the alignedchunk can lie in such
* a position that precedingsize < SIZEOF_NODE_FREENODE. We
@@ -159,12 +159,12 @@ void *memalign(size_t alignment, size_t size)
{
alignedchunk += alignment;
newnode = (struct mm_allocnode_s*)(alignedchunk - SIZEOF_MM_ALLOCNODE);
- precedingsize = (uint32)newnode - (uint32)node;
+ precedingsize = (size_t)newnode - (size_t)node;
}
/* Set up the size of the new node */
- newnode->size = (uint32)next - (uint32)newnode;
+ newnode->size = (size_t)next - (size_t)newnode;
newnode->preceding = precedingsize | MM_ALLOC_BIT;
/* Reduce the size of the original chunk and mark it not allocated, */
diff --git a/nuttx/mm/mm_realloc.c b/nuttx/mm/mm_realloc.c
index 01836de60..b288e880a 100644
--- a/nuttx/mm/mm_realloc.c
+++ b/nuttx/mm/mm_realloc.c
@@ -78,9 +78,9 @@ void *realloc(void *oldmem, size_t size)
struct mm_allocnode_s *oldnode;
struct mm_freenode_s *prev;
struct mm_freenode_s *next;
- uint32 oldsize;
- uint32 prevsize = 0;
- uint32 nextsize = 0;
+ size_t oldsize;
+ size_t prevsize = 0;
+ size_t nextsize = 0;
/* If oldmem is NULL, then realloc is equivalent to malloc */
@@ -145,9 +145,9 @@ void *realloc(void *oldmem, size_t size)
if (nextsize + prevsize + oldsize >= size)
{
- uint32 needed = size - oldsize;
- uint32 takeprev;
- uint32 takenext;
+ size_t needed = size - oldsize;
+ size_t takeprev;
+ size_t takenext;
/* Check if we can extend into the previous chunk and if the
* previous chunk is smaller than the next chunk.
diff --git a/nuttx/mm/mm_shrinkchunk.c b/nuttx/mm/mm_shrinkchunk.c
index daf57c707..8869f045c 100644
--- a/nuttx/mm/mm_shrinkchunk.c
+++ b/nuttx/mm/mm_shrinkchunk.c
@@ -64,7 +64,7 @@
*
************************************************************/
-void mm_shrinkchunk(struct mm_allocnode_s *node, uint32 size)
+void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size)
{
struct mm_freenode_s *next;
diff --git a/nuttx/mm/mm_size2ndx.c b/nuttx/mm/mm_size2ndx.c
index 271e3e221..416652e03 100644
--- a/nuttx/mm/mm_size2ndx.c
+++ b/nuttx/mm/mm_size2ndx.c
@@ -50,7 +50,7 @@
/* Convert the size to a nodelist index */
-int mm_size2ndx(uint32 size)
+int mm_size2ndx(size_t size)
{
int ndx = 0;
diff --git a/nuttx/mm/mm_test.c b/nuttx/mm/mm_test.c
index 86861121a..779fd607c 100644
--- a/nuttx/mm/mm_test.c
+++ b/nuttx/mm/mm_test.c
@@ -37,7 +37,6 @@
#include <stdlib.h>
#include <string.h>
-typedef unsigned int uint32;
#include "mm_internal.h"
/* Definitions */