fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libgloss / frv / sbrk.c
blob469257d5a1277b82d51ea9f4c44f806267ab96ee
1 /* sbrk.c -- allocate memory dynamically.
2 *
3 * Copyright (c) 2002 Red Hat, Inc
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.
15 #include <errno.h>
16 #include "glue.h"
18 /* just in case, most boards have at least some memory */
19 #ifndef RAMSIZE
20 # define RAMSIZE (caddr_t)0x100000
21 #endif
23 char *__heap_ptr = (char *)&_end;
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.
30 char *
31 _sbrk (nbytes)
32 int nbytes;
34 char *base;
35 char *sp;
37 base = __heap_ptr;
38 __heap_ptr += nbytes;
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.
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);
53 #endif