home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / src / md / prosdep.c < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.0 KB  |  88 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "prbit.h"
  20. #include "prsystem.h"
  21.  
  22. #if defined(XP_MAC)
  23. #include "prosdep.h"
  24. #else
  25. #include "md/prosdep.h"
  26. #endif
  27.  
  28. #ifdef XP_UNIX
  29. #include <unistd.h>
  30. #endif
  31.  
  32. PRInt32 _pr_pageShift;
  33. PRInt32 _pr_pageSize;
  34.  
  35. /*
  36. ** Get system page size
  37. */
  38. static void GetPageSize(void)
  39. {
  40.     PRInt32 pageSize;
  41.  
  42.     /* Get page size */
  43. #ifdef XP_UNIX
  44. #if defined SUNOS4 || defined LINUX || defined BSDI || defined AIX \
  45.     || defined FREEBSD
  46.     _pr_pageSize = getpagesize();
  47. #elif defined(HPUX)
  48.     /* I have no idea. Don't get me started. --Rob */
  49.     _pr_pageSize = sysconf(_SC_PAGE_SIZE);
  50. #else
  51.     _pr_pageSize = sysconf(_SC_PAGESIZE);
  52. #endif
  53. #endif /* XP_UNIX */
  54.  
  55. #ifdef XP_MAC
  56.     _pr_pageSize = 4096;
  57. #endif /* XP_MAC */
  58.  
  59. #ifdef XP_PC
  60. #ifdef _WIN32
  61.     SYSTEM_INFO info;
  62.     GetSystemInfo(&info);
  63.     _pr_pageSize = info.dwPageSize;
  64. #else
  65.     _pr_pageSize = 4096;
  66. #endif
  67. #endif /* XP_PC */
  68.  
  69.     pageSize = _pr_pageSize;
  70.     PR_CEILING_LOG2(_pr_pageShift, pageSize);
  71. }
  72.  
  73. PR_IMPLEMENT(PRInt32) PR_GetPageShift(void)
  74. {
  75.     if (!_pr_pageSize) {
  76.     GetPageSize();
  77.     }
  78.     return _pr_pageShift;
  79. }
  80.  
  81. PR_IMPLEMENT(PRInt32) PR_GetPageSize(void)
  82. {
  83.     if (!_pr_pageSize) {
  84.     GetPageSize();
  85.     }
  86.     return _pr_pageSize;
  87. }
  88.