1*0afa8e06SEd Maste /* Placed in the public domain */ 2*0afa8e06SEd Maste 3*0afa8e06SEd Maste #include "openbsd-compat.h" 4*0afa8e06SEd Maste 5*0afa8e06SEd Maste #if !defined(HAVE_GETPAGESIZE) 6*0afa8e06SEd Maste 7*0afa8e06SEd Maste #ifdef HAVE_UNISTD_H 8*0afa8e06SEd Maste #include <unistd.h> 9*0afa8e06SEd Maste #endif 10*0afa8e06SEd Maste #include <limits.h> 11*0afa8e06SEd Maste 12*0afa8e06SEd Maste int getpagesize(void)13*0afa8e06SEd Mastegetpagesize(void) 14*0afa8e06SEd Maste { 15*0afa8e06SEd Maste #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) 16*0afa8e06SEd Maste long r = sysconf(_SC_PAGESIZE); 17*0afa8e06SEd Maste if (r > 0 && r < INT_MAX) 18*0afa8e06SEd Maste return (int)r; 19*0afa8e06SEd Maste #endif 20*0afa8e06SEd Maste /* 21*0afa8e06SEd Maste * This is at the lower end of common values and appropriate for 22*0afa8e06SEd Maste * our current use of getpagesize() in recallocarray(). 23*0afa8e06SEd Maste */ 24*0afa8e06SEd Maste return 4096; 25*0afa8e06SEd Maste } 26*0afa8e06SEd Maste 27*0afa8e06SEd Maste #endif /* !defined(HAVE_GETPAGESIZE) */ 28