[gimp/gimp-2-10] Issue #6850: support for memory in the dashboard under OpenBSD.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] Issue #6850: support for memory in the dashboard under OpenBSD.
- Date: Sun, 9 May 2021 18:03:12 +0000 (UTC)
commit f3c21c7e6e2cf0309d31de958f3e4036b6484717
Author: Marc Espie <espie openbsd org>
Date: Sun May 9 19:57:49 2021 +0200
Issue #6850: support for memory in the dashboard under OpenBSD.
(cherry picked from commit 6dc98fe7f0855e73fa062a5128f936c0f22c891f)
app/widgets/gimpdashboard.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
---
diff --git a/app/widgets/gimpdashboard.c b/app/widgets/gimpdashboard.c
index bc98f3cbd8..8e8273b061 100644
--- a/app/widgets/gimpdashboard.c
+++ b/app/widgets/gimpdashboard.c
@@ -2512,6 +2512,45 @@ gimp_dashboard_sample_memory_available (GimpDashboard *dashboard,
variable_data->value.size = ms.ullAvailPhys;
}
+#elif defined(__OpenBSD__)
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+static void
+gimp_dashboard_sample_memory_used (GimpDashboard *dashboard,
+ Variable variable)
+{
+ GimpDashboardPrivate *priv = dashboard->priv;
+ VariableData *variable_data = &priv->variables[variable];
+ struct rusage rusage;
+
+ variable_data->available = FALSE;
+
+ if (getrusage (RUSAGE_SELF, &rusage) == -1)
+ return;
+ variable_data->available = TRUE;
+ variable_data->value.size = (guint64) (rusage.ru_maxrss * 1024);
+}
+
+static void
+gimp_dashboard_sample_memory_available (GimpDashboard *dashboard,
+ Variable variable)
+{
+ GimpDashboardPrivate *priv = dashboard->priv;
+ VariableData *variable_data = &priv->variables[variable];
+ int mib[] = { CTL_HW, HW_PHYSMEM64 };
+ int64_t result;
+ size_t sz = sizeof(int64_t);
+
+ variable_data->available = FALSE;
+
+ if (sysctl (mib, 2, &result, &sz, NULL, 0) == -1)
+ return;
+ variable_data->available = TRUE;
+ variable_data->value.size = (guint64) result;
+}
+
#else /* ! G_OS_WIN32 && ! PLATFORM_OSX */
static void
gimp_dashboard_sample_memory_used (GimpDashboard *dashboard,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]