fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libgloss / sbrk.c
blobc222b4bbf2f184c98562df3de24bf751004e1b12
1 /* sbrk.c -- allocate memory dynamically.
2 *
3 * Copyright (c) 1995,1996 Cygnus Support
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;
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;
36 if (!heap_ptr)
37 heap_ptr = (char *)&_end;
38 base = heap_ptr;
39 heap_ptr += nbytes;
41 return base;
42 /* FIXME: We really want to make sure we don't run out of RAM, but this
43 * isn't very portable.
45 #if 0
46 if ((RAMSIZE - heap_ptr - nbytes) >= 0) {
47 base = heap_ptr;
48 heap_ptr += nbytes;
49 return (base);
50 } else {
51 errno = ENOMEM;
52 return ((char *)-1);
54 #endif