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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-newlib/] [newlib-1.17.0/] [libgloss/] [m68k/] [cf-sbrk.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 jlechner
/*
2
 * cf-sbrk.c --
3
 *
4
 * Copyright (c) 2006 CodeSourcery Inc
5
 *
6
 * The authors hereby grant permission to use, copy, modify, distribute,
7
 * and license this software and its documentation for any purpose, provided
8
 * that existing copyright notices are retained in all copies and that this
9
 * notice is included verbatim in any distributions. No written agreement,
10
 * license, or royalty fee is required for any of the authorized uses.
11
 * Modifications to this software may be copyrighted by their authors
12
 * and need not follow the licensing terms described here, provided that
13
 * the new terms are clearly indicated on the first page of each file where
14
 * they apply.
15
 */
16
 
17
#include <errno.h>
18
/*
19
 * sbrk -- changes heap size size. Get nbytes more
20
 *         RAM. We just increment a pointer in what's
21
 *         left of memory on the board.
22
 */
23
 
24
extern char __end[] __attribute__ ((aligned (4)));
25
 
26
/* End of heap, if non NULL.  */
27
extern void *__heap_limit;
28
 
29
void *
30
sbrk (int nbytes)
31
{
32
  static char *heap = __end;
33
  char *end = __heap_limit;
34
  char *base = heap;
35
  char *new_heap = heap + nbytes;
36
 
37
  if (!end)
38
    {
39
      /* Use sp - 256 as the heap limit.  */
40
      __asm__ __volatile__ ("move.l %/sp,%0" : "=r"(end));
41
      end -= 256;
42
    }
43
  if (nbytes < 0 || (long)(end - new_heap) < 0)
44
    {
45
      errno = ENOMEM;
46
      return (void *)-1;
47
    }
48
  heap = new_heap;
49
  return base;
50
}

powered by: WebSVN 2.1.0

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