Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

/projects/cubeos/src_current/libc/sbrk.c

Go to the documentation of this file.
00001 /*  src/libc/sbrk.c
00002    CubeOS Version 0.4.90
00003    Copyright (C) 1999,2000 Holger Kenn
00004 
00005    CubeOS is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or any later version.
00009 
00010    CubeOS is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015  */
00016 /* sbrk.c -- allocate memory dynamically.
00017 
00018  * Copyright (c) 1995,1996 Cygnus Support
00019  *
00020  * The authors hereby grant permission to use, copy, modify, distribute,
00021  * and license this software and its documentation for any purpose, provided
00022  * that existing copyright notices are retained in all copies and that this
00023  * notice is included verbatim in any distributions. No written agreement,
00024  * license, or royalty fee is required for any of the authorized uses.
00025  * Modifications to this software may be copyrighted by their authors
00026  * and need not follow the licensing terms described here, provided that
00027  * the new terms are clearly indicated on the first page of each file where
00028  * they apply.
00029  */
00030 #include <errno.h>
00031 #include "glue.h" // this really needs glue.h. don't remove!
00032 
00033 /* \file sbrk.c
00034 \ingroup LIBC
00035 
00036 This file contains the central interface between the libc memory management
00037 and the cubeOS memory management.
00038 */
00039 
00040 /* just in case, most boards have at least some memory */
00041 #ifndef RAMSIZE
00042 #define RAMSIZE             (caddr_t)0x100000
00043 #endif
00044 
00045 char *heap_ptr; 
00046 
00057 char *sbrk (int nbytes)
00058 {
00059         char *base;
00060 
00061         if (!heap_ptr)
00062                 heap_ptr = (char *) &_end;
00063         base = heap_ptr;
00064         heap_ptr += nbytes;
00065 
00066         return base;
00067 /* FIXME: We really want to make sure we don't run out of RAM, but this
00068  *       isn't very portable.
00069  */
00070 #if 0
00071         if ((RAMSIZE - heap_ptr - nbytes) >= 0) {
00072                 base = heap_ptr;
00073                 heap_ptr += nbytes;
00074                 return (base);
00075         } else {
00076                 errno = ENOMEM;
00077                 return ((char *) -1);
00078         }
00079 #endif
00080 }

Generated on Thu Feb 20 15:38:45 2003 for cubeOS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002