summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/src/misc/prsystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/src/misc/prsystem.c')
-rw-r--r--nsprpub/pr/src/misc/prsystem.c141
1 files changed, 70 insertions, 71 deletions
diff --git a/nsprpub/pr/src/misc/prsystem.c b/nsprpub/pr/src/misc/prsystem.c
index eba85fb0b..825d3be0f 100644
--- a/nsprpub/pr/src/misc/prsystem.c
+++ b/nsprpub/pr/src/misc/prsystem.c
@@ -8,10 +8,6 @@
#include "prprf.h"
#include "prlong.h"
-#if defined(BEOS)
-#include <kernel/OS.h>
-#endif
-
#if defined(OS2)
#define INCL_DOS
#define INCL_DOSMISC
@@ -71,7 +67,7 @@ PR_IMPLEMENT(char) PR_GetDirectorySepartor(void)
static PRBool warn = PR_TRUE;
if (warn) {
warn = _PR_Obsolete("PR_GetDirectorySepartor()",
- "PR_GetDirectorySeparator()");
+ "PR_GetDirectorySeparator()");
}
#endif
return PR_GetDirectorySeparator();
@@ -86,84 +82,90 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle
{
PRUintn len = 0;
- if (!_pr_initialized) _PR_ImplicitInitialization();
+ if (!_pr_initialized) {
+ _PR_ImplicitInitialization();
+ }
switch(cmd)
{
- case PR_SI_HOSTNAME:
- case PR_SI_HOSTNAME_UNTRUNCATED:
- if (PR_FAILURE == _PR_MD_GETHOSTNAME(buf, (PRUintn)buflen))
- return PR_FAILURE;
+ case PR_SI_HOSTNAME:
+ case PR_SI_HOSTNAME_UNTRUNCATED:
+ if (PR_FAILURE == _PR_MD_GETHOSTNAME(buf, (PRUintn)buflen)) {
+ return PR_FAILURE;
+ }
- if (cmd == PR_SI_HOSTNAME_UNTRUNCATED)
- break;
- /*
- * On some platforms a system does not have a hostname and
- * its IP address is returned instead. The following code
- * should be skipped on those platforms.
- */
+ if (cmd == PR_SI_HOSTNAME_UNTRUNCATED) {
+ break;
+ }
+ /*
+ * On some platforms a system does not have a hostname and
+ * its IP address is returned instead. The following code
+ * should be skipped on those platforms.
+ */
#ifndef _PR_GET_HOST_ADDR_AS_NAME
- /* Return the unqualified hostname */
+ /* Return the unqualified hostname */
while (buf[len] && (len < buflen)) {
if (buf[len] == '.') {
buf[len] = '\0';
break;
}
len += 1;
- }
+ }
#endif
- break;
+ break;
- case PR_SI_SYSNAME:
- /* Return the operating system name */
+ case PR_SI_SYSNAME:
+ /* Return the operating system name */
#if defined(XP_UNIX) || defined(WIN32)
- if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen))
- return PR_FAILURE;
+ if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {
+ return PR_FAILURE;
+ }
#else
- (void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);
+ (void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);
#endif
- break;
+ break;
- case PR_SI_RELEASE:
- /* Return the version of the operating system */
+ case PR_SI_RELEASE:
+ /* Return the version of the operating system */
#if defined(XP_UNIX) || defined(WIN32)
- if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen))
- return PR_FAILURE;
+ if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {
+ return PR_FAILURE;
+ }
#endif
#if defined(XP_OS2)
- {
- ULONG os2ver[2] = {0};
- DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_REVISION,
- &os2ver, sizeof(os2ver));
- /* Formatting for normal usage (2.11, 3.0, 4.0, 4.5); officially,
- Warp 4 is version 2.40.00, WSeB 2.45.00 */
- if (os2ver[0] < 30)
- (void)PR_snprintf(buf, buflen, "%s%lu",
- "2.", os2ver[0]);
- else if (os2ver[0] < 45)
- (void)PR_snprintf(buf, buflen, "%lu%s%lu",
- os2ver[0]/10, ".", os2ver[1]);
- else
- (void)PR_snprintf(buf, buflen, "%.1f",
- os2ver[0]/10.0);
- }
+ {
+ ULONG os2ver[2] = {0};
+ DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_REVISION,
+ &os2ver, sizeof(os2ver));
+ /* Formatting for normal usage (2.11, 3.0, 4.0, 4.5); officially,
+ Warp 4 is version 2.40.00, WSeB 2.45.00 */
+ if (os2ver[0] < 30)
+ (void)PR_snprintf(buf, buflen, "%s%lu",
+ "2.", os2ver[0]);
+ else if (os2ver[0] < 45)
+ (void)PR_snprintf(buf, buflen, "%lu%s%lu",
+ os2ver[0]/10, ".", os2ver[1]);
+ else
+ (void)PR_snprintf(buf, buflen, "%.1f",
+ os2ver[0]/10.0);
+ }
#endif /* OS2 */
- break;
-
- case PR_SI_ARCHITECTURE:
- /* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/
- (void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);
- break;
- default:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
- return PR_FAILURE;
+ break;
+
+ case PR_SI_ARCHITECTURE:
+ /* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/
+ (void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);
+ break;
+ default:
+ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
+ return PR_FAILURE;
}
return PR_SUCCESS;
}
/*
** PR_GetNumberOfProcessors()
-**
+**
** Implementation notes:
** Every platform does it a bit different.
** numCpus is the returned value.
@@ -173,7 +175,7 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle
** order of the if defined()s may be important,
** especially for unix variants. Do platform
** specific implementations before XP_UNIX.
-**
+**
*/
PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors( void )
{
@@ -183,11 +185,6 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors( void )
GetSystemInfo( &info );
numCpus = info.dwNumberOfProcessors;
-#elif defined(BEOS)
- system_info sysInfo;
-
- get_system_info(&sysInfo);
- numCpus = sysInfo.cpu_count;
#elif defined(OS2)
DosQuerySysInfo( QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numCpus, sizeof(numCpus));
#elif defined(_PR_HAVE_SYSCTL)
@@ -208,9 +205,7 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors( void )
numCpus = -1; /* set to -1 for return value on error */
_PR_MD_MAP_DEFAULT_ERROR( _MD_ERRNO() );
}
-#elif defined(IRIX)
- numCpus = sysconf( _SC_NPROC_ONLN );
-#elif defined(RISCOS) || defined(SYMBIAN)
+#elif defined(RISCOS)
numCpus = 1;
#elif defined(LINUX)
/* for the benefit of devices with advanced power-saving, that
@@ -255,14 +250,14 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors( void )
/*
** PR_GetPhysicalMemorySize()
-**
+**
** Implementation notes:
** Every platform does it a bit different.
** bytes is the returned value.
** for each platform's "if defined" section
** declare your local variable
** do your thing, assign to bytes.
-**
+**
*/
PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
{
@@ -272,8 +267,9 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
long pageSize = sysconf(_SC_PAGESIZE);
long pageCount = sysconf(_SC_PHYS_PAGES);
- if (pageSize >= 0 && pageCount >= 0)
+ if (pageSize >= 0 && pageCount >= 0) {
bytes = (PRUint64) pageSize * pageCount;
+ }
#elif defined(NETBSD) || defined(OPENBSD) \
|| defined(FREEBSD) || defined(DRAGONFLY)
@@ -302,8 +298,9 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
struct pst_static info;
int result = pstat_getstatic(&info, sizeof(info), 1, 0);
- if (result == 1)
+ if (result == 1) {
bytes = (PRUint64) info.physical_memory * info.page_size;
+ }
#elif defined(DARWIN)
@@ -316,15 +313,17 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
(host_info_t) &hInfo,
&count);
mach_port_deallocate(mach_task_self(), mach_host);
- if (result == KERN_SUCCESS)
+ if (result == KERN_SUCCESS) {
bytes = hInfo.max_mem;
+ }
#elif defined(WIN32)
MEMORYSTATUSEX memStat;
memStat.dwLength = sizeof(memStat);
- if (GlobalMemoryStatusEx(&memStat))
+ if (GlobalMemoryStatusEx(&memStat)) {
bytes = memStat.ullTotalPhys;
+ }
#elif defined(OS2)