diff options
-rw-r--r-- | libmaple/syscalls.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libmaple/syscalls.c b/libmaple/syscalls.c index a3f12f1..9193a17 100644 --- a/libmaple/syscalls.c +++ b/libmaple/syscalls.c @@ -29,12 +29,17 @@ #include <sys/stat.h> #include <errno.h> -/* Set by the linker */ +/* If CONFIG_HEAP_START (or CONFIG_HEAP_END) isn't defined, then + * assume _lm_heap_start (resp. _lm_heap_end) is appropriately set by + * the linker */ +#ifndef CONFIG_HEAP_START extern char _lm_heap_start; +#define CONFIG_HEAP_START ((caddr_t)&_lm_heap_start) +#endif +#ifndef CONFIG_HEAP_END extern char _lm_heap_end; - -#define HEAP_START ((caddr_t)&_lm_heap_start) -#define HEAP_END ((caddr_t)&_lm_heap_end) +#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end) +#endif /* * _sbrk -- Increment the program break. @@ -47,10 +52,11 @@ caddr_t _sbrk(int incr) { caddr_t ret; if (pbreak == NULL) { - pbreak = HEAP_START; + pbreak = CONFIG_HEAP_START; } - if ((HEAP_END - pbreak < incr) || (pbreak - HEAP_START < -incr)) { + if ((CONFIG_HEAP_END - pbreak < incr) || + (pbreak - CONFIG_HEAP_START < -incr)) { errno = ENOMEM; return (caddr_t)-1; } |