Hi,
I added support for OpenBSD on the cpufreq
module.

Thanks
--- e_mod_main.c        Sun Sep 30 11:16:50 2012
+++ e_mod_main.c        Sun Sep 30 11:11:57 2012
@@ -6,6 +6,12 @@
 #include <sys/sysctl.h>
 #endif
 
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/param.h>
+#endif
+
 /* gadcon requirements */
 static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char 
*id, const char *style);
 static void             _gc_shutdown(E_Gadcon_Client *gcc);
@@ -422,7 +428,7 @@
    char buf[4096];
    int ret;
 
-#ifdef __FreeBSD__
+#if defined (__FreeBSD__) || defined (__OpenBSD__)
    frequency /= 1000;
 #endif
    if (!cpufreq_config->status->can_set_frequency)
@@ -548,8 +554,32 @@
 {
    char buf[4096];
    Eina_List *l;
-   // FIXME: this sssumes all cores accept the same freqs/ might be wrong
-#ifdef __FreeBSD__
+   // FIXME: this assumes all cores accept the same freqs/ might be wrong
+
+#ifdef __OpenBSD__
+   int freq, getMhz[] = {CTL_HW, HW_CPUSPEED};
+   size_t len = sizeof(buf);
+
+   if (sysctl(getMhz, 2, buf, &len, NULL, 0) == 0)
+     {
+        if (s->frequencies)
+          {
+             eina_list_free(s->frequencies);
+             s->frequencies = NULL;
+          }
+
+        freq = atoi(buf);
+        s->frequencies = eina_list_append(s->frequencies, (void *)freq);
+
+        if (s->governors)
+          {
+             for (l = s->governors; l; l = l->next)
+               free(l->data);
+             eina_list_free(s->governors);
+             s->governors = NULL;
+          }
+     }
+#elif defined (__FreeBSD__)
    int freq, i;
    size_t len = 0;
    char *freqs, *pos, *q;
@@ -665,15 +695,25 @@
 static int
 _cpufreq_status_check_current(Status *s)
 {
-   char buf[4096];
-   int i;
-   FILE *f;
    int ret = 0;
    int frequency = 0;
-   int frequency_min = 0x7fffffff;
-   int frequency_max = 0;
-   int freqtot = 0;
-#ifdef __FreeBSD__
+
+#if defined (__OpenBSD__)
+   size_t len = sizeof(frequency);
+   int getMhz[] = {CTL_HW, HW_CPUSPEED};
+   s->active = 0;
+
+   if (sysctl(getMhz, 2, &frequency, &len, NULL, 0) == 0)
+     {
+        frequency *= 1000;
+        if (frequency != s->cur_frequency) ret = 1;
+        s->cur_frequency = frequency;
+        s->active = 1;
+     }
+
+   s->can_set_frequency = 0;
+   s->cur_governor = NULL;
+#elif defined (__FreeBSD__)
    int len = 4;
 
    s->active = 0;
@@ -690,6 +730,13 @@
    s->can_set_frequency = 1;
    s->cur_governor = NULL;
 #else
+   char buf[4096];
+   FILE *f;
+   int frequency_min = 0x7fffffff;
+   int frequency_max = 0;
+   int freqtot = 0;
+   int i;
+
    s->active = 0;
 
    _cpufreq_status_check_available(s);
@@ -724,7 +771,7 @@
 
 //  printf("%i | %i %i\n", frequency, frequency_min, frequency_max);
 
-   // FIXME: this sssumes all cores are on the same governor
+   // FIXME: this assumes all cores are on the same governor
    f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", "r");
    if (f)
      {
--- freqset.c   Sun Sep 30 11:19:34 2012
+++ freqset.c   Sun Sep 30 11:14:48 2012
@@ -15,6 +15,11 @@
 int
 main(int argc, char *argv[])
 {
+
+#ifdef __OpenBSD__
+   return 1;
+#endif
+
    if (argc != 3)
      {
         fprintf(stderr, "Invalid command. Syntax:\n");
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to