Cygwin: pinfo: raise MAX_PID to 4194304
[newlib-cygwin.git] / libgloss / v850 / sbrk.c
blob65114b0b7829ffb290d20f20bd284d686e1f07fe
1 #include <_ansi.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include "sys/syscall.h"
5 #include <stdlib.h>
7 extern int _write (int, char *, int);
9 caddr_t
10 _sbrk (int incr)
12 extern char heap_start[]; /* Defined by the linker script. */
13 static char * heap_end = NULL;
14 char * prev_heap_end;
15 char * sp = (char *) & sp;
17 if (heap_end == NULL)
18 heap_end = heap_start;
20 prev_heap_end = heap_end;
22 if (heap_end + incr > sp)
24 #define MESSAGE "Heap and stack collision\n"
25 _write (1, MESSAGE, sizeof MESSAGE);
26 abort ();
29 heap_end += incr;
31 return (caddr_t) prev_heap_end;