Message ID | 20090609215425.GA2893@ami.dom.local |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Tue, Jun 09, 2009 at 11:54:25PM +0200, Jarek Poplawski wrote: > On Tue, Jun 09, 2009 at 04:03:16PM +0200, Patrick McHardy wrote: ... > > It seems inconsistent to have the time2tick() function take a > > double, but return an unsigned from tick2time(). If we're going > > to change this, please keep them symetrical (you could even use > > floor() in tick2time() to make it more explicit). ... > tc_core_tick2time() is used differently; it usually gets integers, to > show them as time. But even if not so, we have division here. So, I'm > not sure it's really needed, but if you confirm I'll do it in a > separate patch. OOPS! I argued for double as argument, but you're right tick2time() should return double for consistency. I'll send a separate patch. Sorry, Jarek P. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/tc/tc_core.c b/tc/tc_core.c index 9a0ff39..c9c76b4 100644 --- a/tc/tc_core.c +++ b/tc/tc_core.c @@ -27,18 +27,18 @@ static double tick_in_usec = 1; static double clock_factor = 1; -int tc_core_time2big(unsigned time) +int tc_core_time2big(double time) { - __u64 t = time; + __u64 t; - t *= tick_in_usec; + t = ceil(time * tick_in_usec); return (t >> 32) != 0; } -unsigned tc_core_time2tick(unsigned time) +unsigned tc_core_time2tick(double time) { - return time*tick_in_usec; + return ceil(time * tick_in_usec); } unsigned tc_core_tick2time(unsigned tick) diff --git a/tc/tc_core.h b/tc/tc_core.h index 5a693ba..0ac65aa 100644 --- a/tc/tc_core.h +++ b/tc/tc_core.h @@ -13,8 +13,8 @@ enum link_layer { }; -int tc_core_time2big(unsigned time); -unsigned tc_core_time2tick(unsigned time); +int tc_core_time2big(double time); +unsigned tc_core_time2tick(double time); unsigned tc_core_tick2time(unsigned tick); unsigned tc_core_time2ktime(unsigned time); unsigned tc_core_ktime2time(unsigned ktime);