diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-02-14 00:45:29 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-02-14 00:45:29 +0200 |
commit | 3084d662d2646ab7eb58daf0dc32cf3f9a74eec7 (patch) | |
tree | 6601b6dee1b3c35b6894d71fcdbf1554801aff4f /src/common/physmem.h | |
parent | Initial port to DOS using DJGPP. (diff) | |
download | xz-3084d662d2646ab7eb58daf0dc32cf3f9a74eec7.tar.xz |
Cleanups to the code that detects the amount of RAM and
the number of CPU cores. Added support for using sysinfo()
on Linux systems whose libc lacks appropriate sysconf()
support (at least dietlibc). The Autoconf macros were
split into separate files, and CPU core count detection
was moved from hardware.c to cpucores.h. The core count
isn't used for anything real for now, so a problematic
part in process.c was commented out.
Diffstat (limited to '')
-rw-r--r-- | src/common/physmem.h | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/common/physmem.h b/src/common/physmem.h index fb17eac5..7075bc56 100644 --- a/src/common/physmem.h +++ b/src/common/physmem.h @@ -14,27 +14,27 @@ #ifndef PHYSMEM_H #define PHYSMEM_H -#if defined(HAVE_PHYSMEM_SYSCTL) || defined(HAVE_NCPU_SYSCTL) +#if defined(HAVE_PHYSMEM_SYSCONF) +# include <unistd.h> + +#elif defined(HAVE_PHYSMEM_SYSCTL) # ifdef HAVE_SYS_PARAM_H # include <sys/param.h> # endif # ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> # endif -#endif -#if defined(HAVE_PHYSMEM_SYSCONF) || defined(HAVE_NCPU_SYSCONF) -# include <unistd.h> -#endif +#elif defined(HAVE_PHYSMEM_SYSINFO) +# include <sys/sysinfo.h> -#ifdef _WIN32 +#elif defined(_WIN32) # ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0500 # endif # include <windows.h> -#endif -#ifdef __DJGPP__ +#elif defined(__DJGPP__) # include <dpmi.h> #endif @@ -75,6 +75,11 @@ physmem(void) ret = mem.ui; } +#elif defined(HAVE_PHYSMEM_SYSINFO) + struct sysinfo si; + if (sysinfo(&si) == 0) + ret = (uint64_t)(si.totalram) * si.mem_unit; + #elif defined(_WIN32) MEMORYSTATUSEX meminfo; meminfo.dwLength = sizeof(meminfo); |