Build Linux-only functions only on Linux

This commit is contained in:
Aaron Marcher 2018-03-18 23:26:13 +01:00
parent 25bda72e64
commit ebf5a35052
10 changed files with 20 additions and 0 deletions

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -54,3 +55,4 @@ battery_state(const char *bat)
} }
return (i == LEN(map)) ? "?" : map[i].symbol; return (i == LEN(map)) ? "?" : map[i].symbol;
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -61,3 +62,4 @@ cpu_iowait(void)
return bprintf("%d", perc); return bprintf("%d", perc);
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <stdio.h> #include <stdio.h>
#include "../util.h" #include "../util.h"
@ -11,3 +12,4 @@ entropy(void)
return (pscanf("/proc/sys/kernel/random/entropy_avail", "%d", &num) == 1) ? return (pscanf("/proc/sys/kernel/random/entropy_avail", "%d", &num) == 1) ?
bprintf("%d", num) : NULL; bprintf("%d", num) : NULL;
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <err.h> #include <err.h>
#include <ifaddrs.h> #include <ifaddrs.h>
#include <netdb.h> #include <netdb.h>
@ -68,3 +69,4 @@ ipv6(const char *iface)
return NULL; return NULL;
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <stdio.h> #include <stdio.h>
#include "../util.h" #include "../util.h"
@ -50,3 +51,4 @@ ram_used(void)
bprintf("%f", (float)(total - free - buffers - cached) / 1024 / 1024) : bprintf("%f", (float)(total - free - buffers - cached) / 1024 / 1024) :
NULL; NULL;
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <err.h> #include <err.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -134,3 +135,4 @@ swap_used(void)
return bprintf("%f", (float)(total - free - cached) / 1024 / 1024); return bprintf("%f", (float)(total - free - cached) / 1024 / 1024);
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <stdio.h> #include <stdio.h>
#include "../util.h" #include "../util.h"
@ -11,3 +12,4 @@ temp(const char *file)
return (pscanf(file, "%d", &temp) == 1) ? return (pscanf(file, "%d", &temp) == 1) ?
bprintf("%d", temp / 1000) : NULL; bprintf("%d", temp / 1000) : NULL;
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#include "../util.h" #include "../util.h"
@ -16,3 +17,4 @@ uptime(void)
return bprintf("%dh %dm", h, m); return bprintf("%dh %dm", h, m);
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <err.h> #include <err.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/soundcard.h> #include <sys/soundcard.h>
@ -41,3 +42,4 @@ vol_perc(const char *card)
return bprintf("%d", v & 0xff); return bprintf("%d", v & 0xff);
} }
#endif

View file

@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifdef __linux__
#include <err.h> #include <err.h>
#include <ifaddrs.h> #include <ifaddrs.h>
#include <linux/wireless.h> #include <linux/wireless.h>
@ -88,3 +89,4 @@ wifi_essid(const char *iface)
else else
return id; return id;
} }
#endif