Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "prio.h" |
michael@0 | 7 | #include "prmem.h" |
michael@0 | 8 | #include "prprf.h" |
michael@0 | 9 | #include "prsystem.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "plerror.h" |
michael@0 | 12 | |
michael@0 | 13 | static char *tag[] = |
michael@0 | 14 | { |
michael@0 | 15 | "PR_SI_HOSTNAME", |
michael@0 | 16 | "PR_SI_SYSNAME", |
michael@0 | 17 | "PR_SI_RELEASE", |
michael@0 | 18 | "PR_SI_ARCHITECTURE" |
michael@0 | 19 | }; |
michael@0 | 20 | |
michael@0 | 21 | static PRSysInfo Incr(PRSysInfo *cmd) |
michael@0 | 22 | { |
michael@0 | 23 | PRIntn tmp = (PRIntn)*cmd + 1; |
michael@0 | 24 | *cmd = (PRSysInfo)tmp; |
michael@0 | 25 | return (PRSysInfo)tmp; |
michael@0 | 26 | } /* Incr */ |
michael@0 | 27 | |
michael@0 | 28 | int main(int argc, char **argv) |
michael@0 | 29 | { |
michael@0 | 30 | PRStatus rv; |
michael@0 | 31 | PRSysInfo cmd; |
michael@0 | 32 | PRFileDesc *output = PR_GetSpecialFD(PR_StandardOutput); |
michael@0 | 33 | |
michael@0 | 34 | char *info = (char*)PR_Calloc(SYS_INFO_BUFFER_LENGTH, 1); |
michael@0 | 35 | for (cmd = PR_SI_HOSTNAME; cmd <= PR_SI_ARCHITECTURE; Incr(&cmd)) |
michael@0 | 36 | { |
michael@0 | 37 | rv = PR_GetSystemInfo(cmd, info, SYS_INFO_BUFFER_LENGTH); |
michael@0 | 38 | if (PR_SUCCESS == rv) PR_fprintf(output, "%s: %s\n", tag[cmd], info); |
michael@0 | 39 | else PL_FPrintError(output, tag[cmd]); |
michael@0 | 40 | } |
michael@0 | 41 | PR_DELETE(info); |
michael@0 | 42 | |
michael@0 | 43 | PR_fprintf(output, "Host page size is %d\n", PR_GetPageSize()); |
michael@0 | 44 | PR_fprintf(output, "Page shift is %d\n", PR_GetPageShift()); |
michael@0 | 45 | PR_fprintf(output, "Memory map alignment is %ld\n", PR_GetMemMapAlignment()); |
michael@0 | 46 | PR_fprintf(output, "Number of processors is: %d\n", PR_GetNumberOfProcessors()); |
michael@0 | 47 | PR_fprintf(output, "Physical memory size is: %llu\n", PR_GetPhysicalMemorySize()); |
michael@0 | 48 | |
michael@0 | 49 | return 0; |
michael@0 | 50 | } /* main */ |
michael@0 | 51 | |
michael@0 | 52 | /* system.c */ |