Sysinfo Gadget: Unify define macro checking.

This commit is contained in:
Stephen 'Okra' Houston 2017-07-15 11:14:41 -05:00
parent d7538011ec
commit 139045c120
12 changed files with 38 additions and 38 deletions

View File

@ -605,7 +605,7 @@ sysinfo_batman_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
E_FREE_FUNC(inst->cfg->batman.configure, evas_object_del); E_FREE_FUNC(inst->cfg->batman.configure, evas_object_del);
EINA_LIST_FREE(inst->cfg->batman.handlers, handler) EINA_LIST_FREE(inst->cfg->batman.handlers, handler)
ecore_event_handler_del(handler); ecore_event_handler_del(handler);
#ifdef HAVE_EEZE #if defined(HAVE_EEZE)
_batman_udev_stop(inst); _batman_udev_stop(inst);
#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) #elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
(void) inst; (void) inst;
@ -731,7 +731,7 @@ _conf_item_get(int *id)
ci->batman.time_left = -2; ci->batman.time_left = -2;
ci->batman.have_battery = -2; ci->batman.have_battery = -2;
ci->batman.have_power = -2; ci->batman.have_power = -2;
#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ #if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__)
ci->batman.fuzzy = 0; ci->batman.fuzzy = 0;
#endif #endif
ci->batman.desktop_notifications = 0; ci->batman.desktop_notifications = 0;

View File

@ -27,12 +27,12 @@ struct _Battery
{ {
Instance *inst; Instance *inst;
const char *udi; const char *udi;
#if defined HAVE_EEZE || defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__ #if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
Ecore_Poller *poll; Ecore_Poller *poll;
#endif #endif
Eina_Bool present:1; Eina_Bool present:1;
Eina_Bool charging:1; Eina_Bool charging:1;
#if defined HAVE_EEZE || defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__ #if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
double last_update; double last_update;
double percent; double percent;
double current_charge; double current_charge;
@ -98,12 +98,12 @@ EINTERN void _batman_device_update(Instance *inst);
EINTERN int _batman_fallback_start(Instance *inst); EINTERN int _batman_fallback_start(Instance *inst);
EINTERN void _batman_fallback_stop(void); EINTERN void _batman_fallback_stop(void);
/* end batman_fallback.c */ /* end batman_fallback.c */
#ifdef HAVE_EEZE #if defined(HAVE_EEZE)
/* in batman_udev.c */ /* in batman_udev.c */
EINTERN int _batman_udev_start(Instance *inst); EINTERN int _batman_udev_start(Instance *inst);
EINTERN void _batman_udev_stop(Instance *inst); EINTERN void _batman_udev_stop(Instance *inst);
/* end batman_udev.c */ /* end batman_udev.c */
#elif !defined __OpenBSD__ && !defined __DragonFly__ && !defined __FreeBSD__ && !defined __NetBSD__ #elif !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
/* in batman_upower.c */ /* in batman_upower.c */
EINTERN int _batman_upower_start(Instance *inst); EINTERN int _batman_upower_start(Instance *inst);
EINTERNvoid _batman_upower_stop(void); EINTERNvoid _batman_upower_stop(void);

View File

@ -1,6 +1,6 @@
#include "batman.h" #include "batman.h"
#ifdef HAVE_CFBASE_H #if defined(HAVE_CFBASE_H)
# include <CFBase.h> # include <CFBase.h>
# include <CFNumber.h> # include <CFNumber.h>
# include <CFArray.h> # include <CFArray.h>

View File

@ -69,7 +69,7 @@ _cpuclock_cb_sort(const void *item1, const void *item2)
return 0; return 0;
} }
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
static void static void
_cpuclock_set_thread_frequency(void *data, Ecore_Thread *th EINA_UNUSED) _cpuclock_set_thread_frequency(void *data, Ecore_Thread *th EINA_UNUSED)
{ {
@ -88,7 +88,7 @@ _cpuclock_set_thread_done(void *data EINA_UNUSED, Ecore_Thread *th EINA_UNUSED)
void void
_cpuclock_set_governor(const char *governor) _cpuclock_set_governor(const char *governor)
{ {
#if defined __FreeBSD__ || defined __OpenBSD__ #if defined(__FreeBSD__) || defined(__OpenBSD__)
return; return;
#endif #endif
char buf[4096], exe[4096]; char buf[4096], exe[4096];
@ -113,7 +113,7 @@ _cpuclock_set_frequency(int frequency)
#endif #endif
snprintf(buf, sizeof(buf), "%i", frequency); snprintf(buf, sizeof(buf), "%i", frequency);
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
const char *freq; const char *freq;
freq = eina_stringshare_add(buf); freq = eina_stringshare_add(buf);
ecore_thread_run(_cpuclock_set_thread_frequency, _cpuclock_set_thread_done, NULL, freq); ecore_thread_run(_cpuclock_set_thread_frequency, _cpuclock_set_thread_done, NULL, freq);
@ -132,7 +132,7 @@ _cpuclock_set_frequency(int frequency)
void void
_cpuclock_set_pstate(int min, int max, int turbo) _cpuclock_set_pstate(int min, int max, int turbo)
{ {
#if defined __FreeBSD__ || defined __OpenBSD__ #if defined(__FreeBSD__) || defined(__OpenBSD__)
return; return;
#endif #endif
char buf[4096], exe[4096]; char buf[4096], exe[4096];
@ -444,7 +444,7 @@ _cpuclock_status_check_available(Cpu_Status *s)
#endif #endif
// FIXME: this assumes all cores accept the same freqs/ might be wrong // FIXME: this assumes all cores accept the same freqs/ might be wrong
#if defined (__OpenBSD__) #if defined(__OpenBSD__)
int p; int p;
if (s->frequencies) if (s->frequencies)
@ -462,7 +462,7 @@ _cpuclock_status_check_available(Cpu_Status *s)
s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p); s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p);
p = 25; p = 25;
s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p); s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p);
#elif defined (__FreeBSD__) #elif defined(__FreeBSD__)
int freq; int freq;
size_t len = sizeof(buf); size_t len = sizeof(buf);
char *pos, *q; char *pos, *q;
@ -631,7 +631,7 @@ _cpuclock_status_check_current(Cpu_Status *s)
int ret = 0; int ret = 0;
int frequency = 0; int frequency = 0;
#if defined (__OpenBSD__) #if defined(__OpenBSD__)
size_t len = sizeof(frequency); size_t len = sizeof(frequency);
int percent, mib[] = {CTL_HW, HW_CPUSPEED}; int percent, mib[] = {CTL_HW, HW_CPUSPEED};
s->active = 0; s->active = 0;
@ -656,7 +656,7 @@ _cpuclock_status_check_current(Cpu_Status *s)
s->can_set_frequency = 1; s->can_set_frequency = 1;
s->cur_governor = NULL; s->cur_governor = NULL;
#elif defined (__FreeBSD__) #elif defined(__FreeBSD__)
size_t len = sizeof(frequency); size_t len = sizeof(frequency);
s->active = 0; s->active = 0;
@ -852,7 +852,7 @@ _cpuclock_cb_frequency_check_notify(void *data,
if ((inst->cfg->cpuclock.status) && (status) && if ((inst->cfg->cpuclock.status) && (status) &&
( (
#ifdef __OpenBSD__ #if defined(__OpenBSD__)
(status->cur_percent != inst->cfg->cpuclock.status->cur_percent ) || (status->cur_percent != inst->cfg->cpuclock.status->cur_percent ) ||
#endif #endif
(status->cur_frequency != inst->cfg->cpuclock.status->cur_frequency ) || (status->cur_frequency != inst->cfg->cpuclock.status->cur_frequency ) ||

View File

@ -26,7 +26,7 @@ EINTERN void _cpuclock_config_updated(Instance *inst);
EINTERN void _cpuclock_set_governor(const char *governor); EINTERN void _cpuclock_set_governor(const char *governor);
EINTERN void _cpuclock_set_frequency(int frequency); EINTERN void _cpuclock_set_frequency(int frequency);
EINTERN void _cpuclock_set_pstate(int min, int max, int turbo); EINTERN void _cpuclock_set_pstate(int min, int max, int turbo);
#if defined __OpenBSD__ || defined __FreeBSD__ #if defined(__OpenBSD__) || defined(__FreeBSD__)
EINTERN int _cpuclock_sysctl_frequency(int new_perf); EINTERN int _cpuclock_sysctl_frequency(int new_perf);
#endif #endif

View File

@ -567,7 +567,7 @@ cpuclock_configure(Instance *inst)
elm_radio_state_value_set(o, i); elm_radio_state_value_set(o, i);
E_ALIGN(o, 0.0, 0.0); E_ALIGN(o, 0.0, 0.0);
E_WEIGHT(o, EVAS_HINT_EXPAND, 0); E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
#ifdef __OpenBSD__ #if defined(__OpenBSD__)
snprintf(buf, sizeof(buf), "%i %%", frequency); snprintf(buf, sizeof(buf), "%i %%", frequency);
#else #else
if (frequency < 1000000) if (frequency < 1000000)
@ -581,7 +581,7 @@ cpuclock_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _frequency_changed, cc); evas_object_smart_callback_add(o, "changed", _frequency_changed, cc);
evas_object_show(o); evas_object_show(o);
#ifdef __OpenBSD__ #if defined(__OpenBSD__)
if (inst->cfg->cpuclock.status->cur_percent == frequency) if (inst->cfg->cpuclock.status->cur_percent == frequency)
value = i; value = i;
#else #else

View File

@ -462,10 +462,10 @@ sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
} }
EINA_LIST_FREE(inst->cfg->memusage.handlers, handler) EINA_LIST_FREE(inst->cfg->memusage.handlers, handler)
ecore_event_handler_del(handler); ecore_event_handler_del(handler);
inst->cfg->thermal.done = EINA_TRUE; inst->cfg->memusage.done = EINA_TRUE;
if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO) if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO)
{ {
if (inst->cfg->memusage.done && inst->cfg->cpumonitor.done && if (inst->cfg->thermal.done && inst->cfg->cpumonitor.done &&
inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->batman.done) inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->batman.done)
{ {
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg); sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);

View File

@ -28,7 +28,7 @@ sysinfo_init(void)
E_CONFIG_VAL(D, T, batman.suspend_below, INT); E_CONFIG_VAL(D, T, batman.suspend_below, INT);
E_CONFIG_VAL(D, T, batman.suspend_method, INT); E_CONFIG_VAL(D, T, batman.suspend_method, INT);
E_CONFIG_VAL(D, T, batman.force_mode, INT); E_CONFIG_VAL(D, T, batman.force_mode, INT);
#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ #if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__)
E_CONFIG_VAL(D, T, batman.fuzzy, INT); E_CONFIG_VAL(D, T, batman.fuzzy, INT);
#endif #endif
E_CONFIG_VAL(D, T, batman.desktop_notifications, INT); E_CONFIG_VAL(D, T, batman.desktop_notifications, INT);
@ -82,7 +82,7 @@ sysinfo_init(void)
ci->batman.time_left = -2; ci->batman.time_left = -2;
ci->batman.have_battery = -2; ci->batman.have_battery = -2;
ci->batman.have_power = -2; ci->batman.have_power = -2;
#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ #if defined(HAVE_EEZ)E || defined(__OpenBSD__) || defined(__NetBSD__)
ci->batman.fuzzy = 0; ci->batman.fuzzy = 0;
#endif #endif
ci->batman.desktop_notifications = 0; ci->batman.desktop_notifications = 0;

View File

@ -101,7 +101,7 @@ _conf_item_get(int *id)
ci->batman.time_left = -2; ci->batman.time_left = -2;
ci->batman.have_battery = -2; ci->batman.have_battery = -2;
ci->batman.have_power = -2; ci->batman.have_power = -2;
#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ #if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__)
ci->batman.fuzzy = 0; ci->batman.fuzzy = 0;
#endif #endif
ci->batman.desktop_notifications = 0; ci->batman.desktop_notifications = 0;

View File

@ -2,7 +2,7 @@
#define SYSINFO_H #define SYSINFO_H
#include "e.h" #include "e.h"
#ifdef HAVE_EEZE #if defined(HAVE_EEZE)
# include <Eeze.h> # include <Eeze.h>
#else #else
# include <Eldbus.h> # include <Eldbus.h>
@ -39,7 +39,7 @@ enum _Netstatus_Unit
typedef enum _Sensor_Type typedef enum _Sensor_Type
{ {
SENSOR_TYPE_NONE, SENSOR_TYPE_NONE,
#if defined __FreeBSD__ || defined __OpenBSD__ || defined __DragonFly__ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
SENSOR_TYPE_FREEBSD, SENSOR_TYPE_FREEBSD,
SENSOR_TYPE_OPENBSD, SENSOR_TYPE_OPENBSD,
#else #else
@ -77,7 +77,7 @@ struct _Tempthread
const char *sensor_path; const char *sensor_path;
void *extn; void *extn;
E_Powersave_Sleeper *sleeper; E_Powersave_Sleeper *sleeper;
#ifdef HAVE_EEZE #if defined(HAVE_EEZE)
Eina_List *tempdevs; Eina_List *tempdevs;
#endif #endif
Eina_Bool initted : 1; Eina_Bool initted : 1;
@ -88,7 +88,7 @@ struct _Cpu_Status
Eina_List *frequencies; Eina_List *frequencies;
Eina_List *governors; Eina_List *governors;
int cur_frequency; int cur_frequency;
#ifdef __OpenBSD__ #if defined(__OpenBSD__)
int cur_percent; int cur_percent;
#endif #endif
int cur_min_frequency; int cur_min_frequency;
@ -146,11 +146,11 @@ struct _Config_Item
int desktop_notifications; int desktop_notifications;
Eina_List *handlers; Eina_List *handlers;
Eina_Bool done; Eina_Bool done;
#ifdef HAVE_EEZE #if defined(HAVE_EEZE)
Eeze_Udev_Watch *acwatch; Eeze_Udev_Watch *acwatch;
Eeze_Udev_Watch *batwatch; Eeze_Udev_Watch *batwatch;
#endif #endif
#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ #if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__)
Eina_Bool fuzzy; Eina_Bool fuzzy;
int fuzzcount; int fuzzcount;
#endif #endif
@ -167,7 +167,7 @@ struct _Config_Item
int temp; int temp;
const char *sensor_name; const char *sensor_name;
Unit units; Unit units;
#ifdef HAVE_EEZE #if defined(HAVE_EEZE)
Ecore_Poller *poller; Ecore_Poller *poller;
Tempthread *tth; Tempthread *tth;
#endif #endif

View File

@ -13,11 +13,11 @@ struct _Thermal_Config
}; };
#ifdef HAVE_EEZE #if defined(HAVE_EEZE)
EINTERN int thermal_udev_get(Tempthread *tth); EINTERN int thermal_udev_get(Tempthread *tth);
#endif #endif
#if defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ #if defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__)
EINTERN int thermal_sysctl_get(Tempthread *tth); EINTERN int thermal_sysctl_get(Tempthread *tth);
#endif #endif

View File

@ -49,7 +49,7 @@ init(Tempthread *tth)
size_t sdlen = sizeof(snsrdev); size_t sdlen = sizeof(snsrdev);
#endif #endif
#if defined (__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
unsigned i; unsigned i;
size_t len; size_t len;
int rc; int rc;
@ -71,7 +71,7 @@ init(Tempthread *tth)
eina_stringshare_del(tth->sensor_path); eina_stringshare_del(tth->sensor_path);
tth->sensor_path = NULL; tth->sensor_path = NULL;
#if defined (__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
for (i = 0; sources[i]; i++) for (i = 0; sources[i]; i++)
{ {
rc = sysctlbyname(sources[i], NULL, NULL, NULL, 0); rc = sysctlbyname(sources[i], NULL, NULL, NULL, 0);
@ -150,11 +150,11 @@ check(Tempthread *tth)
{ {
int ret = 0; int ret = 0;
int temp = 0; int temp = 0;
#if defined (__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
size_t len; size_t len;
size_t ftemp = 0; size_t ftemp = 0;
#endif #endif
#if defined (__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
Extn *extn = tth->extn; Extn *extn = tth->extn;
#endif #endif
@ -164,7 +164,7 @@ check(Tempthread *tth)
*/ */
if (tth->sensor_type == SENSOR_TYPE_FREEBSD) if (tth->sensor_type == SENSOR_TYPE_FREEBSD)
{ {
#if defined (__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
len = sizeof(ftemp); len = sizeof(ftemp);
if (sysctl(extn->mib, extn->miblen, &ftemp, &len, NULL, 0) == 0) if (sysctl(extn->mib, extn->miblen, &ftemp, &len, NULL, 0) == 0)
{ {