andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: #include "prbit.h" andre@0: #include "prsystem.h" andre@0: andre@0: #ifdef XP_UNIX andre@0: #include andre@0: #endif andre@0: #ifdef _WIN32 andre@0: #include andre@0: #endif andre@0: #ifdef XP_BEOS andre@0: #include andre@0: #endif andre@0: andre@0: PRInt32 _pr_pageShift; andre@0: PRInt32 _pr_pageSize; andre@0: andre@0: /* andre@0: ** Get system page size andre@0: */ andre@0: static void GetPageSize(void) andre@0: { andre@0: PRInt32 pageSize; andre@0: andre@0: /* Get page size */ andre@0: #ifdef XP_UNIX andre@0: #if defined BSDI || defined AIX \ andre@0: || defined LINUX || defined __GNU__ || defined __GLIBC__ \ andre@0: || defined FREEBSD || defined NETBSD || defined OPENBSD \ andre@0: || defined DARWIN || defined SYMBIAN andre@0: _pr_pageSize = getpagesize(); andre@0: #elif defined(HPUX) andre@0: /* I have no idea. Don't get me started. --Rob */ andre@0: _pr_pageSize = sysconf(_SC_PAGE_SIZE); andre@0: #else andre@0: _pr_pageSize = sysconf(_SC_PAGESIZE); andre@0: #endif andre@0: #endif /* XP_UNIX */ andre@0: andre@0: #ifdef XP_BEOS andre@0: _pr_pageSize = B_PAGE_SIZE; andre@0: #endif andre@0: andre@0: #ifdef XP_PC andre@0: #ifdef _WIN32 andre@0: SYSTEM_INFO info; andre@0: GetSystemInfo(&info); andre@0: _pr_pageSize = info.dwPageSize; andre@0: #else andre@0: _pr_pageSize = 4096; andre@0: #endif andre@0: #endif /* XP_PC */ andre@0: andre@0: pageSize = _pr_pageSize; andre@0: PR_CEILING_LOG2(_pr_pageShift, pageSize); andre@0: } andre@0: andre@0: PR_IMPLEMENT(PRInt32) PR_GetPageShift(void) andre@0: { andre@0: if (!_pr_pageSize) { andre@0: GetPageSize(); andre@0: } andre@0: return _pr_pageShift; andre@0: } andre@0: andre@0: PR_IMPLEMENT(PRInt32) PR_GetPageSize(void) andre@0: { andre@0: if (!_pr_pageSize) { andre@0: GetPageSize(); andre@0: } andre@0: return _pr_pageSize; andre@0: }