freebsd-dev/contrib/libfido2/openbsd-compat/bsd-getpagesize.c
Ed Maste 0afa8e065e Import libfido2 at 'contrib/libfido2/'
git-subtree-dir: contrib/libfido2
git-subtree-mainline: d586c978b9
git-subtree-split: a58dee945a
2021-10-06 21:29:18 -04:00

28 lines
513 B
C

/* Placed in the public domain */
#include "openbsd-compat.h"
#if !defined(HAVE_GETPAGESIZE)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <limits.h>
int
getpagesize(void)
{
#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
long r = sysconf(_SC_PAGESIZE);
if (r > 0 && r < INT_MAX)
return (int)r;
#endif
/*
* This is at the lower end of common values and appropriate for
* our current use of getpagesize() in recallocarray().
*/
return 4096;
}
#endif /* !defined(HAVE_GETPAGESIZE) */