OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [m32r/] [sbrk.c] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
#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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.