From: dtrg Date: Fri, 6 Aug 2010 17:06:31 +0000 (+0000) Subject: Changed to actually work. (On modern Linux systems the old version just X-Git-Tag: release-6-0-pre-5~57 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a0c67da261dd3777bcd73461e485cc2c9a33602d;p=ack.git Changed to actually work. (On modern Linux systems the old version just crashes. On old Linux systems it apparently only worked by accident.) --- diff --git a/plat/linux386/libsys/sbrk.c b/plat/linux386/libsys/sbrk.c index 121de9aee..1b66460a8 100644 --- a/plat/linux386/libsys/sbrk.c +++ b/plat/linux386/libsys/sbrk.c @@ -9,23 +9,27 @@ #define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ -extern char _end[1]; - -static char* current = _end; +static char* current = NULL; void* sbrk(intptr_t increment) { char* old; char* new; + char* actual; + if (!current) + current = (char*) _syscall(__NR_brk, 0, 0, 0); + if (increment == 0) return current; old = current; new = old + increment; - if (brk(new) < 0) + + actual = (char*) _syscall(__NR_brk, (quad) new, 0, 0); + if (actual < new) return OUT_OF_MEMORY; - current = new; + current = actual; return old; }