nsprpub/pr/src/md/prosdep.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "prbit.h"
michael@0 7 #include "prsystem.h"
michael@0 8
michael@0 9 #ifdef XP_UNIX
michael@0 10 #include <unistd.h>
michael@0 11 #endif
michael@0 12 #ifdef _WIN32
michael@0 13 #include <windows.h>
michael@0 14 #endif
michael@0 15 #ifdef XP_BEOS
michael@0 16 #include <OS.h>
michael@0 17 #endif
michael@0 18
michael@0 19 PRInt32 _pr_pageShift;
michael@0 20 PRInt32 _pr_pageSize;
michael@0 21
michael@0 22 /*
michael@0 23 ** Get system page size
michael@0 24 */
michael@0 25 static void GetPageSize(void)
michael@0 26 {
michael@0 27 PRInt32 pageSize;
michael@0 28
michael@0 29 /* Get page size */
michael@0 30 #ifdef XP_UNIX
michael@0 31 #if defined BSDI || defined AIX \
michael@0 32 || defined LINUX || defined __GNU__ || defined __GLIBC__ \
michael@0 33 || defined FREEBSD || defined NETBSD || defined OPENBSD \
michael@0 34 || defined DARWIN || defined SYMBIAN
michael@0 35 _pr_pageSize = getpagesize();
michael@0 36 #elif defined(HPUX)
michael@0 37 /* I have no idea. Don't get me started. --Rob */
michael@0 38 _pr_pageSize = sysconf(_SC_PAGE_SIZE);
michael@0 39 #else
michael@0 40 _pr_pageSize = sysconf(_SC_PAGESIZE);
michael@0 41 #endif
michael@0 42 #endif /* XP_UNIX */
michael@0 43
michael@0 44 #ifdef XP_BEOS
michael@0 45 _pr_pageSize = B_PAGE_SIZE;
michael@0 46 #endif
michael@0 47
michael@0 48 #ifdef XP_PC
michael@0 49 #ifdef _WIN32
michael@0 50 SYSTEM_INFO info;
michael@0 51 GetSystemInfo(&info);
michael@0 52 _pr_pageSize = info.dwPageSize;
michael@0 53 #else
michael@0 54 _pr_pageSize = 4096;
michael@0 55 #endif
michael@0 56 #endif /* XP_PC */
michael@0 57
michael@0 58 pageSize = _pr_pageSize;
michael@0 59 PR_CEILING_LOG2(_pr_pageShift, pageSize);
michael@0 60 }
michael@0 61
michael@0 62 PR_IMPLEMENT(PRInt32) PR_GetPageShift(void)
michael@0 63 {
michael@0 64 if (!_pr_pageSize) {
michael@0 65 GetPageSize();
michael@0 66 }
michael@0 67 return _pr_pageShift;
michael@0 68 }
michael@0 69
michael@0 70 PR_IMPLEMENT(PRInt32) PR_GetPageSize(void)
michael@0 71 {
michael@0 72 if (!_pr_pageSize) {
michael@0 73 GetPageSize();
michael@0 74 }
michael@0 75 return _pr_pageSize;
michael@0 76 }

mercurial