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