1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-15 19:56:55 +00:00

Use lround instead of std::lround

for unknown reasons DragonFly's gcc does not have lround in the std namespace
cf. sf.net #3289079
This commit is contained in:
Pavel Labath 2012-07-13 20:17:54 +02:00
parent ef6282fedc
commit b34a1a21e7
9 changed files with 16 additions and 16 deletions

View File

@ -190,7 +190,7 @@ namespace {
aud_result get_res() aud_result get_res()
{ {
uint32_t period = std::max( uint32_t period = std::max(
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l lround(music_player_interval.get(*state)/active_update_interval()), 1l
); );
return conky::register_cb<audacious_cb>(period)->get_result_copy(); return conky::register_cb<audacious_cb>(period)->get_result_copy();
} }

View File

@ -174,7 +174,7 @@ struct curl_data {
/* prints result data to text buffer, used by $curl */ /* prints result data to text buffer, used by $curl */
void ccurl_process_info(char *p, int p_max_size, const std::string &uri, int interval) void ccurl_process_info(char *p, int p_max_size, const std::string &uri, int interval)
{ {
uint32_t period = std::max(std::lround(interval/active_update_interval()), 1l); uint32_t period = std::max(lround(interval/active_update_interval()), 1l);
auto cb = conky::register_cb<simple_curl_cb>(period, uri); auto cb = conky::register_cb<simple_curl_cb>(period, uri);
strncpy(p, cb->get_result_copy().c_str(), p_max_size); strncpy(p, cb->get_result_copy().c_str(), p_max_size);

View File

@ -148,7 +148,7 @@ void print_cmus_##type(struct text_object *obj, char *p, int p_max_size) \
{ \ { \
(void)obj; \ (void)obj; \
uint32_t period = std::max( \ uint32_t period = std::max( \
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l \ lround(music_player_interval.get(*state)/active_update_interval()), 1l \
); \ ); \
const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy(); \ const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy(); \
snprintf(p, p_max_size, "%s", (cmus.type.length() ? cmus.type.c_str() : alt)); \ snprintf(p, p_max_size, "%s", (cmus.type.length() ? cmus.type.c_str() : alt)); \
@ -170,7 +170,7 @@ uint8_t cmus_percent(struct text_object *obj)
{ {
(void)obj; (void)obj;
uint32_t period = std::max( uint32_t period = std::max(
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l); lround(music_player_interval.get(*state)/active_update_interval()), 1l);
const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy(); const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy();
return (uint8_t) round(cmus.progress * 100.0f); return (uint8_t) round(cmus.progress * 100.0f);
} }
@ -179,7 +179,7 @@ double cmus_progress(struct text_object *obj)
{ {
(void)obj; (void)obj;
uint32_t period = std::max( uint32_t period = std::max(
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l); lround(music_player_interval.get(*state)/active_update_interval()), 1l);
const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy(); const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy();
return (double) cmus.progress; return (double) cmus.progress;
} }
@ -188,7 +188,7 @@ void print_cmus_totaltime(struct text_object *obj, char *p, int p_max_size)
{ {
(void)obj; (void)obj;
uint32_t period = std::max( uint32_t period = std::max(
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l); lround(music_player_interval.get(*state)/active_update_interval()), 1l);
const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy(); const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy();
format_seconds_short(p, p_max_size, atol(cmus.totaltime.c_str())); format_seconds_short(p, p_max_size, atol(cmus.totaltime.c_str()));
} }
@ -197,7 +197,7 @@ void print_cmus_timeleft(struct text_object *obj, char *p, int p_max_size)
{ {
(void)obj; (void)obj;
uint32_t period = std::max( uint32_t period = std::max(
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l); lround(music_player_interval.get(*state)/active_update_interval()), 1l);
const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy(); const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy();
//format_seconds_short(p, p_max_size, atol(cmus.timeleft.c_str())); //format_seconds_short(p, p_max_size, atol(cmus.timeleft.c_str()));
format_seconds_short(p, p_max_size, (long)cmus.timeleft); format_seconds_short(p, p_max_size, (long)cmus.timeleft);
@ -207,7 +207,7 @@ void print_cmus_curtime(struct text_object *obj, char *p, int p_max_size)
{ {
(void)obj; (void)obj;
uint32_t period = std::max( uint32_t period = std::max(
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l); lround(music_player_interval.get(*state)/active_update_interval()), 1l);
const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy(); const cmus_result &cmus = conky::register_cb<cmus_cb>(period)->get_result_copy();
format_seconds_short(p, p_max_size, atol(cmus.curtime.c_str())); format_seconds_short(p, p_max_size, atol(cmus.curtime.c_str()));
} }

View File

@ -244,7 +244,7 @@ void print_execi(struct text_object *obj, char *p, int p_max_size)
if (!ed) if (!ed)
return; return;
uint32_t period = std::max(std::lround(ed->interval/active_update_interval()), 1l); uint32_t period = std::max(lround(ed->interval/active_update_interval()), 1l);
auto cb = conky::register_cb<exec_cb>(period, !obj->thread, ed->cmd); auto cb = conky::register_cb<exec_cb>(period, !obj->thread, ed->cmd);
@ -264,7 +264,7 @@ double execi_barval(struct text_object *obj)
if (!ed) if (!ed)
return 0; return 0;
uint32_t period = std::max(std::lround(ed->interval/active_update_interval()), 1l); uint32_t period = std::max(lround(ed->interval/active_update_interval()), 1l);
auto cb = conky::register_cb<exec_cb>(period, !obj->thread, ed->cmd); auto cb = conky::register_cb<exec_cb>(period, !obj->thread, ed->cmd);

View File

@ -564,7 +564,7 @@ std::unique_ptr<mail_param_ex> parse_mail_args(mail_type type, const char *arg)
tmp += 3; tmp += 3;
sscanf(tmp, "%f", &interval); sscanf(tmp, "%f", &interval);
} }
mail->period = std::max(std::lround(interval/active_update_interval()), 1l); mail->period = std::max(lround(interval/active_update_interval()), 1l);
tmp = (char*)strstr(arg, "-p "); tmp = (char*)strstr(arg, "-p ");
if (tmp) { if (tmp) {

View File

@ -117,7 +117,7 @@ void print_moc_##type(struct text_object *obj, char *p, int p_max_size) \
{ \ { \
(void)obj; \ (void)obj; \
uint32_t period = std::max( \ uint32_t period = std::max( \
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l \ lround(music_player_interval.get(*state)/active_update_interval()), 1l \
); \ ); \
const moc_result &moc = conky::register_cb<moc_cb>(period)->get_result_copy(); \ const moc_result &moc = conky::register_cb<moc_cb>(period)->get_result_copy(); \
snprintf(p, p_max_size, "%s", (moc.type.length() ? moc.type.c_str() : alt)); \ snprintf(p, p_max_size, "%s", (moc.type.length() ? moc.type.c_str() : alt)); \

View File

@ -303,7 +303,7 @@ if (b) a=b; else a="";
mpd_result get_mpd() mpd_result get_mpd()
{ {
uint32_t period = std::max( uint32_t period = std::max(
std::lround(music_player_interval.get(*state)/active_update_interval()), 1l lround(music_player_interval.get(*state)/active_update_interval()), 1l
); );
return conky::register_cb<mpd_cb>(period)->get_result_copy(); return conky::register_cb<mpd_cb>(period)->get_result_copy();
} }

View File

@ -74,7 +74,7 @@ static void rss_process_info(char *p, int p_max_size, const std::string &uri, ch
{ {
char *str; char *str;
uint32_t period = std::max(std::lround(interval/active_update_interval()), 1l); uint32_t period = std::max(lround(interval/active_update_interval()), 1l);
auto cb = conky::register_cb<rss_cb>(period, uri); auto cb = conky::register_cb<rss_cb>(period, uri);

View File

@ -732,7 +732,7 @@ void wind_deg_to_dir(char *p, int p_max_size, int wind_deg) {
static void weather_forecast_process_info(char *p, int p_max_size, const static void weather_forecast_process_info(char *p, int p_max_size, const
std::string &uri, unsigned int day, char *data_type, int interval) std::string &uri, unsigned int day, char *data_type, int interval)
{ {
uint32_t period = std::max(std::lround(interval/active_update_interval()), 1l); uint32_t period = std::max(lround(interval/active_update_interval()), 1l);
auto cb = conky::register_cb<weather_cb<weather_forecast>>(period, uri); auto cb = conky::register_cb<weather_cb<weather_forecast>>(period, uri);
@ -774,7 +774,7 @@ static void weather_process_info(char *p, int p_max_size, const std::string &uri
"dust/sand", "squall", "sand storm", "dust storm" "dust/sand", "squall", "sand storm", "dust storm"
}; };
uint32_t period = std::max(std::lround(interval/active_update_interval()), 1l); uint32_t period = std::max(lround(interval/active_update_interval()), 1l);
auto cb = conky::register_cb<weather_cb<weather>>(period, uri); auto cb = conky::register_cb<weather_cb<weather>>(period, uri);