OS.c revision f353fbad
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 107a84e134Smrg#ifndef X_NOT_POSIX 117a84e134Smrg#include <unistd.h> /* for sysconf(), and getpagesize() */ 127a84e134Smrg#endif 137a84e134Smrg 147a84e134Smrg#if defined(linux) 157a84e134Smrg/* kernel header doesn't work with -ansi */ 167a84e134Smrg/* #include <asm/page.h> *//* for PAGE_SIZE */ 177a84e134Smrg#define HAS_SC_PAGESIZE /* _SC_PAGESIZE may be an enum for Linux */ 187a84e134Smrg#endif 197a84e134Smrg 207a84e134Smrgint 21ab902922Smrg_XawGetPageSize(void) 227a84e134Smrg{ 237a84e134Smrg static int pagesize = -1; 247a84e134Smrg 257a84e134Smrg if (pagesize != -1) 267a84e134Smrg return pagesize; 277a84e134Smrg 287a84e134Smrg /* Try each supported method in the preferred order */ 297a84e134Smrg 307a84e134Smrg#if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE) 317a84e134Smrg pagesize = sysconf(_SC_PAGESIZE); 327a84e134Smrg#endif 337a84e134Smrg 347a84e134Smrg#ifdef _SC_PAGE_SIZE 357a84e134Smrg if (pagesize == -1) 367a84e134Smrg pagesize = sysconf(_SC_PAGE_SIZE); 377a84e134Smrg#endif 387a84e134Smrg 39f353fbadSmrg#ifdef HAVE_GETPAGESIZE 407a84e134Smrg if (pagesize == -1) 417a84e134Smrg pagesize = getpagesize(); 427a84e134Smrg#endif 437a84e134Smrg 447a84e134Smrg#ifdef PAGE_SIZE 457a84e134Smrg if (pagesize == -1) 467a84e134Smrg pagesize = PAGE_SIZE; 477a84e134Smrg#endif 487a84e134Smrg 497a84e134Smrg if (pagesize == -1) 507a84e134Smrg pagesize = 0; 517a84e134Smrg 527a84e134Smrg return pagesize; 537a84e134Smrg} 54