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

Subversion Repositories scarts

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 jlechner
/* sbrk.c -- allocate memory dynamically.
2
 *
3
 * Copyright (c) 2002 Red Hat, Inc
4
 *
5
 * The authors hereby grant permission to use, copy, modify, distribute,
6
 * and license this software and its documentation for any purpose, provided
7
 * that existing copyright notices are retained in all copies and that this
8
 * notice is included verbatim in any distributions. No written agreement,
9
 * license, or royalty fee is required for any of the authorized uses.
10
 * Modifications to this software may be copyrighted by their authors
11
 * and need not follow the licensing terms described here, provided that
12
 * the new terms are clearly indicated on the first page of each file where
13
 * they apply.
14
 */
15
#include <errno.h>
16
#include "glue.h"
17
 
18
/* just in case, most boards have at least some memory */
19
#ifndef RAMSIZE
20
#  define RAMSIZE             (caddr_t)0x100000
21
#endif
22
 
23
char *__heap_ptr = (char *)&_end;
24
 
25
/*
26
 * sbrk -- changes heap size size. Get nbytes more
27
 *         RAM. We just increment a pointer in what's
28
 *         left of memory on the board.
29
 */
30
char *
31
_sbrk (nbytes)
32
     int nbytes;
33
{
34
  char *base;
35
  char *sp;
36
 
37
  base = __heap_ptr;
38
  __heap_ptr += nbytes;
39
 
40
  return base;
41
/* FIXME: We really want to make sure we don't run out of RAM, but this
42
 *       isn't very portable.
43
 */
44
#if 0
45
  if ((RAMSIZE - heap_ptr - nbytes) >= 0) {
46
    base = heap_ptr;
47
    heap_ptr += nbytes;
48
    return (base);
49
  } else {
50
    errno = ENOMEM;
51
    return ((char *)-1);
52
  }
53
#endif
54
}

powered by: WebSVN 2.1.0

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