home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / malloc / valloc.c < prev   
Encoding:
C/C++ Source or Header  |  1993-12-20  |  1.7 KB  |  65 lines

  1. /* Allocate memory on a page boundary.
  2.    Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  3.  
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.
  18.  
  19.    The author may be reached (Email) at the address mike@ai.mit.edu,
  20.    or (US mail) as Mike Haertel c/o Free Software Foundation.  */
  21.  
  22. #ifndef    _MALLOC_INTERNAL
  23. #define    _MALLOC_INTERNAL
  24. #include <malloc.h>
  25. #endif
  26.  
  27. #ifdef     emacs
  28. #include "config.h"
  29. #endif
  30.  
  31. #ifdef    __GNU_LIBRARY__
  32. extern size_t __getpagesize __P ((void));
  33. #else
  34. #ifndef    USG
  35. extern size_t getpagesize __P ((void));
  36. #define    __getpagesize()    getpagesize()
  37. #else
  38. #include <sys/param.h>
  39. #ifdef    EXEC_PAGESIZE
  40. #define    __getpagesize()    EXEC_PAGESIZE
  41. #else /* No EXEC_PAGESIZE.  */
  42. #ifdef    NBPG
  43. #ifndef    CLSIZE
  44. #define    CLSIZE    1
  45. #endif /* No CLSIZE.  */
  46. #define    __getpagesize()    (NBPG * CLSIZE)
  47. #else /* No NBPG.  */
  48. #define    __getpagesize()    NBPC
  49. #endif /* NBPG.  */
  50. #endif /* EXEC_PAGESIZE.  */
  51. #endif /* USG.  */
  52. #endif
  53.  
  54. static size_t pagesize;
  55.  
  56. __ptr_t
  57. valloc (size)
  58.      size_t size;
  59. {
  60.   if (pagesize == 0)
  61.     pagesize = __getpagesize ();
  62.  
  63.   return memalign (pagesize, size);
  64. }
  65.