1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/tests/system.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "prio.h" 1.10 +#include "prmem.h" 1.11 +#include "prprf.h" 1.12 +#include "prsystem.h" 1.13 + 1.14 +#include "plerror.h" 1.15 + 1.16 +static char *tag[] = 1.17 +{ 1.18 + "PR_SI_HOSTNAME", 1.19 + "PR_SI_SYSNAME", 1.20 + "PR_SI_RELEASE", 1.21 + "PR_SI_ARCHITECTURE" 1.22 +}; 1.23 + 1.24 +static PRSysInfo Incr(PRSysInfo *cmd) 1.25 +{ 1.26 + PRIntn tmp = (PRIntn)*cmd + 1; 1.27 + *cmd = (PRSysInfo)tmp; 1.28 + return (PRSysInfo)tmp; 1.29 +} /* Incr */ 1.30 + 1.31 +int main(int argc, char **argv) 1.32 +{ 1.33 + PRStatus rv; 1.34 + PRSysInfo cmd; 1.35 + PRFileDesc *output = PR_GetSpecialFD(PR_StandardOutput); 1.36 + 1.37 + char *info = (char*)PR_Calloc(SYS_INFO_BUFFER_LENGTH, 1); 1.38 + for (cmd = PR_SI_HOSTNAME; cmd <= PR_SI_ARCHITECTURE; Incr(&cmd)) 1.39 + { 1.40 + rv = PR_GetSystemInfo(cmd, info, SYS_INFO_BUFFER_LENGTH); 1.41 + if (PR_SUCCESS == rv) PR_fprintf(output, "%s: %s\n", tag[cmd], info); 1.42 + else PL_FPrintError(output, tag[cmd]); 1.43 + } 1.44 + PR_DELETE(info); 1.45 + 1.46 + PR_fprintf(output, "Host page size is %d\n", PR_GetPageSize()); 1.47 + PR_fprintf(output, "Page shift is %d\n", PR_GetPageShift()); 1.48 + PR_fprintf(output, "Memory map alignment is %ld\n", PR_GetMemMapAlignment()); 1.49 + PR_fprintf(output, "Number of processors is: %d\n", PR_GetNumberOfProcessors()); 1.50 + PR_fprintf(output, "Physical memory size is: %llu\n", PR_GetPhysicalMemorySize()); 1.51 + 1.52 + return 0; 1.53 +} /* main */ 1.54 + 1.55 +/* system.c */