From b29d6b44781be7d15ddef908ec0068dce4bd467e Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Fri, 17 Feb 2023 11:11:31 -0300 Subject: [PATCH] _sbrk in TI --- examples/ti/ek-tm4c1294xl-baremetal/syscalls.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c b/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c index 49312476..ff2a9a2e 100644 --- a/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c +++ b/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c @@ -12,8 +12,11 @@ void *_sbrk(int incr) { extern char _end; static unsigned char *heap = NULL; unsigned char *prev_heap; + unsigned char x = 0, *heap_end = (unsigned char *)((size_t) &x - 512); + (void) x; if (heap == NULL) heap = (unsigned char *) &_end; prev_heap = heap; + if (heap + incr > heap_end) return (void *) -1; heap += incr; return prev_heap; }