Add initial NetBSD backend for the cpufreq panel plugin.
This commit is contained in:
parent
5bcd2873d4
commit
511029b27e
11 changed files with 1947 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.21 2019/01/16 15:02:45 youri Exp $
|
||||
# $NetBSD: Makefile,v 1.22 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
PYTHON_VERSIONS_ACCEPTED= 27
|
||||
.include "../../meta-pkgs/mate/Makefile.common"
|
||||
|
@ -15,6 +15,12 @@ TOOL_DEPENDS+= libxml2-[0-9]*:../../textproc/libxml2 # for xmllint
|
|||
CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
|
||||
CONFIGURE_ARGS+= --libexecdir=${PREFIX}/libexec/mate-applets
|
||||
|
||||
PLIST_VARS= batt cpufreq
|
||||
.if ${OPSYS} == "NetBSD" && (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64")
|
||||
CONFIGURE_ARGS+= --enable-cpufreq=yes
|
||||
PLIST.cpufreq= yes
|
||||
.endif
|
||||
|
||||
INSTALL_MAKE_FLAGS+= sysconfdir=${PREFIX}/share/examples/mate-applets
|
||||
|
||||
MAKE_DIRS+= ${PKG_SYSCONFDIR}/sound/events
|
||||
|
@ -26,7 +32,6 @@ CONF_FILES+= ${PREFIX}/share/examples/mate-applets/sound/events/mate-battstat_ap
|
|||
${PKG_SYSCONFDIR}/sound/events/mate-battstat_applet.soundlist
|
||||
.endif
|
||||
|
||||
PLIST_VARS= batt
|
||||
.if ${OPSYS} != "Darwin" && ${OPSYS} != "SunOS"
|
||||
PLIST.batt= yes
|
||||
.endif
|
||||
|
@ -35,10 +40,6 @@ PLIST.batt= yes
|
|||
|
||||
.include "../../devel/glib2/schemas.mk"
|
||||
|
||||
REPLACE_PYTHON+= invest-applet/invest/chart.py
|
||||
REPLACE_PYTHON+= invest-applet/invest/invest-applet.py
|
||||
REPLACE_PYTHON+= invest-applet/invest/mate-invest-chart
|
||||
|
||||
.include "../../x11/mate-panel/buildlink3.mk"
|
||||
.include "../../x11/mate-desktop/buildlink3.mk"
|
||||
.include "../../x11/mate-settings-daemon/buildlink3.mk"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,14 @@
|
|||
$NetBSD: distinfo,v 1.4 2019/01/16 15:02:45 youri Exp $
|
||||
$NetBSD: distinfo,v 1.5 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
SHA1 (mate-applets-1.21.1.tar.xz) = 72aabe0276161c68ea0946d3193eedf6a108e18e
|
||||
RMD160 (mate-applets-1.21.1.tar.xz) = a033f599c5518be627e7c4d1db14d7225e75a26b
|
||||
SHA512 (mate-applets-1.21.1.tar.xz) = f006e5935354f5dd332b4a977b0a3b1ce9606770f86a48bb7177d32a27aa8d055d4fed384b2e9c330e0352d5cca8fc0cc36ebc60bbb4b21b453f707e1e938ee8
|
||||
Size (mate-applets-1.21.1.tar.xz) = 7696012 bytes
|
||||
SHA1 (patch-configure) = 6c3149ed460ad833c076ac370d2cdd497fb123d8
|
||||
SHA1 (patch-cpufreq_src_Makefile.in) = ea3b4cf9fa0e9e79af28d0d045c6f8cdfb736253
|
||||
SHA1 (patch-cpufreq_src_cpufreq-monitor-cpuinfo.c) = f19ddbf7e6ad764ae14f0adabc3b4c689e338e1b
|
||||
SHA1 (patch-cpufreq_src_cpufreq-monitor-factory.c) = 7b5e992b4481af2376f17e7da1d0fe91f90dda0c
|
||||
SHA1 (patch-cpufreq_src_cpufreq-monitor-sysctl.c) = 430a6bf29c638d6cd4b4ce3e54a3bed747337712
|
||||
SHA1 (patch-cpufreq_src_cpufreq-monitor-sysctl.h) = b079bc3e40ce1f960096fcb1b4568b18d01a1121
|
||||
SHA1 (patch-cpufreq_src_cpufreq-selector.c) = b9aef12a3ef9703a35bfa350b44891d98a1eaa31
|
||||
SHA1 (patch-cpufreq_src_cpufreq-utils.c) = 2d420ee31fa114a397062463b6762020cbc6ece8
|
||||
|
|
18
x11/mate-applets/patches/patch-configure
Normal file
18
x11/mate-applets/patches/patch-configure
Normal file
|
@ -0,0 +1,18 @@
|
|||
$NetBSD: patch-configure,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Allow configure to enable cpufreq.
|
||||
|
||||
--- configure.orig 2018-11-18 07:55:11.000000000 +0000
|
||||
+++ configure
|
||||
@@ -16881,9 +16881,9 @@ fi
|
||||
|
||||
build_cpufreq_applet=no
|
||||
|
||||
-if test x$disable_cpufreq = xno; then
|
||||
+if test x$enable_cpufreq = xyes; then
|
||||
case "${host}" in
|
||||
- *linux*)
|
||||
+ *linux*|*-*-netbsd*)
|
||||
build_cpufreq_applet=yes
|
||||
;;
|
||||
*)
|
43
x11/mate-applets/patches/patch-cpufreq_src_Makefile.in
Normal file
43
x11/mate-applets/patches/patch-cpufreq_src_Makefile.in
Normal file
|
@ -0,0 +1,43 @@
|
|||
$NetBSD: patch-cpufreq_src_Makefile.in,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Hook sysctl file.
|
||||
|
||||
--- cpufreq/src/Makefile.in.orig 2018-11-18 07:55:12.000000000 +0000
|
||||
+++ cpufreq/src/Makefile.in
|
||||
@@ -113,7 +113,7 @@ am__mate_cpufreq_applet_SOURCES_DIST = c
|
||||
cpufreq-monitor-procfs.h cpufreq-monitor-sysfs.c \
|
||||
cpufreq-monitor-sysfs.h cpufreq-monitor-libcpufreq.c \
|
||||
cpufreq-monitor-libcpufreq.h cpufreq-monitor-cpuinfo.c \
|
||||
- cpufreq-monitor-cpuinfo.h
|
||||
+ cpufreq-monitor-cpuinfo.h cpufreq-monitor-sysctl.h cpufreq-monitor-sysctl.c
|
||||
@HAVE_LIBCPUFREQ_TRUE@am__objects_1 = \
|
||||
@HAVE_LIBCPUFREQ_TRUE@ cpufreq-monitor-libcpufreq.$(OBJEXT)
|
||||
am_mate_cpufreq_applet_OBJECTS = cpufreq-applet.$(OBJEXT) \
|
||||
@@ -122,7 +122,8 @@ am_mate_cpufreq_applet_OBJECTS = cpufreq
|
||||
cpufreq-monitor.$(OBJEXT) cpufreq-monitor-factory.$(OBJEXT) \
|
||||
cpufreq-monitor-procfs.$(OBJEXT) \
|
||||
cpufreq-monitor-sysfs.$(OBJEXT) $(am__objects_1) \
|
||||
- cpufreq-monitor-cpuinfo.$(OBJEXT)
|
||||
+ cpufreq-monitor-cpuinfo.$(OBJEXT) \
|
||||
+ cpufreq-monitor-sysctl.$(OBJEXT)
|
||||
mate_cpufreq_applet_OBJECTS = $(am_mate_cpufreq_applet_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
mate_cpufreq_applet_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||
@@ -470,7 +471,8 @@ mate_cpufreq_applet_SOURCES = \
|
||||
cpufreq-monitor-procfs.c cpufreq-monitor-procfs.h \
|
||||
cpufreq-monitor-sysfs.c cpufreq-monitor-sysfs.h \
|
||||
$(cpufreq_files) \
|
||||
- cpufreq-monitor-cpuinfo.c cpufreq-monitor-cpuinfo.h
|
||||
+ cpufreq-monitor-cpuinfo.c cpufreq-monitor-cpuinfo.h \
|
||||
+ cpufreq-monitor-sysctl.c cpufreq-monitor-sysctl.h
|
||||
|
||||
mate_cpufreq_applet_LDADD = \
|
||||
$(MATE_APPLETS4_LIBS) \
|
||||
@@ -573,6 +575,7 @@ distclean-compile:
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpufreq-applet.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpufreq-monitor-cpuinfo.Po@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpufreq-monitor-sysctl.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpufreq-monitor-factory.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpufreq-monitor-libcpufreq.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpufreq-monitor-procfs.Po@am__quote@
|
|
@ -0,0 +1,59 @@
|
|||
$NetBSD: patch-cpufreq_src_cpufreq-monitor-cpuinfo.c,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Add NetBSD support.
|
||||
|
||||
--- cpufreq/src/cpufreq-monitor-cpuinfo.c.orig 2018-01-14 14:48:43.000000000 +0000
|
||||
+++ cpufreq/src/cpufreq-monitor-cpuinfo.c
|
||||
@@ -29,6 +29,12 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
+#ifdef __NetBSD__
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <err.h>
|
||||
+#endif
|
||||
+
|
||||
#include "cpufreq-monitor-cpuinfo.h"
|
||||
#include "cpufreq-utils.h"
|
||||
|
||||
@@ -64,15 +70,20 @@ cpufreq_monitor_cpuinfo_new (guint cpu)
|
||||
static gboolean
|
||||
cpufreq_monitor_cpuinfo_run (CPUFreqMonitor *monitor)
|
||||
{
|
||||
+#ifndef __NetBSD__
|
||||
gchar *file;
|
||||
gchar **lines;
|
||||
gchar *buffer = NULL;
|
||||
gchar *p;
|
||||
+#else
|
||||
+ size_t len;
|
||||
+#endif
|
||||
gint cpu, i;
|
||||
gint cur_freq, max_freq;
|
||||
gchar *governor;
|
||||
GError *error = NULL;
|
||||
|
||||
+#ifndef __NetBSD__
|
||||
file = g_strdup ("/proc/cpuinfo");
|
||||
if (!cpufreq_file_get_contents (file, &buffer, NULL, &error)) {
|
||||
g_warning ("%s", error->message);
|
||||
@@ -117,9 +128,17 @@ cpufreq_monitor_cpuinfo_run (CPUFreqMoni
|
||||
|
||||
g_strfreev (lines);
|
||||
g_free (buffer);
|
||||
+#else
|
||||
+ len = sizeof(cpu);
|
||||
+ if (sysctlbyname("kern.clockrate", &cpu, &len, NULL, 0) < 1) {
|
||||
+ errx(1, "Failed to get kern.clockrate");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ printf("got clockrate = %d\n", cpu);
|
||||
+#endif
|
||||
|
||||
governor = g_strdup (_("Frequency Scaling Unsupported"));
|
||||
- cur_freq = cpu * 1000;
|
||||
+ cur_freq = cpu;
|
||||
max_freq = cur_freq;
|
||||
|
||||
g_object_set (G_OBJECT (monitor),
|
|
@ -0,0 +1,53 @@
|
|||
$NetBSD: patch-cpufreq_src_cpufreq-monitor-factory.c,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Add NetBSD support.
|
||||
|
||||
--- cpufreq/src/cpufreq-monitor-factory.c.orig 2018-01-14 14:48:43.000000000 +0000
|
||||
+++ cpufreq/src/cpufreq-monitor-factory.c
|
||||
@@ -25,11 +25,18 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
+#ifdef __NetBSD__
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#endif
|
||||
|
||||
#include "cpufreq-applet.h"
|
||||
#include "cpufreq-utils.h"
|
||||
#include "cpufreq-monitor-sysfs.h"
|
||||
#include "cpufreq-monitor-procfs.h"
|
||||
+#ifdef __NetBSD__
|
||||
+#include "cpufreq-monitor-sysctl.h"
|
||||
+#endif
|
||||
#include "cpufreq-monitor-cpuinfo.h"
|
||||
#ifdef HAVE_LIBCPUFREQ
|
||||
#include "cpufreq-monitor-libcpufreq.h"
|
||||
@@ -40,6 +47,7 @@ CPUFreqMonitor *
|
||||
cpufreq_monitor_factory_create_monitor (guint cpu)
|
||||
{
|
||||
CPUFreqMonitor *monitor = NULL;
|
||||
+#ifndef __NetBSD__
|
||||
|
||||
#ifdef HAVE_LIBCPUFREQ
|
||||
monitor = cpufreq_monitor_libcpufreq_new (cpu);
|
||||
@@ -63,6 +71,19 @@ cpufreq_monitor_factory_create_monitor (
|
||||
|
||||
monitor = cpufreq_monitor_cpuinfo_new (cpu);
|
||||
}
|
||||
+#else
|
||||
+ size_t len;
|
||||
+
|
||||
+ if (sysctlbyname ("machdep.est.frequency.current", NULL, &len, NULL, 0) == 0) {
|
||||
+ monitor = cpufreq_monitor_sysctl_new (cpu);
|
||||
+ } else {
|
||||
+ cpufreq_utils_display_error (_("CPU frequency scaling unsupported"),
|
||||
+ _("You will not be able to modify the frequency of your machine. "
|
||||
+ "Your machine may be misconfigured or not have hardware support "
|
||||
+ "for CPU frequency scaling."));
|
||||
+ monitor = cpufreq_monitor_cpuinfo_new (cpu);
|
||||
+ }
|
||||
+#endif /* __NetBSD__ */
|
||||
|
||||
return monitor;
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
$NetBSD: patch-cpufreq_src_cpufreq-monitor-sysctl.c,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Add NetBSD support, adapted from freebsd ports.
|
||||
|
||||
--- cpufreq/src/cpufreq-monitor-sysctl.c.orig 2019-01-23 13:06:18.405523935 +0000
|
||||
+++ cpufreq/src/cpufreq-monitor-sysctl.c
|
||||
@@ -0,0 +1,182 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2001, 2002 Free Software Foundation
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public
|
||||
+ * License along with this library; if not, write to the Free
|
||||
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
+ *
|
||||
+ * Authors : Joe Marcus Clarke <marcus@FreeBSD.org>
|
||||
+ * Youri Mouton <youri@NetBSD.org>
|
||||
+ */
|
||||
+
|
||||
+#include <glib.h>
|
||||
+#include <glib/gi18n.h>
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+#ifdef __NetBSD__
|
||||
+#include <errno.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+
|
||||
+#include "cpufreq-monitor-sysctl.h"
|
||||
+
|
||||
+#define PARENT_TYPE TYPE_CPUFREQ_MONITOR
|
||||
+
|
||||
+#define CPUFREQ_MONITOR_GET_PROTECTED(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PARENT_TYPE, CPUFreqMonitorProtected))
|
||||
+
|
||||
+static void cpufreq_monitor_sysctl_class_init (CPUFreqMonitorSysctlClass *klass);
|
||||
+
|
||||
+static gboolean cpufreq_monitor_sysctl_run (CPUFreqMonitor *monitor);
|
||||
+static GList *cpufreq_monitor_sysctl_get_available_frequencies (CPUFreqMonitor *monitor);
|
||||
+static GList *cpufreq_monitor_sysctl_get_available_governors (CPUFreqMonitor *monitor);
|
||||
+
|
||||
+static gboolean cpufreq_monitor_sysctl_get (gpointer gdata);
|
||||
+
|
||||
+G_DEFINE_TYPE (CPUFreqMonitorSysctl, cpufreq_monitor_sysctl, CPUFREQ_TYPE_MONITOR)
|
||||
+
|
||||
+static void
|
||||
+cpufreq_monitor_sysctl_init (CPUFreqMonitorSysctl *monitor)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+cpufreq_monitor_sysctl_class_init (CPUFreqMonitorSysctlClass *klass)
|
||||
+{
|
||||
+ CPUFreqMonitorClass *monitor_class = CPUFREQ_MONITOR_CLASS (klass);
|
||||
+
|
||||
+ monitor_class->run = cpufreq_monitor_sysctl_run;
|
||||
+ monitor_class->get_available_frequencies = cpufreq_monitor_sysctl_get_available_frequencies;
|
||||
+ monitor_class->get_available_governors = cpufreq_monitor_sysctl_get_available_governors;
|
||||
+}
|
||||
+
|
||||
+CPUFreqMonitor *
|
||||
+cpufreq_monitor_sysctl_new (guint cpu)
|
||||
+{
|
||||
+ CPUFreqMonitorSysctl *monitor;
|
||||
+
|
||||
+ monitor = g_object_new (TYPE_CPUFREQ_MONITOR_SYSCTL, "cpu", cpu, NULL);
|
||||
+
|
||||
+ return CPUFREQ_MONITOR (monitor);
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+cpufreq_monitor_sysctl_run (CPUFreqMonitor *monitor)
|
||||
+{
|
||||
+ gint fmax, fmin, ifreq;
|
||||
+ gchar *governor;
|
||||
+ size_t len;
|
||||
+ gchar *freq_oid;
|
||||
+ guint mon_cpu;
|
||||
+ GList *list;
|
||||
+
|
||||
+ list = cpufreq_monitor_sysctl_get_available_frequencies (CPUFREQ_MONITOR (monitor));
|
||||
+
|
||||
+ fmax = (int)strtol(g_list_first(list), (char **)NULL, 10);
|
||||
+ if (errno)
|
||||
+ errx(1, "Failed to strtol for fmax");
|
||||
+ fmin = (int)strtol(g_list_last(list), (char **)NULL, 10);
|
||||
+ if (errno)
|
||||
+ errx(1, "Failed to strtol for fmin");
|
||||
+
|
||||
+ g_list_foreach (list, (GFunc) g_free, NULL);
|
||||
+ g_list_free (list);
|
||||
+
|
||||
+ g_object_get (G_OBJECT (monitor), "cpu", &mon_cpu, NULL);
|
||||
+ len = sizeof (ifreq);
|
||||
+ freq_oid = g_strdup_printf ("machdep.est.frequency.current", 0);
|
||||
+
|
||||
+ if (sysctlbyname (freq_oid, &ifreq, &len, NULL, 0) == -1) {
|
||||
+ errx(1, "failed to get machdep.est.frequency.current: %s\n", strerror(errno));
|
||||
+ g_free (freq_oid);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ if (ifreq == fmax)
|
||||
+ governor = g_strdup ("performance");
|
||||
+ else if (ifreq == fmin)
|
||||
+ governor = g_strdup ("economy");
|
||||
+ else
|
||||
+ governor = g_strdup ("userspace");
|
||||
+
|
||||
+ g_object_set (G_OBJECT (monitor),
|
||||
+ "online", TRUE,
|
||||
+ "governor", governor,
|
||||
+ "frequency", ifreq,
|
||||
+ "max-frequency", fmax,
|
||||
+ NULL);
|
||||
+
|
||||
+ g_free (governor);
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static GList *
|
||||
+cpufreq_monitor_sysctl_get_available_frequencies (CPUFreqMonitor *monitor)
|
||||
+{
|
||||
+ gchar *levels_oid, *levels;
|
||||
+ gchar **levelsp, **l;
|
||||
+ GList *list = NULL;
|
||||
+ gint mib[4];
|
||||
+ guint mon_cpu;
|
||||
+ size_t len;
|
||||
+
|
||||
+ g_object_get (G_OBJECT (monitor), "cpu", &mon_cpu, NULL);
|
||||
+
|
||||
+ levels_oid = g_strdup_printf ("machdep.est.frequency.available",
|
||||
+ 0);
|
||||
+ len = 4;
|
||||
+ sysctlnametomib (levels_oid, mib, &len);
|
||||
+ len = sizeof (levels);
|
||||
+ g_free (levels_oid);
|
||||
+
|
||||
+ if (sysctl (mib, 4, NULL, &len, NULL, 0) == -1)
|
||||
+ return NULL;
|
||||
+
|
||||
+ levels = g_malloc (len);
|
||||
+ if (sysctl (mib, 4, levels, &len, NULL, 0) == -1)
|
||||
+ {
|
||||
+ g_free(levels);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ levelsp = g_strsplit (levels, " ", 0);
|
||||
+ g_free (levels);
|
||||
+
|
||||
+ for (l = levelsp; l && *l; l++) {
|
||||
+ int freq = (int)strtol(*l, (char **)NULL, 0);
|
||||
+ if (errno)
|
||||
+ errx(1, "Failed to strtol freq levels");
|
||||
+ freq *= 1000;
|
||||
+ char *f = g_strdup_printf("%d", freq);
|
||||
+ list = g_list_append(list, f);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ g_strfreev (levelsp);
|
||||
+
|
||||
+ return (list);
|
||||
+}
|
||||
+
|
||||
+static GList *
|
||||
+cpufreq_monitor_sysctl_get_available_governors (CPUFreqMonitor *monitor)
|
||||
+{
|
||||
+ GList *list = NULL;
|
||||
+
|
||||
+ list = g_list_prepend (list, g_strdup ("performance"));
|
||||
+ list = g_list_prepend (list, g_strdup ("userspace"));
|
||||
+ list = g_list_prepend (list, g_strdup ("economy"));
|
||||
+
|
||||
+ return list;
|
||||
+}
|
||||
+#endif /* __NetBSD__ */
|
|
@ -0,0 +1,55 @@
|
|||
$NetBSD: patch-cpufreq_src_cpufreq-monitor-sysctl.h,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Add NetBSD sysctl backend, adapted from freebsd ports
|
||||
|
||||
--- cpufreq/src/cpufreq-monitor-sysctl.h.orig 2019-01-23 11:12:16.438531424 +0000
|
||||
+++ cpufreq/src/cpufreq-monitor-sysctl.h
|
||||
@@ -0,0 +1,48 @@
|
||||
+/* Copyright (C) 2001, 2002 Free Software Foundation
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public
|
||||
+ * License along with this library; if not, write to the Free
|
||||
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
+ *
|
||||
+ * Authors : Joe Marcus Clarke <marcus@FreeBSD.org>
|
||||
+ */
|
||||
+
|
||||
+#ifndef __CPUFREQ_MONITOR_SYSCTL_H__
|
||||
+#define __CPUFREQ_MONITOR_SYSCTL_H__
|
||||
+
|
||||
+#include <glib-object.h>
|
||||
+
|
||||
+#include "cpufreq-monitor.h"
|
||||
+
|
||||
+#define TYPE_CPUFREQ_MONITOR_SYSCTL (cpufreq_monitor_sysctl_get_type ())
|
||||
+#define CPUFREQ_MONITOR_SYSCTL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CPUFREQ_MONITOR_SYSCTL, CPUFreqMonitorSysctl))
|
||||
+#define CPUFREQ_MONITOR_SYSCTL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_CPUFREQ_MONITOR_SYSCTL, CPUFreqMonitorSysctlClass))
|
||||
+#define IS_CPUFREQ_MONITOR_SYSCTL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CPUFREQ_MONITOR_SYSCTL))
|
||||
+#define IS_CPUFREQ_MONITOR_SYSCTL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CPUFREQ_MONITOR_SYSCTL))
|
||||
+#define CPUFREQ_MONITOR_SYSCTL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CPUFREQ_MONITOR_SYSCTL, CPUFreqMonitorSysctlClass))
|
||||
+
|
||||
+typedef struct _CPUFreqMonitorSysctl CPUFreqMonitorSysctl;
|
||||
+typedef struct _CPUFreqMonitorSysctlClass CPUFreqMonitorSysctlClass;
|
||||
+
|
||||
+struct _CPUFreqMonitorSysctl {
|
||||
+ CPUFreqMonitor parent;
|
||||
+};
|
||||
+
|
||||
+struct _CPUFreqMonitorSysctlClass {
|
||||
+ CPUFreqMonitorClass parent_class;
|
||||
+};
|
||||
+
|
||||
+GType cpufreq_monitor_sysctl_get_type (void) G_GNUC_CONST;
|
||||
+CPUFreqMonitor *cpufreq_monitor_sysctl_new (guint cpu);
|
||||
+
|
||||
+#endif /* __CPUFREQ_MONITOR_SYSCTL_H__ */
|
|
@ -0,0 +1,19 @@
|
|||
$NetBSD: patch-cpufreq_src_cpufreq-selector.c,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Add NetBSD backend.
|
||||
|
||||
--- cpufreq/src/cpufreq-selector.c.orig 2019-01-23 11:23:52.583081163 +0000
|
||||
+++ cpufreq/src/cpufreq-selector.c
|
||||
@@ -18,7 +18,12 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
+#ifdef __Linux__
|
||||
#include <sys/sysinfo.h>
|
||||
+#else
|
||||
+#include "cpufreq-utils.h"
|
||||
+#define get_nprocs cpufreq_utils_get_n_cpus
|
||||
+#endif
|
||||
|
||||
#ifdef HAVE_POLKIT
|
||||
#include <dbus/dbus-glib.h>
|
44
x11/mate-applets/patches/patch-cpufreq_src_cpufreq-utils.c
Normal file
44
x11/mate-applets/patches/patch-cpufreq_src_cpufreq-utils.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
$NetBSD: patch-cpufreq_src_cpufreq-utils.c,v 1.1 2019/01/23 15:25:36 youri Exp $
|
||||
|
||||
Add NetBSD backend.
|
||||
|
||||
--- cpufreq/src/cpufreq-utils.c.orig 2018-01-14 14:48:43.000000000 +0000
|
||||
+++ cpufreq/src/cpufreq-utils.c
|
||||
@@ -29,6 +29,11 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
+#ifdef __NetBSD__
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <err.h>
|
||||
+#endif
|
||||
|
||||
#include "cpufreq-utils.h"
|
||||
|
||||
@@ -36,6 +41,17 @@
|
||||
#include <dbus/dbus-glib.h>
|
||||
#endif /* HAVE_POLKIT */
|
||||
|
||||
+#ifdef __NetBSD__
|
||||
+guint
|
||||
+cpufreq_utils_get_n_cpus (void)
|
||||
+{
|
||||
+ guint ncpu = -1;
|
||||
+ size_t len = sizeof(ncpu);
|
||||
+ if (sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0) < 0)
|
||||
+ errx(1, "Failed to get hw.ncpu");
|
||||
+ return ncpu;
|
||||
+}
|
||||
+#else
|
||||
guint
|
||||
cpufreq_utils_get_n_cpus (void)
|
||||
{
|
||||
@@ -78,6 +94,7 @@ cpufreq_utils_get_n_cpus (void)
|
||||
|
||||
return 1;
|
||||
}
|
||||
+#endif
|
||||
|
||||
void
|
||||
cpufreq_utils_display_error (const gchar *message,
|
Loading…
Reference in a new issue