|
|
1.1 ! root 1: /* Emulation of getpagesize() for systems that need it. ! 2: Copyright (C) 1991 Free Software Foundation, Inc. ! 3: ! 4: This file is part of the libiberty library. ! 5: Libiberty is free software; you can redistribute it and/or ! 6: modify it under the terms of the GNU Library General Public ! 7: License as published by the Free Software Foundation; either ! 8: version 2 of the License, or (at your option) any later version. ! 9: ! 10: Libiberty is distributed in the hope that it will be useful, ! 11: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! 13: Library General Public License for more details. ! 14: ! 15: You should have received a copy of the GNU Library General Public ! 16: License along with libiberty; see the file COPYING.LIB. If ! 17: not, write to the Free Software Foundation, Inc., 675 Mass Ave, ! 18: Cambridge, MA 02139, USA. */ ! 19: ! 20: /* ! 21: ! 22: NAME ! 23: ! 24: getpagesize -- return the number of bytes in page of memory ! 25: ! 26: SYNOPSIS ! 27: ! 28: int getpagesize (void) ! 29: ! 30: DESCRIPTION ! 31: ! 32: Returns the number of bytes in a page of memory. This is the ! 33: granularity of many of the system memory management routines. ! 34: No guarantee is made as to whether or not it is the same as the ! 35: basic memory management hardware page size. ! 36: ! 37: BUGS ! 38: ! 39: Is intended as a reasonable replacement for systems where this ! 40: is not provided as a system call. The value of 4096 may or may ! 41: not be correct for the systems where it is returned as the default ! 42: value. ! 43: ! 44: */ ! 45: ! 46: ! 47: #include <sys/types.h> ! 48: #include <sys/param.h> ! 49: ! 50: #ifdef HAVE_SYSCONF ! 51: #include <unistd.h> ! 52: #define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE) ! 53: #else ! 54: #ifdef PAGESIZE ! 55: #define GNU_OUR_PAGESIZE PAGESIZE ! 56: #else /* no PAGESIZE */ ! 57: #ifdef EXEC_PAGESIZE ! 58: #define GNU_OUR_PAGESIZE EXEC_PAGESIZE ! 59: #else /* no EXEC_PAGESIZE */ ! 60: #ifdef NBPG ! 61: #define GNU_OUR_PAGESIZE (NBPG * CLSIZE) ! 62: #ifndef CLSIZE ! 63: #define CLSIZE 1 ! 64: #endif /* CLSIZE */ ! 65: #else /* no NBPG */ ! 66: #ifdef NBPC ! 67: #define GNU_OUR_PAGESIZE NBPC ! 68: #else /* no NBPC */ ! 69: #define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */ ! 70: #endif /* NBPC */ ! 71: #endif /* NBPG */ ! 72: #endif /* EXEC_PAGESIZE */ ! 73: #endif /* PAGESIZE */ ! 74: #endif /* HAVE_SYSCONF */ ! 75: ! 76: int ! 77: getpagesize () ! 78: { ! 79: return (GNU_OUR_PAGESIZE); ! 80: } ! 81:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.