washerdryer: Use pkg-config for GTK build flags.
[dockapps.git] / wmlongrun / src / longrun_freebsd.c
blobab55e4b43decafeea272e7e53b0f1ac192d7a95e
1 /*
2 * longrun_freebsd.c - module to get LongRun(TM) status, for FreeBSD
4 * Copyright(C) 2001,2002 Seiichi SATO <ssato@sh.rim.or.jp>
6 * licensed under the GPL
7 */
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
13 #include <stdio.h>
14 #include <stdlib.h>
15 #if defined(HAVE_STRING_H)
16 #include <string.h>
17 #elif defined(HAVE_STRINGS_H)
18 #include <strings.h>
19 #endif
20 #include <unistd.h>
21 #include <err.h>
22 #include <sys/sysctl.h>
23 #include <sys/file.h>
24 #include "longrun.h"
25 #include "common.h"
27 #define LONGRUN_MODE_MINFREQUENCY 0x00
28 #define LONGRUN_MODE_ECONOMY 0x01
29 #define LONGRUN_MODE_PERFORMANCE 0x02
30 #define LONGRUN_MODE_MAXFREQUENCY 0x03
32 void
33 longrun_init(char *dummy, char *dummy2)
35 /* You don't need initialization under FreeBSD */
39 * percent: performance level (0 to 100)
40 * flags: performance/economy/unknown
41 * mhz: frequency
42 * volts: voltage
44 void
45 longrun_get_stat(int *percent, int *flags, int *mhz, int *voltz)
47 u_int ret_val;
48 size_t len;
50 *percent = *mhz = *voltz = *flags = 0;
52 /* level */
53 len = sizeof(ret_val);
54 if (sysctlbyname("hw.crusoe.percentage", &ret_val, &len, NULL, 0) == 0)
55 *percent = (int) ret_val;
57 /* frequency */
58 if (sysctlbyname("hw.crusoe.frequency", &ret_val, &len, NULL, 0) == 0)
59 *mhz = (int) ret_val;
61 /* voltage */
62 if (sysctlbyname("hw.crusoe.voltage", &ret_val, &len, NULL, 0) == 0)
63 *voltz = (int) ret_val;
65 /* flags */
66 if (sysctlbyname("hw.crusoe.longrun", &ret_val, &len, NULL, 0) == 0) {
67 switch (ret_val) {
68 case LONGRUN_MODE_MINFREQUENCY:
69 case LONGRUN_MODE_ECONOMY:
70 *flags = LONGRUN_FLAGS_ECONOMY;
71 break;
72 case LONGRUN_MODE_PERFORMANCE:
73 case LONGRUN_MODE_MAXFREQUENCY:
74 *flags = LONGRUN_FLAGS_PEFORMANCE;
75 break;
76 default:
77 *flags = LONGRUN_FLAGS_UNKNOWN;