aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2010-01-12 16:18:14 +0200
committerLasse Collin <lasse.collin@tukaani.org>2010-01-12 16:18:14 +0200
commit153c7740c54b3c90129dbd3d6153ac1303c4d605 (patch)
treedf4b8812a8b5c1cf71704134d87f667846b3a07c /src/common
parentFix _memconfig() functions. (diff)
downloadxz-153c7740c54b3c90129dbd3d6153ac1303c4d605.tar.xz
Add IRIX-specific code to tuklib_physmem and tuklib_cpucores.
This is untested but it will get tested soon and, if needed, fixed before 5.0.0. Thanks to Stuart Shelton.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tuklib_cpucores.c6
-rw-r--r--src/common/tuklib_physmem.c19
2 files changed, 25 insertions, 0 deletions
diff --git a/src/common/tuklib_cpucores.c b/src/common/tuklib_cpucores.c
index 0a8081ff..e35d9bc7 100644
--- a/src/common/tuklib_cpucores.c
+++ b/src/common/tuklib_cpucores.c
@@ -37,7 +37,13 @@ tuklib_cpucores(void)
ret = (uint32_t)cpus;
#elif defined(TUKLIB_CPUCORES_SYSCONF)
+# ifdef _SC_NPROCESSORS_ONLN
+ // Most systems
const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
+# else
+ // IRIX
+ const long cpus = sysconf(_SC_NPROC_ONLN);
+# endif
if (cpus > 0)
ret = (uint32_t)cpus;
#endif
diff --git a/src/common/tuklib_physmem.c b/src/common/tuklib_physmem.c
index b2d21283..1536e6e5 100644
--- a/src/common/tuklib_physmem.c
+++ b/src/common/tuklib_physmem.c
@@ -42,6 +42,10 @@
# endif
# include <sys/sysctl.h>
+// IRIX
+#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)
+# include <invent.h>
+
// This sysinfo() is Linux-specific.
#elif defined(TUKLIB_PHYSMEM_SYSINFO)
# include <sys/sysinfo.h>
@@ -136,6 +140,21 @@ tuklib_physmem(void)
ret = mem.u32;
}
+#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)
+ inv_state_t *st = NULL;
+ if (setinvent_r(&st) != -1) {
+ inventory_t *i;
+ while ((i = getinvent_r(st)) != NULL) {
+ if (i->inv_class == INV_MEMORY
+ && i->inv_type == INV_MAIN_MB) {
+ ret = (uint64_t)i->inv_state << 20;
+ break;
+ }
+ }
+
+ endinvent_r(st);
+ }
+
#elif defined(TUKLIB_PHYSMEM_SYSINFO)
struct sysinfo si;
if (sysinfo(&si) == 0)