133965Sjdp/* Emulation of getpagesize() for systems that need it. */ 233965Sjdp 333965Sjdp/* 433965Sjdp 589857Sobrien@deftypefn Supplemental int getpagesize (void) 633965Sjdp 789857SobrienReturns the number of bytes in a page of memory. This is the 889857Sobriengranularity of many of the system memory management routines. No 989857Sobrienguarantee is made as to whether or not it is the same as the basic 1089857Sobrienmemory management hardware page size. 1133965Sjdp 1289857Sobrien@end deftypefn 1333965Sjdp 1433965SjdpBUGS 1533965Sjdp 1633965Sjdp Is intended as a reasonable replacement for systems where this 1733965Sjdp is not provided as a system call. The value of 4096 may or may 1833965Sjdp not be correct for the systems where it is returned as the default 1933965Sjdp value. 2033965Sjdp 2133965Sjdp*/ 2233965Sjdp 2333965Sjdp#ifndef VMS 2433965Sjdp 2560484Sobrien#include "config.h" 2660484Sobrien 2733965Sjdp#include <sys/types.h> 2860484Sobrien#ifdef HAVE_SYS_PARAM_H 2933965Sjdp#include <sys/param.h> 3033965Sjdp#endif 3133965Sjdp 3260484Sobrien#undef GNU_OUR_PAGESIZE 3360484Sobrien#if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H) 3433965Sjdp#include <unistd.h> 3560484Sobrien#ifdef _SC_PAGESIZE 3633965Sjdp#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE) 3760484Sobrien#endif 3860484Sobrien#endif 3933965Sjdp 4060484Sobrien#ifndef GNU_OUR_PAGESIZE 4160484Sobrien# ifdef PAGESIZE 4260484Sobrien# define GNU_OUR_PAGESIZE PAGESIZE 4360484Sobrien# else /* no PAGESIZE */ 4460484Sobrien# ifdef EXEC_PAGESIZE 4560484Sobrien# define GNU_OUR_PAGESIZE EXEC_PAGESIZE 4660484Sobrien# else /* no EXEC_PAGESIZE */ 4760484Sobrien# ifdef NBPG 4860484Sobrien# define GNU_OUR_PAGESIZE (NBPG * CLSIZE) 4960484Sobrien# ifndef CLSIZE 5060484Sobrien# define CLSIZE 1 5160484Sobrien# endif /* CLSIZE */ 5260484Sobrien# else /* no NBPG */ 5360484Sobrien# ifdef NBPC 5460484Sobrien# define GNU_OUR_PAGESIZE NBPC 5560484Sobrien# else /* no NBPC */ 5660484Sobrien# define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */ 5760484Sobrien# endif /* NBPC */ 5860484Sobrien# endif /* NBPG */ 5960484Sobrien# endif /* EXEC_PAGESIZE */ 6060484Sobrien# endif /* PAGESIZE */ 6160484Sobrien#endif /* GNU_OUR_PAGESIZE */ 6260484Sobrien 6333965Sjdpint 64218822Sdimgetpagesize (void) 6533965Sjdp{ 6633965Sjdp return (GNU_OUR_PAGESIZE); 6733965Sjdp} 6833965Sjdp 6933965Sjdp#else /* VMS */ 7033965Sjdp 7133965Sjdp#if 0 /* older distributions of gcc-vms are missing <syidef.h> */ 7233965Sjdp#include <syidef.h> 7333965Sjdp#endif 7433965Sjdp#ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */ 7533965Sjdp#define SYI$_PAGE_SIZE 4452 7633965Sjdp#endif 7733965Sjdpextern unsigned long lib$getsyi(const unsigned short *,...); 7833965Sjdp 79218822Sdimint getpagesize (void) 8033965Sjdp{ 8133965Sjdp long pagsiz = 0L; 8233965Sjdp unsigned short itmcod = SYI$_PAGE_SIZE; 8333965Sjdp 8433965Sjdp (void) lib$getsyi (&itmcod, (void *) &pagsiz); 8533965Sjdp if (pagsiz == 0L) 8633965Sjdp pagsiz = 512L; /* VAX default */ 8733965Sjdp return (int) pagsiz; 8833965Sjdp} 8933965Sjdp 9033965Sjdp#endif /* VMS */ 91