sysfs is a Linux-only feature.
authorNikos Ntarmos <ntarmos@cs.uoi.gr>
Sat, 28 Mar 2009 19:46:20 +0000 (21:46 +0200)
committerPhil Sutter <phil@nwl.cc>
Sun, 29 Mar 2009 00:25:48 +0000 (01:25 +0100)
Moving sysfs-related functions and defs out of common.h and into
linux.h, as sysfs exists only on Linux, and updating openbsd.c,
netbsd.c, and freebsd.c accordingly.

Signed-off-by: Nikos Ntarmos <ntarmos@cs.uoi.gr>

src/common.h
src/conky.c
src/freebsd.c
src/linux.h
src/netbsd.c

index 9658453..be18280 100644 (file)
@@ -70,18 +70,6 @@ struct net_stat {
 void clear_net_stats(void);
 struct net_stat *get_net_stat(const char *);
 
-int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
-       int *divisor, char *devtype);
-
-#define open_i2c_sensor(dev, type, n, divisor, devtype) \
-       open_sysfs_sensor("/sys/bus/i2c/devices/", dev, type, n, divisor, devtype)
-#define open_platform_sensor(dev, type, n, divisor, devtype) \
-       open_sysfs_sensor("/sys/bus/platform/devices/", dev, type, n, divisor, devtype)
-#define open_hwmon_sensor(dev, type, n, divisor, devtype) \
-       open_sysfs_sensor("/sys/class/hwmon/", dev, type, n, divisor, devtype)
-
-double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
-
 void get_adt746x_cpu(char *, size_t);
 void get_adt746x_fan(char *, size_t);
 
index a28530e..cb30a04 100644 (file)
@@ -627,12 +627,14 @@ static void free_text_objects(struct text_object *root)
                        case OBJ_acpitemp:
                                close(data.i);
                                break;
+#endif /* !__OpenBSD__ */
+#ifdef __linux__
                        case OBJ_i2c:
                        case OBJ_platform:
                        case OBJ_hwmon:
                                close(data.sysfs.fd);
                                break;
-#endif /* !__OpenBSD__ */
+#endif /* __linux__ */
                        case OBJ_time:
                        case OBJ_utime:
                                free(data.s);
@@ -1598,7 +1600,7 @@ static struct text_object *construct_text_object(const char *s,
                obj->data.pair.a = a;
                obj->data.pair.b = b;
 
-#ifndef __OpenBSD__
+#ifdef __linux__
        END OBJ(i2c, INFO_SYSFS)
                char buf1[64], buf2[64];
                int n;
@@ -2122,7 +2124,7 @@ static struct text_object *construct_text_object(const char *s,
        END OBJ(swapbar, INFO_MEM)
                scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
        END OBJ(sysname, 0)
-#ifndef __OpenBSD__
+#ifdef __linux__
        END OBJ(temp1, INFO_SYSFS)
                obj->type = OBJ_i2c;
                obj->data.sysfs.fd = open_i2c_sensor(0, "temp", 1,
@@ -3918,7 +3920,7 @@ static void generate_text_internal(char *p, int p_max_size,
                        OBJ(voffset) {
                                new_voffset(p, obj->data.i);
                        }
-#ifndef __OpenBSD__
+#ifdef __linux__
                        OBJ(i2c) {
                                double r;
 
@@ -3961,7 +3963,7 @@ static void generate_text_internal(char *p, int p_max_size,
                                        snprintf(p, p_max_size, "%.1f", r);
                                }
                        }
-#endif /* !__OpenBSD__ */
+#endif /* __linux__ */
                        OBJ(alignr) {
                                new_alignr(p, obj->data.i);
                        }
index d5859d7..a34a01e 100644 (file)
@@ -345,11 +345,6 @@ void update_cpu_usage()
        oldtotal = total;
 }
 
-double get_sysfs_info(int *fd, int arg, char *devtype, char *type)
-{
-       return 0.0;
-}
-
 void update_load_average()
 {
        double v[3];
@@ -450,12 +445,6 @@ int get_battery_perct_bar(const char *bar)
        return 0;
 }
 
-int open_sysfs_sensor(const char *dir, const char *dev, const char *type,
-               int n, int *div, char *devtype)
-{
-       return 0;
-}
-
 int open_acpi_temperature(const char *name)
 {
        return 0;
index b9ea657..4b1f098 100644 (file)
@@ -28,4 +28,16 @@ void update_gateway_info(void);
 enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME };
 void get_powerbook_batt_info(char *, size_t, int);
 
+int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
+       int *divisor, char *devtype);
+
+#define open_i2c_sensor(dev, type, n, divisor, devtype) \
+       open_sysfs_sensor("/sys/bus/i2c/devices/", dev, type, n, divisor, devtype)
+#define open_platform_sensor(dev, type, n, divisor, devtype) \
+       open_sysfs_sensor("/sys/bus/platform/devices/", dev, type, n, divisor, devtype)
+#define open_hwmon_sensor(dev, type, n, divisor, devtype) \
+       open_sysfs_sensor("/sys/class/hwmon/", dev, type, n, divisor, devtype)
+
+double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
+
 #endif /* _LINUX_H */
index 71d0a4c..8f054f9 100644 (file)
@@ -302,11 +302,6 @@ void update_cpu_usage()
        oldtotal = total;
 }
 
-double get_sysfs_info(int *fd, int div, char *devtype)
-{
-       return -1;
-}
-
 void update_load_average()
 {
        double v[3];
@@ -327,12 +322,6 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 {
 }
 
-int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
-               int *div, char *devtype)
-{
-       return -1;
-}
-
 int open_acpi_temperature(const char *name)
 {
        return -1;