From: Shuya MAEDA <[EMAIL PROTECTED]> Date: Mon, 19 Jun 2006 14:36:46 +0900
> #define PSCHED_TADD2(tv, delta, tv_res) \ > ({ \ > - int __delta = (tv).tv_usec + (delta); \ > - (tv_res).tv_sec = (tv).tv_sec; \ > - if (__delta > USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= > USEC_PER_SEC; } \ > - (tv_res).tv_usec = __delta; \ > + int __delta = (delta); \ > + (tv_res) = (tv); \ > + if((delta) > USEC_PER_SEC) { \ > + (tv_res).tv_sec += (delta) / USEC_PER_SEC; \ > + __delta -= (delta) % USEC_PER_SEC; \ > + } \ > + (tv_res).tv_usec += __delta; \ > + if((tv_res).tv_usec >= USEC_PER_SEC) { \ > + (tv_res).tv_sec++; \ > + (tv_res).tv_usec -= USEC_PER_SEC; \ > + } \ > }) Divide and modulus can be extremely expensive on some systems, so let's try to avoid using them. It is probably sufficient to adjust the passed in delta only once if it is >= USEC_PER_SEC, but if you feel that is an unsafe assumption then please use a simply loop like this: while (__delta >= USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; } And please provide a proper "Signed-off-by: " line in your next patch submission. Thank you very much. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html