Cygwin: setpriority, sched_setparam: add missing process access right
[newlib-cygwin.git] / libgloss / m32r / sbrk.c
blob92a9b60a1b593cf0e0f34016d5cb7013b37efbfc
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include "syscall.h"
4 #include "eit.h"
5 #include <stdlib.h>
8 extern int _write (int, char *, int);
10 caddr_t
11 _sbrk (int incr)
13 /* `_end' is defined in the linker script.
14 We must handle it carefully as we don't want the compiler to think
15 it lives in the small data area. Use medium model to ensure 32 bit
16 addressability. */
17 extern char _end __attribute__ ((__model__(__medium__)));
18 static char *heap_end;
19 char *prev_heap_end;
20 char *sp = (char *)&sp;
22 if (heap_end == 0)
24 heap_end = &_end;
26 prev_heap_end = heap_end;
27 if (heap_end > sp)
29 _write (1, "Heap and stack collision\n", 25);
30 #if 0 /* Calling abort brings in the signal handling code. */
31 abort ();
32 #else
33 exit (1);
34 #endif
36 heap_end += incr;
37 return (caddr_t) prev_heap_end;