Last change
on this file since 573 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.5 KB
|
Rev | Line | |
---|
[444] | 1 | /* sbrk.c -- allocate memory dynamically. |
---|
| 2 | * |
---|
| 3 | * Copyright (c) 1995,1996 Cygnus Support |
---|
| 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; |
---|
| 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 | |
---|
| 36 | if (!heap_ptr) |
---|
| 37 | heap_ptr = (char *)&_end; |
---|
| 38 | base = heap_ptr; |
---|
| 39 | heap_ptr += nbytes; |
---|
| 40 | |
---|
| 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. |
---|
| 44 | */ |
---|
| 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); |
---|
| 53 | } |
---|
| 54 | #endif |
---|
| 55 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.