Cygwin: Add new APIs tc[gs]etwinsize()
[newlib-cygwin.git] / newlib / libc / sys / h8300hms / sbrk.c
bloba99ae29048b2c6f38faf88fbe41abefbe2224c23
1 #include <_ansi.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <stdlib.h>
6 register char *stack_ptr asm ("sp");
7 extern int _write (int, char *, int);
9 caddr_t
10 _sbrk(incr)
11 int incr;
13 extern char end; /* Defined by the linker */
14 static char *heap_end;
15 char *prev_heap_end;
17 if (heap_end == 0)
19 heap_end = &end;
21 prev_heap_end = heap_end;
22 if (heap_end + incr > stack_ptr)
24 _write (1, "Heap and stack collision\n", 25);
25 abort ();
27 heap_end += incr;
28 return (caddr_t)prev_heap_end;