17a84e134Smrg/* Some OS-dependent utility code */ 27a84e134Smrg 37a84e134Smrg#ifdef HAVE_CONFIG_H 47a84e134Smrg#include <config.h> 57a84e134Smrg#endif 67a84e134Smrg#include <X11/Xosdefs.h> 77a84e134Smrg#include <X11/IntrinsicP.h> 87a84e134Smrg#include "Private.h" 97a84e134Smrg 10c8571806Smrg#ifdef HAVE_UNISTD_H 117a84e134Smrg#include <unistd.h> /* for sysconf(), and getpagesize() */ 127a84e134Smrg#endif 137a84e134Smrg 145ec34c4cSmrg#if defined(_WIN32) && !defined(__CYGWIN__) 155ec34c4cSmrg/* AC_CHECK_FUNCS([getpagesize]) may report a false positive for 165ec34c4cSmrg getpagesize() when using MinGW gcc, since it's present in libgcc.a */ 175ec34c4cSmrg#undef HAVE_GETPAGESIZE 185ec34c4cSmrg#endif 195ec34c4cSmrg 207a84e134Smrg#if defined(linux) 217a84e134Smrg/* kernel header doesn't work with -ansi */ 227a84e134Smrg/* #include <asm/page.h> *//* for PAGE_SIZE */ 237a84e134Smrg#define HAS_SC_PAGESIZE /* _SC_PAGESIZE may be an enum for Linux */ 247a84e134Smrg#endif 257a84e134Smrg 267a84e134Smrgint 27ab902922Smrg_XawGetPageSize(void) 287a84e134Smrg{ 297a84e134Smrg static int pagesize = -1; 307a84e134Smrg 317a84e134Smrg if (pagesize != -1) 327a84e134Smrg return pagesize; 337a84e134Smrg 347a84e134Smrg /* Try each supported method in the preferred order */ 357a84e134Smrg 367a84e134Smrg#if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE) 375ec34c4cSmrg pagesize = (int) sysconf(_SC_PAGESIZE); 387a84e134Smrg#endif 397a84e134Smrg 407a84e134Smrg#ifdef _SC_PAGE_SIZE 417a84e134Smrg if (pagesize == -1) 425ec34c4cSmrg pagesize = (int) sysconf(_SC_PAGE_SIZE); 437a84e134Smrg#endif 447a84e134Smrg 45f353fbadSmrg#ifdef HAVE_GETPAGESIZE 467a84e134Smrg if (pagesize == -1) 477a84e134Smrg pagesize = getpagesize(); 487a84e134Smrg#endif 497a84e134Smrg 507a84e134Smrg#ifdef PAGE_SIZE 517a84e134Smrg if (pagesize == -1) 527a84e134Smrg pagesize = PAGE_SIZE; 537a84e134Smrg#endif 547a84e134Smrg 557a84e134Smrg if (pagesize == -1) 567a84e134Smrg pagesize = 0; 577a84e134Smrg 587a84e134Smrg return pagesize; 597a84e134Smrg} 60