9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 515727833e8a5e5b317c6c8c69ee44b407731353
parent a30e70312e15e8231024c34df2db245bb98201f8
Author: Roberto Vargas <roberto.vargas@arm.com>
Date:   Fri,  8 Mar 2019 11:00:21 +0000

Merge branch 'master' of ssh://gerrit.oss.arm.com/trusted-firmware/rcode

Change-Id: I28f72b419ac0c297ab59e1374388997a5377169b

Diffstat:
Mtarget/hosted/rom.c | 11++++++++++-
Mtarget/native/rom.c | 20+++++++++++++++++++-
2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/target/hosted/rom.c b/target/hosted/rom.c @@ -23,7 +23,16 @@ frame(void) void * alloc(size_t size) { - void * p; + static int lock; + void *p; + + if (size == 0) { + lock = 1; + return NULL; + } + + if (lock) + panic("alloc"); if ((p = malloc(size)) == NULL) panic("alloc"); diff --git a/target/native/rom.c b/target/native/rom.c @@ -14,6 +14,7 @@ #define ENVSIZ (sizeof(struct _Env) + ENVPOS*sizeof(char *)) #define BSSSIZ 2048 #define STACKSIZ 1024 +#define HEAPSIZ 1024 typedef struct mach Mach; @@ -43,7 +44,24 @@ getenviron(void) void * alloc(size_t size) { - return NULL; + static char heap[HEAPSIZ]; + static char *base = heap; + static int lock; + char *bp; + + if (size == 0) { + lock = 1; + return NULL; + } + + if (lock) + panic("alloc"); + + bp = base; + if (&bp[size] > &heap[HEAPSIZ]) + return NULL; + base += size; + return bp; } static void