mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roman Zippel <zippel@linux-m68k.org>
To: john stultz <johnstul@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	ioe-lkml@rameria.de, George Anzinger <george@mvista.com>,
	Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
Subject: Re: [RFC][PATCH] NTP shiftR cleanup
Date: Sat, 10 Sep 2005 03:39:48 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.61.0509100329270.3743@scrub.home> (raw)
In-Reply-To: <1126314217.3455.10.camel@cog.beaverton.ibm.com>

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

      parent reply	other threads:[~2005-09-10  1:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-10  1:03 john stultz
2005-09-10  1:15 ` YOSHIFUJI Hideaki / 吉藤英明
2005-09-10  1:39 ` Roman Zippel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0509100329270.3743@scrub.home \
    --to=zippel@linux-m68k.org \
    --cc=george@mvista.com \
    --cc=ioe-lkml@rameria.de \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ulrich.windl@rz.uni-regensburg.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®