Saturday, May 01, 2021

GIMP patch: add memory dashboard support

Simple and straightforward enough. A bit approximative probably but better
than nothing.

(if it looks fine, I'll try upstreaming this)

Index: Makefile
===================================================================
RCS file: /cvs/ports/graphics/gimp/stable/Makefile,v
retrieving revision 1.144
diff -u -p -r1.144 Makefile
--- Makefile 1 Apr 2021 10:01:06 -0000 1.144
+++ Makefile 1 May 2021 11:11:42 -0000
@@ -3,6 +3,7 @@
COMMENT= GNU Image Manipulation Program

DISTNAME = gimp-2.10.24
+REVISION = 0

.for i in gimp gimpbase gimpcolor gimpconfig gimpmath gimpmodule \
gimpthumb gimpui gimpwidgets
Index: patches/patch-app_widgets_gimpdashboard_c
===================================================================
RCS file: patches/patch-app_widgets_gimpdashboard_c
diff -N patches/patch-app_widgets_gimpdashboard_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-app_widgets_gimpdashboard_c 1 May 2021 11:11:42 -0000
@@ -0,0 +1,52 @@
+$OpenBSD$
+
+Index: app/widgets/gimpdashboard.c
+--- app/widgets/gimpdashboard.c.orig
++++ app/widgets/gimpdashboard.c
+@@ -2512,6 +2512,46 @@ gimp_dashboard_sample_memory_available (GimpDashboard
+ 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,

No comments:

Post a Comment