[tracker/tracker-0.16] Implement get_memory_total() on OpenBSD.
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.16] Implement get_memory_total() on OpenBSD.
- Date: Wed, 1 May 2013 12:02:43 +0000 (UTC)
commit 25dfc1e85f5135a7d14eea7688a07d1ff26491cc
Author: Antoine Jacoutot <ajacoutot gnome org>
Date: Mon Apr 29 17:03:36 2013 +0200
Implement get_memory_total() on OpenBSD.
https://bugzilla.gnome.org/show_bug.cgi?id=697719
src/libtracker-common/tracker-os-dependant-unix.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-os-dependant-unix.c
b/src/libtracker-common/tracker-os-dependant-unix.c
index 5c36c71..79eb837 100644
--- a/src/libtracker-common/tracker-os-dependant-unix.c
+++ b/src/libtracker-common/tracker-os-dependant-unix.c
@@ -26,6 +26,11 @@
#include <unistd.h>
#include <sys/resource.h>
+#if defined (__OpenBSD__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
#include <glib.h>
#include "tracker-log.h"
@@ -225,6 +230,7 @@ tracker_create_permission_string (struct stat finfo)
static glong
get_memory_total (void)
{
+#if !defined (__OpenBSD__)
GError *error = NULL;
const gchar *filename;
gchar *contents = NULL;
@@ -258,6 +264,20 @@ get_memory_total (void)
}
g_free (contents);
}
+#else /* OpenBSD */
+ glong total = 0;
+ int64_t physmem;
+ size_t len;
+ static gint mib[] = { CTL_HW, HW_PHYSMEM64 };
+
+ len = sizeof (physmem);
+
+ if (sysctl (mib, G_N_ELEMENTS (mib), &physmem, &len, NULL, 0) == -1) {
+ g_critical ("Couldn't get memory information: %d", errno);
+ } else {
+ total = physmem;
+ }
+#endif /* !OpenBSD */
return total;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]