source: trunk/libs/newlib/src/libgloss/m32r/sbrk.c @ 544

Last change on this file since 544 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 795 bytes
RevLine 
[444]1#include <sys/types.h>
2#include <sys/stat.h>
3#include "syscall.h"
4#include "eit.h"
5
6caddr_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}
Note: See TracBrowser for help on using the repository browser.