the Fink project is an effort to port
popular Unix programs to Mac OS X
Package: wmcpuload
Version: 1.0.0
Revision: 1
Source: http://www.sh.rim.or.jp/~ssato/src/%n-%v.tar.gz
Source-MD5: cf1184c563e141e4d311c393b40207f1
BuildDepends: fink (>= 0.24.12-1), x11-dev
Depends: x11
PatchFile: %n.patch
PatchFile-MD5: cd614ec5d371d6f1e913c26d4c104d74
SetLDFLAGS: -L/usr/X11R6/lib
ConfigureParams: --prefix=%p --mandir=%p/share/man
InstallScript: make install DESTDIR=%d
Description: Dock applet to display the current cpu load
DescDetail: <<
WMCPULoad is a program to monitor CPU usage. It is a dockapp that is supported
by X window managers such as Window Maker, AfterStep, BlackBox, and
Enlightenment
<<
DescPort: <<
The patch to support Darwin has been accepted for the next release
<<
Homepage: http://www.sh.rim.or.jp/~ssato/dockapp/index.shtml
License: GPL
Maintainer: Landon Fuller
diff -rwub wmcpuload-1.0.0/configure wmcpuload-1.0.0-darwin/configure
--- wmcpuload-1.0.0/configure Sun Jul 14 03:47:19 2002
+++ wmcpuload-1.0.0/configure Tue Sep 24 07:53:44 2002
@@ -4376,6 +4376,9 @@
cygwin*)
OS=cygwin
;;
+darwin*)
+ OS=darwin
+ ;;
*)
echo ""
echo "Sorry, ${target_os} is not supported yet"
Only in wmcpuload-1.0.0-darwin/src: cpu_darwin.c
diff -rwubN wmcpuload-1.0.0/src/cpu_darwin.c wmcpuload-1.0.0-darwin/src/cpu_darwin.c
--- wmcpuload-1.0.0/src/cpu_darwin.c Wed Dec 31 16:00:00 1969
+++ wmcpuload-1.0.0/src/cpu_darwin.c Tue Sep 24 08:55:27 2002
@@ -0,0 +1,59 @@
+/*
+ * cpu_darwin - module to get cpu usage, for Darwin
+ *
+ * Copyright (C) 2002 Landon J. Fuller
+ * Copyright (C) 2001, 2002 Seiichi SATO
+ *
+ * Licensed under the GPL
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+#include
+#include
+#include "cpu.h"
+
+#include
+#include
+#include
+
+static host_cpu_load_info_data_t prevcount, curcount;
+static mach_port_t host_priv_port;
+
+static
+getload(host_cpu_load_info_t cpucounters)
+{
+ mach_msg_type_number_t count;
+ kern_return_t kr;
+ count = HOST_CPU_LOAD_INFO_COUNT;
+ kr = host_statistics (host_priv_port, HOST_CPU_LOAD_INFO, (host_info_t) cpucounters, &count);
+ return (kr);
+}
+
+void
+cpu_init(void)
+{
+ host_priv_port = mach_host_self();
+ getload(&prevcount);
+ return;
+}
+
+/* Returns the current CPU usage in percent */
+int
+cpu_get_usage(cpu_options *opts)
+{
+ double userticks, systicks, idleticks, totalticks, usedticks;
+ getload(&curcount);
+
+ userticks = curcount.cpu_ticks[CPU_STATE_USER] - prevcount.cpu_ticks[CPU_STATE_USER];
+ systicks = curcount.cpu_ticks[CPU_STATE_SYSTEM] - prevcount.cpu_ticks[CPU_STATE_SYSTEM];
+ idleticks = curcount.cpu_ticks[CPU_STATE_IDLE] - prevcount.cpu_ticks[CPU_STATE_IDLE];
+ prevcount = curcount;
+ usedticks = userticks + systicks;
+ totalticks = usedticks + idleticks;
+ return ((100 * (double) usedticks) / totalticks);
+}