]> sourceware.org Git - newlib-cygwin.git/blob - libgloss/m32r/sbrk.c
20000317 sourceware import
[newlib-cygwin.git] / libgloss / m32r / sbrk.c
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include "syscall.h"
4 #include "eit.h"
5
6 caddr_t
7 _sbrk (int incr)
8 {
9 /* `_end' is defined in the linker script.
10 We must handle it carefully as we don't want the compiler to think
11 it lives in the small data area. Use medium model to ensure 32 bit
12 addressability. */
13 extern char _end __attribute__ ((__model__(__medium__)));
14 static char *heap_end;
15 char *prev_heap_end;
16 char *sp = (char *)&sp;
17
18 if (heap_end == 0)
19 {
20 heap_end = &_end;
21 }
22 prev_heap_end = heap_end;
23 if (heap_end > sp)
24 {
25 _write (1, "Heap and stack collision\n", 25);
26 #if 0 /* Calling abort brings in the signal handling code. */
27 abort ();
28 #else
29 exit (1);
30 #endif
31 }
32 heap_end += incr;
33 return (caddr_t) prev_heap_end;
34 }
This page took 0.034856 seconds and 5 git commands to generate.