summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdk-stage1/dietlibc/lib/alloc.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/mdk-stage1/dietlibc/lib/alloc.c b/mdk-stage1/dietlibc/lib/alloc.c
index a2b3b73a1..9643913a6 100644
--- a/mdk-stage1/dietlibc/lib/alloc.c
+++ b/mdk-stage1/dietlibc/lib/alloc.c
@@ -44,14 +44,17 @@ typedef union {
/* a simple mmap :) */
-#ifdef __i386__
/* regparm exists only on i386 */
-static void *do_mmap(size_t size) __attribute__((regparm(1)));
-static size_t get_index(size_t _size) __attribute__((regparm(1)));
-static void* __small_malloc(size_t _size) __attribute__((regparm(1)));
+#ifdef __i386__
+#define REGPARM(n) __attribute__((regparm(n)))
+#else
+#define REGPARM(n)
#endif
+static size_t REGPARM(1) get_index(size_t _size);
+static void* REGPARM(1) __small_malloc(size_t _size);
+
-static void *do_mmap(size_t size) {
+static void REGPARM(1) *do_mmap(size_t size) {
return mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, (size_t)0);
}
@@ -70,7 +73,7 @@ static __alloc_t* __small_mem[8];
static inline int __ind_shift() { return (MEM_BLOCK_SIZE==4096)?4:5; }
-static size_t get_index(size_t _size) {
+static size_t REGPARM(1) get_index(size_t _size) {
register size_t idx=0;
if (_size) {
register size_t size=((_size-1)&(MEM_BLOCK_SIZE-1))>>__ind_shift();
@@ -80,9 +83,8 @@ static size_t get_index(size_t _size) {
}
/* small mem */
-static void __small_free(void*_ptr,size_t _size) __attribute__((regparm(2)));
-static void __small_free(void*_ptr,size_t _size) {
+static void REGPARM(2) __small_free(void*_ptr,size_t _size) {
__alloc_t* ptr=BLOCK_START(_ptr);
size_t size=_size;
size_t idx=get_index(size);
@@ -93,7 +95,7 @@ static void __small_free(void*_ptr,size_t _size) {
__small_mem[idx]=ptr;
}
-static void* __small_malloc(size_t _size) {
+static void* REGPARM(1) __small_malloc(size_t _size) {
__alloc_t *ptr;
size_t size=_size;
size_t idx;