lkml.org 
[lkml]   [2005]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC][PATCH] NTP shiftR cleanup
Hi,

On Fri, 9 Sep 2005, john stultz wrote:

> +/* Required to safely shift negative values */
> +#define shiftR(x, s) ({ __typeof__(x) __x = x;\
> + __typeof__(s) __s = s; \
> + (__x < 0) ? (-((-__x) >> (__s))) : ((__x) >> (__s));})
> +

Some parenthesis are missing and some are redundant. Formatting it so it
looks more like normal function makes it more readable:

#define shiftR(x, s) ({ \
__typeof__(x) __x = (x); \
__typeof__(s) __s = (s); \
__x < 0 ? -(-__x >> __s) : __x >> __s; \
})

> @@ -792,13 +769,8 @@ static void update_wall_time_one_tick(vo
> * advance the tick more.
> */
> time_phase += time_adj;
> - if (time_phase <= -FINENSEC) {
> - long ltemp = -time_phase >> (SHIFT_SCALE - 10);
> - time_phase += ltemp << (SHIFT_SCALE - 10);
> - delta_nsec -= ltemp;
> - }
> - else if (time_phase >= FINENSEC) {
> - long ltemp = time_phase >> (SHIFT_SCALE - 10);
> + if (abs(time_phase) >= FINENSEC) {
> + long ltemp = shiftR(time_phase, (SHIFT_SCALE - 10));
> time_phase -= ltemp << (SHIFT_SCALE - 10);
> delta_nsec += ltemp;
> }

It would be interesting to check, whether gcc produces the same code here.

bye, Roman
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-09-10 03:43    [W:0.036 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site