mvalloc.c

Go to the documentation of this file.
00001 /* @(#)root/clib:$Id: mvalloc.c 31230 2009-11-17 13:39:14Z brun $ */
00002 /* Author: */
00003 
00004 /* Allocate memory on a page boundary.
00005    Copyright (C) 1991 Free Software Foundation, Inc.
00006 
00007 The GNU C Library is free software; you can redistribute it and/or
00008 modify it under the terms of the GNU Library General Public License as
00009 published by the Free Software Foundation; either version 2 of the
00010 License, or (at your option) any later version.
00011 
00012 The GNU C Library is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 Library General Public License for more details.
00016 
00017 You should have received a copy of the GNU Library General Public
00018 License along with the GNU C Library; see the file COPYING.LIB.  If
00019 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020 Boston, MA 02111-1307, USA.  */
00021 
00022 #include "mmprivate.h"
00023 
00024 #ifndef WIN32
00025 #  include <unistd.h>
00026 #endif
00027 
00028 #ifdef __CYGWIN__
00029 #include <cygwin/version.h>
00030 #endif /* __CYGWIN__ */
00031 
00032 #if defined(R__LINUX) && !defined(R__GLIBC) && !defined(__CYGWIN__) \
00033    || (defined(__CYGWIN__) && (CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR < 213))
00034 extern size_t getpagesize PARAMS ((void));
00035 #else
00036 extern int getpagesize PARAMS ((void));
00037 #endif
00038 
00039 #ifdef VMS
00040 #undef _SC_PAGE_SIZE
00041 #undef _SC_PAGESIZE
00042 #endif
00043 
00044 /* Cache the pagesize for the current host machine.  Note that if the host
00045    does not readily provide a getpagesize() function, we need to emulate it
00046    elsewhere, not clutter up this file with lots of kluges to try to figure
00047    it out. */
00048 
00049 static size_t pagesize;
00050 
00051 PTR
00052 mvalloc (md, size)
00053   PTR md;
00054   size_t size;
00055 {
00056   if (pagesize == 0)
00057     {
00058 #ifdef _SC_PAGE_SIZE
00059       pagesize = sysconf(_SC_PAGE_SIZE);
00060 #else
00061 # ifdef _SC_PAGESIZE
00062       pagesize = sysconf(_SC_PAGESIZE);
00063 # else
00064       pagesize = getpagesize();
00065 # endif
00066 #endif
00067     }
00068 
00069   return (mmemalign (md, pagesize, size));
00070 }
00071 
00072 #ifndef NO_SBRK_MALLOC
00073 
00074 PTR
00075 valloc (size)
00076   size_t size;
00077 {
00078   return mvalloc ((PTR) NULL, size);
00079 }
00080 
00081 #endif
00082 

Generated on Tue Jul 5 14:11:25 2011 for ROOT_528-00b_version by  doxygen 1.5.1