[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Could you please test my pet package ;)



Fabian Greffrath, le Mon 27 Feb 2012 15:05:41 +0100, a écrit :
> I have already found patches for NetBSD and OpenBSD.  FreeBSD is
> already supported by upstream, but there is no explicit support for
> Hurd.

I was lazy, but re-using the linux case and the /proc
linux-compatibility of GNU/Hurd, see attached patch.

Samuel
Index: hot-babe/hot-babe.c
===================================================================
--- hot-babe.orig/hot-babe.c	2012-02-27 20:38:15.000000000 +0000
+++ hot-babe/hot-babe.c	2012-02-27 20:39:28.000000000 +0000
@@ -91,14 +91,14 @@
   double loadavg;
   return ((getloadavg(&loadavg, 1) == -1) ? 0 : (100 * loadavg));
 }
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
 
 /* returns current CPU load in percent, 0 to 256 */
 static int system_cpu(void)
 {
   unsigned int  cpuload;
   int           i;
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
   u_int64_t     load, total, oload, ototal;
   u_int64_t     ab, ac, ad, ae;
   FILE         *stat;
@@ -117,7 +117,7 @@
   static int mib[] = { CTL_KERN, KERN_CPTIME };
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
   stat = fopen("/proc/stat", "r");
   fscanf(stat, "%*s %Ld %Ld %Ld %Ld", &ab, &ac, &ad, &ae);
   fclose(stat);

Reply to: