Enlightenment: Fix double compare in batman and fix compilation on bsd.

This commit is contained in:
Stephen 'Okra' Houston 2017-01-07 04:49:57 -06:00
parent 0b0b6e6fd9
commit 9189293b46
6 changed files with 17 additions and 11 deletions

View File

@ -414,11 +414,11 @@ _batman_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
if (inst->o_main != event_data) return; if (inst->o_main != event_data) return;
#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__
_batman_sysctl_stop(); _batman_sysctl_stop();
#elif upower #elif defined(upower)
_batman_upower_stop(); _batman_upower_stop();
#else #else
_batman_fallback_stop(); _batman_fallback_stop();
@ -439,7 +439,7 @@ sysinfo_batman_remove(Instance *inst)
_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__
_batman_sysctl_stop(); _batman_sysctl_stop();
#elif upower #elif defined(upower)
_batman_upower_stop(); _batman_upower_stop();
#else #else
_batman_fallback_stop(); _batman_fallback_stop();

View File

@ -229,11 +229,11 @@ _batman_udev_battery_update(const char *syspath, Battery *bat, Instance *inst)
GET_STR(bat, model, POWER_SUPPLY_MODEL_NAME); GET_STR(bat, model, POWER_SUPPLY_MODEL_NAME);
GET_STR(bat, vendor, POWER_SUPPLY_MANUFACTURER); GET_STR(bat, vendor, POWER_SUPPLY_MANUFACTURER);
GET_NUM(bat, design_charge, POWER_SUPPLY_ENERGY_FULL_DESIGN); GET_NUM(bat, design_charge, POWER_SUPPLY_ENERGY_FULL_DESIGN);
if (!bat->design_charge) if (eina_dbl_exact(bat->design_charge, 0))
GET_NUM(bat, design_charge, POWER_SUPPLY_CHARGE_FULL_DESIGN); GET_NUM(bat, design_charge, POWER_SUPPLY_CHARGE_FULL_DESIGN);
} }
GET_NUM(bat, last_full_charge, POWER_SUPPLY_ENERGY_FULL); GET_NUM(bat, last_full_charge, POWER_SUPPLY_ENERGY_FULL);
if (!bat->last_full_charge) if (eina_dbl_exact(bat->last_full_charge, 0))
GET_NUM(bat, last_full_charge, POWER_SUPPLY_CHARGE_FULL); GET_NUM(bat, last_full_charge, POWER_SUPPLY_CHARGE_FULL);
test = eeze_udev_syspath_get_property(bat->udi, "POWER_SUPPLY_ENERGY_NOW"); test = eeze_udev_syspath_get_property(bat->udi, "POWER_SUPPLY_ENERGY_NOW");
if (!test) if (!test)
@ -245,9 +245,9 @@ _batman_udev_battery_update(const char *syspath, Battery *bat, Instance *inst)
charge = strtod(test, NULL); charge = strtod(test, NULL);
eina_stringshare_del(test); eina_stringshare_del(test);
t = ecore_time_get(); t = ecore_time_get();
if ((bat->got_prop) && (charge != bat->current_charge) && bat->current_charge != 0) if ((bat->got_prop) && (!eina_dbl_exact(charge, bat->current_charge)) && (!eina_dbl_exact(bat->current_charge, 0)))
charge_rate = ((charge - bat->current_charge) / (t - bat->last_update)); charge_rate = ((charge - bat->current_charge) / (t - bat->last_update));
if (charge_rate != 0 || bat->last_update == 0 || bat->current_charge == 0) if ((!eina_dbl_exact(charge_rate, 0)) || eina_dbl_exact(bat->last_update, 0) || eina_dbl_exact(bat->current_charge, 0))
{ {
bat->last_update = t; bat->last_update = t;
bat->current_charge = charge; bat->current_charge = charge;

View File

@ -1,7 +1,10 @@
#include "cpuclock.h" #include "cpuclock.h"
#if defined(__OpenBSD__) || defined(__NetBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#endif
typedef struct _Thread_Config Thread_Config; typedef struct _Thread_Config Thread_Config;
struct _Thread_Config struct _Thread_Config
{ {
int interval; int interval;
@ -9,7 +12,6 @@ struct _Thread_Config
}; };
typedef struct _Pstate_Config Pstate_Config; typedef struct _Pstate_Config Pstate_Config;
struct _Pstate_Config struct _Pstate_Config
{ {
Instance *inst; Instance *inst;
@ -77,7 +79,7 @@ _cpuclock_set_thread_frequency(void *data, Ecore_Thread *th EINA_UNUSED)
const char *freq = data; const char *freq = data;
#if defined __FreeBSD__ || defined __OpenBSD__ #if defined __FreeBSD__ || defined __OpenBSD__
_cpuclock_sysctl_set("frequency", freq); _cpuclock_sysctl_frequency(freq);
return; return;
#endif #endif
_cpuclock_sysfs_setall("scaling_setspeed", freq); _cpuclock_sysfs_setall("scaling_setspeed", freq);

View File

@ -8,7 +8,7 @@ int _cpuclock_sysfs_setall(const char *control, const char *value);
int _cpuclock_sysfs_set(const char *control, const char *value); int _cpuclock_sysfs_set(const char *control, const char *value);
int _cpuclock_sysfs_pstate(int min, int max, int turbo); int _cpuclock_sysfs_pstate(int min, int max, int turbo);
#if defined __OpenBSD__ || defined __FreeBSD__ #if defined __OpenBSD__ || defined __FreeBSD__
int _cpuclock_sysctl_frequency(int new_perf) int _cpuclock_sysctl_frequency(int new_perf);
#endif #endif
#endif #endif

View File

@ -1,3 +1,4 @@
#if defined(__linux__)
#include "thermal.h" #include "thermal.h"
typedef struct typedef struct
@ -429,3 +430,5 @@ thermal_fallback_get(Tempthread *tth)
temp = check(tth); temp = check(tth);
return temp; return temp;
} }
#endif

View File

@ -177,6 +177,7 @@ check(Tempthread *tth)
else else
goto error; goto error;
#endif #endif
}
else if (tth->sensor_type == SENSOR_TYPE_OPENBSD) else if (tth->sensor_type == SENSOR_TYPE_OPENBSD)
{ {
#ifdef __OpenBSD_ #ifdef __OpenBSD_