system.c (1572B)
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 "prio.h" 7 #include "prmem.h" 8 #include "prprf.h" 9 #include "prsystem.h" 10 11 #include "plerror.h" 12 13 static char* tag[] = {"PR_SI_HOSTNAME", "PR_SI_SYSNAME", "PR_SI_RELEASE", 14 "PR_SI_ARCHITECTURE"}; 15 16 static PRSysInfo Incr(PRSysInfo* cmd) { 17 PRIntn tmp = (PRIntn)*cmd + 1; 18 *cmd = (PRSysInfo)tmp; 19 return (PRSysInfo)tmp; 20 } /* Incr */ 21 22 int main(int argc, char** argv) { 23 PRStatus rv; 24 PRSysInfo cmd; 25 PRFileDesc* output = PR_GetSpecialFD(PR_StandardOutput); 26 27 char* info = (char*)PR_Calloc(SYS_INFO_BUFFER_LENGTH, 1); 28 for (cmd = PR_SI_HOSTNAME; cmd <= PR_SI_ARCHITECTURE; Incr(&cmd)) { 29 rv = PR_GetSystemInfo(cmd, info, SYS_INFO_BUFFER_LENGTH); 30 if (PR_SUCCESS == rv) { 31 PR_fprintf(output, "%s: %s\n", tag[cmd], info); 32 } else { 33 PL_FPrintError(output, tag[cmd]); 34 } 35 } 36 PR_DELETE(info); 37 38 PR_fprintf(output, "Host page size is %d\n", PR_GetPageSize()); 39 PR_fprintf(output, "Page shift is %d\n", PR_GetPageShift()); 40 PR_fprintf(output, "Memory map alignment is %ld\n", PR_GetMemMapAlignment()); 41 PR_fprintf(output, "Number of processors is: %d\n", 42 PR_GetNumberOfProcessors()); 43 PR_fprintf(output, "Physical memory size is: %llu\n", 44 PR_GetPhysicalMemorySize()); 45 46 return 0; 47 } /* main */ 48 49 /* system.c */