fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / libgloss / iq2000 / sbrk.c
blob6dfd93b0236740594c7477a065b4b5cad33ca41c
1 #include <_ansi.h>
2 #include <errno.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include "trap.h"
8 caddr_t
9 _sbrk (size_t incr)
11 extern char __stack; /* Defined by the linker */
12 extern char _end; /* Defined by the linker */
13 static char *heap_end;
14 char *prev_heap_end;
15 char *sp = (char *)&sp;
17 if (heap_end == 0)
19 heap_end = &_end;
21 prev_heap_end = heap_end;
22 heap_end += incr;
23 if (heap_end > sp)
25 _write (1, "Heap and stack collision\n", 25);
26 errno = ENOMEM;
27 return (caddr_t)-1;
29 return (caddr_t) prev_heap_end;