patch-src_common_c 807 B

123456789101112131415161718192021222324252627282930313233
  1. $OpenBSD: patch-src_common_c,v 1.1 2011/05/21 11:19:24 fgsch Exp $
  2. --- src/common.c.orig Mon May 9 09:14:48 2011
  3. +++ src/common.c Mon May 9 09:33:03 2011
  4. @@ -31,6 +31,7 @@
  5. #define isHex(c) (hexToInt(c) != -1)
  6. #define HEX_BASE 16
  7. +#if !defined(__OpenBSD__)
  8. int get_ram_size(void) {
  9. FILE *fp;
  10. char str[256];
  11. @@ -52,6 +53,20 @@ int get_ram_size(void) {
  12. fclose(fp);
  13. return ret;
  14. }
  15. +#else
  16. +#include <sys/param.h>
  17. +#include <sys/sysctl.h>
  18. +
  19. +int get_ram_size(void) {
  20. + int mib[2] = { CTL_HW, HW_PHYSMEM };
  21. + unsigned int physmem;
  22. + size_t len = sizeof(physmem);
  23. +
  24. + if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0)
  25. + return -1;
  26. + return (physmem / 1024);
  27. +}
  28. +#endif
  29. /* Return the version number */
  30. char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc)