| 1 |
/* Some OS-dependent utility code */ |
| 2 |
|
| 3 |
#ifdef HAVE_CONFIG_H |
| 4 |
#include <config.h> |
| 5 |
#endif |
| 6 |
#include <X11/Xosdefs.h> |
| 7 |
#include <X11/IntrinsicP.h> |
| 8 |
#include "Private.h" |
| 9 |
|
| 10 |
#ifdef HAVE_UNISTD_H |
| 11 |
#include <unistd.h> /* for sysconf(), and getpagesize() */ |
| 12 |
#endif |
| 13 |
|
| 14 |
#if defined(_WIN32) && !defined(__CYGWIN__) |
| 15 |
/* AC_CHECK_FUNCS([getpagesize]) may report a false positive for |
| 16 |
getpagesize() when using MinGW gcc, since it's present in libgcc.a */ |
| 17 |
#undef HAVE_GETPAGESIZE |
| 18 |
#endif |
| 19 |
|
| 20 |
#if defined(linux) |
| 21 |
/* kernel header doesn't work with -ansi */ |
| 22 |
/* #include <asm/page.h> *//* for PAGE_SIZE */ |
| 23 |
#define HAS_SC_PAGESIZE /* _SC_PAGESIZE may be an enum for Linux */ |
| 24 |
#endif |
| 25 |
|
| 26 |
int |
| 27 |
_XawGetPageSize(void) |
| 28 |
{ |
| 29 |
static int pagesize = -1; |
| 30 |
|
| 31 |
if (pagesize != -1) |
| 32 |
return pagesize; |
| 33 |
|
| 34 |
/* Try each supported method in the preferred order */ |
| 35 |
|
| 36 |
#if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE) |
| 37 |
pagesize = (int) sysconf(_SC_PAGESIZE); |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifdef _SC_PAGE_SIZE |
| 41 |
if (pagesize == -1) |
| 42 |
pagesize = (int) sysconf(_SC_PAGE_SIZE); |
| 43 |
#endif |
| 44 |
|
| 45 |
#ifdef HAVE_GETPAGESIZE |
| 46 |
if (pagesize == -1) |
| 47 |
pagesize = getpagesize(); |
| 48 |
#endif |
| 49 |
|
| 50 |
#ifdef PAGE_SIZE |
| 51 |
if (pagesize == -1) |
| 52 |
pagesize = PAGE_SIZE; |
| 53 |
#endif |
| 54 |
|
| 55 |
if (pagesize == -1) |
| 56 |
pagesize = 0; |
| 57 |
|
| 58 |
return pagesize; |
| 59 |
} |