source: trunk/libs/newlib/src/libgloss/v850/sbrk.c @ 444

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

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

File size: 568 bytes
Line 
1#include <_ansi.h>
2#include <sys/types.h>
3#include <sys/stat.h>
4#include "sys/syscall.h"
5
6caddr_t
7_sbrk (int incr)
8{
9  extern char   heap_start[];           /* Defined by the linker script. */
10  static char * heap_end = NULL;
11  char *        prev_heap_end;
12  char *        sp = (char *) & sp;
13
14  if (heap_end == NULL)
15    heap_end = heap_start;
16
17  prev_heap_end = heap_end;
18
19  if (heap_end + incr > sp)
20    {
21#define MESSAGE "Heap and stack collision\n"
22      _write (1, MESSAGE, sizeof MESSAGE);
23      abort ();
24    }
25
26  heap_end += incr;
27
28  return (caddr_t) prev_heap_end;
29}
Note: See TracBrowser for help on using the repository browser.