system.c 1.6 KB

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