MT#55283 modernise timeval_from_us

Change-Id: I745365e9c0c3c055e6972d18ab4593b9589f55f5
pull/1910/head
Richard Fuchs 10 months ago
parent 89abf47989
commit 5dd0a387a3

@ -136,7 +136,7 @@ GString *print_graphite_data(void) {
struct timeval avg_duration;
uint64_t managed_sess = atomic64_get_na(&rtpe_stats_graphite_diff.managed_sess);
if (managed_sess)
timeval_from_us(&avg_duration, atomic64_get_na(&rtpe_stats_graphite_diff.call_duration) / managed_sess);
avg_duration = timeval_from_us(atomic64_get_na(&rtpe_stats_graphite_diff.call_duration) / managed_sess);
else
avg_duration = (struct timeval) {0,0};
GPF("average_call_dur %llu.%06llu",(unsigned long long)avg_duration.tv_sec,(unsigned long long)avg_duration.tv_usec);

@ -1601,7 +1601,7 @@ static void create_everything(void) {
gettimeofday(&rtpe_latest_graphite_interval_start, NULL);
timeval_from_us(&tmp_tv, (long long) rtpe_config.graphite_interval*1000000);
tmp_tv = timeval_from_us((long long) rtpe_config.graphite_interval*1000000);
set_graphite_interval_tv(&tmp_tv);
if (!media_player_preload_files(rtpe_config.preload_media_files))

@ -1121,9 +1121,7 @@ static atomic64 strtoa64(const char *c, char **endp, int base) {
}
static struct timeval strtotimeval(const char *c, char **endp, int base) {
long long ll = strtoll(c, endp, base);
struct timeval ret;
timeval_from_us(&ret, ll);
return ret;
return timeval_from_us(ll);
}
define_get_int_type(time_t, time_t, strtoull);

@ -350,23 +350,20 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(rwlock_w_lock_t, rwlock_ptr_unlock_r)
INLINE long long timeval_us(const struct timeval *t) {
return (long long) ((long long) t->tv_sec * 1000000LL) + t->tv_usec;
}
INLINE void timeval_from_us(struct timeval *t, long long ms) {
t->tv_sec = ms/1000000LL;
t->tv_usec = ms%1000000LL;
INLINE struct timeval timeval_from_us(long long ms) {
return (struct timeval) { .tv_sec = ms/1000000LL, .tv_usec = ms%1000000LL };
}
INLINE long long timeval_diff(const struct timeval *a, const struct timeval *b) {
return timeval_us(a) - timeval_us(b);
}
INLINE void timeval_subtract(struct timeval *result, const struct timeval *a, const struct timeval *b) {
timeval_from_us(result, timeval_diff(a, b));
*result = timeval_from_us(timeval_diff(a, b));
}
INLINE struct timeval timeval_add(const struct timeval *a, const struct timeval *b) {
struct timeval result;
timeval_from_us(&result, timeval_us(a) + timeval_us(b));
return result;
return timeval_from_us(timeval_us(a) + timeval_us(b));
}
INLINE void timeval_add_usec(struct timeval *tv, long usec) {
timeval_from_us(tv, timeval_us(tv) + usec);
*tv = timeval_from_us(timeval_us(tv) + usec);
}
INLINE int long_cmp(long long a, long long b) {
if (a == b)

Loading…
Cancel
Save