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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 148 jeremybenn
#include <_ansi.h>
2
#include <errno.h>
3
#include <sys/types.h>
4
#include <sys/stat.h>
5
#include "trap.h"
6
 
7
 
8
caddr_t
9
_sbrk (size_t incr)
10
{
11
  extern char __stack;       /* Defined by the linker */
12
  extern char _end;             /* Defined by the linker */
13
  static char *heap_end;
14
  char *prev_heap_end;
15
  char *sp = (char *)&sp;
16
 
17
  if (heap_end == 0)
18
    {
19
      heap_end = &_end;
20
    }
21
  prev_heap_end = heap_end;
22
  heap_end += incr;
23
  if (heap_end > sp)
24
    {
25
      _write (1, "Heap and stack collision\n", 25);
26
      errno = ENOMEM;
27
      return (caddr_t)-1;
28
    }
29
  return (caddr_t) prev_heap_end;
30
}

powered by: WebSVN 2.1.0

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