Coverage Report

Created: 2025-07-01 06:25

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