bsd-getpagesize.c 463 B

1234567891011121314151617181920212223242526
  1. /* Placed in the public domain */
  2. #include "includes.h"
  3. #ifndef HAVE_GETPAGESIZE
  4. #include <unistd.h>
  5. #include <limits.h>
  6. int
  7. getpagesize(void)
  8. {
  9. #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
  10. long r = sysconf(_SC_PAGESIZE);
  11. if (r > 0 && r < INT_MAX)
  12. return (int)r;
  13. #endif
  14. /*
  15. * This is at the lower end of common values and appropriate for
  16. * our current use of getpagesize() in recallocarray().
  17. */
  18. return 4096;
  19. }
  20. #endif /* HAVE_GETPAGESIZE */