From b2db0ebcfe5ade4a1db755bca5112400a69be288 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 17 Jan 2002 16:39:53 +0000 Subject: _sbrk(): Return -1 rather than aborting if too much memory is requested. --- newlib/libc/sys/arm/syscalls.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'newlib/libc/sys/arm/syscalls.c') diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c index 795f7784d..0483d4893 100644 --- a/newlib/libc/sys/arm/syscalls.c +++ b/newlib/libc/sys/arm/syscalls.c @@ -470,8 +470,6 @@ _getpid (int n) n = n; } -extern void abort (void); - caddr_t _sbrk (int incr) { @@ -486,8 +484,18 @@ _sbrk (int incr) if (heap_end + incr > stack_ptr) { + /* Some of the libstdc++-v3 tests rely upon detecting + out of memory errors, so do not abort here. */ +#if 0 + extern void abort (void); + _write (1, "_sbrk: Heap and stack collision\n", 32); + abort (); +#else + errno = ENOMEM; + return -1; +#endif } heap_end += incr; -- cgit v1.2.3