Back to index

glibc  2.9
brk.c
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 1994, 1995, 1997 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
00004      On-Line Applications Research Corporation.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <stdlib.h>
00022 
00023 void *__curbrk;
00024 void *__rorig;
00025 void *__rlimit;
00026 
00027 int
00028 __brk (inaddr)
00029      void *inaddr;
00030 {
00031 
00032   if ( ( (void *)inaddr > (void *)__rlimit ) ||
00033                         ( (void *)inaddr < (void *)__rorig ) )
00034     return -1;
00035 
00036   __curbrk = inaddr;
00037   return 0;
00038 }
00039 
00040 /* Initialization Code for Memory Allocation */
00041 
00042 void *__C_heap_start;
00043 int __C_heap_size;
00044 
00045 #ifdef HAVE_GNU_LD
00046 static
00047 #endif
00048 void
00049 __NONE_set_memvals (argc, argv, envp)
00050      int argc;
00051      char **argv;
00052      char **envp;
00053 {
00054 
00055   __rorig  =
00056   __curbrk = __C_heap_start;
00057   __rlimit = __curbrk + __C_heap_size;
00058 
00059   (void) &__NONE_set_memvals;    /* Avoid "defined but not used" warning.  */
00060 }
00061 
00062 #ifdef  HAVE_GNU_LD
00063 text_set_element (__libc_subinit, __NONE_set_memvals);
00064 #endif
00065 
00066 weak_alias (__brk, brk)