Issue #6850: support for memory in the dashboard under OpenBSD.
(cherry picked from commit 6dc98fe7f0
)
This commit is contained in:
@ -2512,6 +2512,45 @@ gimp_dashboard_sample_memory_available (GimpDashboard *dashboard,
|
|||||||
variable_data->value.size = ms.ullAvailPhys;
|
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 */
|
#else /* ! G_OS_WIN32 && ! PLATFORM_OSX */
|
||||||
static void
|
static void
|
||||||
gimp_dashboard_sample_memory_used (GimpDashboard *dashboard,
|
gimp_dashboard_sample_memory_used (GimpDashboard *dashboard,
|
||||||
|
Reference in New Issue
Block a user