Changes for 4.5.0 snapshot
[newlib-cygwin.git] / libgloss / mn10300 / sbrk.c
blob78945e77ae259843d97f278b1bd91dc3c4a396e7
1 #include <_ansi.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <stdlib.h>
5 #include "trap.h"
7 extern int _write (int, char *, size_t);
10 caddr_t
11 _sbrk (size_t incr)
13 extern char end; /* Defined by the linker */
14 static char *heap_end;
15 char *prev_heap_end;
16 #if 0
17 char *sp = (char *)stack_ptr;
18 #else
19 char *sp = (char *)&sp;
20 #endif
22 if (heap_end == 0)
24 heap_end = &end;
26 prev_heap_end = heap_end;
27 heap_end += incr;
28 if (heap_end > sp)
30 _write (1, "Heap and stack collision\n", 25);
31 abort ();
33 return (caddr_t) prev_heap_end;