100bf4279Sespie /* Emulation of getpagesize() for systems that need it. */ 200bf4279Sespie 300bf4279Sespie /* 400bf4279Sespie 59588ddcfSespie @deftypefn Supplemental int getpagesize (void) 600bf4279Sespie 700bf4279Sespie Returns the number of bytes in a page of memory. This is the 89588ddcfSespie granularity of many of the system memory management routines. No 99588ddcfSespie guarantee is made as to whether or not it is the same as the basic 109588ddcfSespie memory management hardware page size. 119588ddcfSespie 129588ddcfSespie @end deftypefn 1300bf4279Sespie 1400bf4279Sespie BUGS 1500bf4279Sespie 1600bf4279Sespie Is intended as a reasonable replacement for systems where this 1700bf4279Sespie is not provided as a system call. The value of 4096 may or may 1800bf4279Sespie not be correct for the systems where it is returned as the default 1900bf4279Sespie value. 2000bf4279Sespie 2100bf4279Sespie */ 2200bf4279Sespie 2300bf4279Sespie #ifndef VMS 2400bf4279Sespie 2500bf4279Sespie #include "config.h" 2600bf4279Sespie 2700bf4279Sespie #include <sys/types.h> 2800bf4279Sespie #ifdef HAVE_SYS_PARAM_H 2900bf4279Sespie #include <sys/param.h> 3000bf4279Sespie #endif 3100bf4279Sespie 3200bf4279Sespie #undef GNU_OUR_PAGESIZE 3300bf4279Sespie #if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H) 3400bf4279Sespie #include <unistd.h> 3500bf4279Sespie #ifdef _SC_PAGESIZE 3600bf4279Sespie #define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE) 3700bf4279Sespie #endif 3800bf4279Sespie #endif 3900bf4279Sespie 4000bf4279Sespie #ifndef GNU_OUR_PAGESIZE 4100bf4279Sespie # ifdef PAGESIZE 4200bf4279Sespie # define GNU_OUR_PAGESIZE PAGESIZE 4300bf4279Sespie # else /* no PAGESIZE */ 4400bf4279Sespie # ifdef EXEC_PAGESIZE 4500bf4279Sespie # define GNU_OUR_PAGESIZE EXEC_PAGESIZE 4600bf4279Sespie # else /* no EXEC_PAGESIZE */ 4700bf4279Sespie # ifdef NBPG 4800bf4279Sespie # define GNU_OUR_PAGESIZE (NBPG * CLSIZE) 4900bf4279Sespie # ifndef CLSIZE 5000bf4279Sespie # define CLSIZE 1 5100bf4279Sespie # endif /* CLSIZE */ 5200bf4279Sespie # else /* no NBPG */ 5300bf4279Sespie # ifdef NBPC 5400bf4279Sespie # define GNU_OUR_PAGESIZE NBPC 5500bf4279Sespie # else /* no NBPC */ 5600bf4279Sespie # define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */ 5700bf4279Sespie # endif /* NBPC */ 5800bf4279Sespie # endif /* NBPG */ 5900bf4279Sespie # endif /* EXEC_PAGESIZE */ 6000bf4279Sespie # endif /* PAGESIZE */ 6100bf4279Sespie #endif /* GNU_OUR_PAGESIZE */ 6200bf4279Sespie 6300bf4279Sespie int getpagesize(void)64*20fce977Smiodgetpagesize (void) 6500bf4279Sespie { 6600bf4279Sespie return (GNU_OUR_PAGESIZE); 6700bf4279Sespie } 6800bf4279Sespie 6900bf4279Sespie #else /* VMS */ 7000bf4279Sespie 7100bf4279Sespie #if 0 /* older distributions of gcc-vms are missing <syidef.h> */ 7200bf4279Sespie #include <syidef.h> 7300bf4279Sespie #endif 7400bf4279Sespie #ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */ 7500bf4279Sespie #define SYI$_PAGE_SIZE 4452 7600bf4279Sespie #endif 7700bf4279Sespie extern unsigned long lib$getsyi(const unsigned short *,...); 7800bf4279Sespie getpagesize(void)79*20fce977Smiodint getpagesize (void) 8000bf4279Sespie { 8100bf4279Sespie long pagsiz = 0L; 8200bf4279Sespie unsigned short itmcod = SYI$_PAGE_SIZE; 8300bf4279Sespie 8400bf4279Sespie (void) lib$getsyi (&itmcod, (void *) &pagsiz); 8500bf4279Sespie if (pagsiz == 0L) 8600bf4279Sespie pagsiz = 512L; /* VAX default */ 8700bf4279Sespie return (int) pagsiz; 8800bf4279Sespie } 8900bf4279Sespie 9000bf4279Sespie #endif /* VMS */ 91