netdev
[Top] [All Lists]

Re: MSEC_TO_JIFFIES is messed up...

To: Ingo Molnar <mingo@xxxxxxx>
Subject: Re: MSEC_TO_JIFFIES is messed up...
From: Zan Lynx <zlynx@xxxxxxx>
Date: Wed, 12 May 2004 15:49:25 -0600
Cc: Davide Libenzi <davidel@xxxxxxxxxxxxxxx>, Jeff Garzik <jgarzik@xxxxxxxxx>, Greg KH <greg@xxxxxxxxx>, Andrew Morton <akpm@xxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Netdev <netdev@xxxxxxxxxxx>
In-reply-to: <20040512211255.GA20800@xxxxxxx>
References: <20040512020700.6f6aa61f.akpm@xxxxxxxx> <20040512181903.GG13421@xxxxxxxxx> <40A26FFA.4030701@xxxxxxxxx> <20040512193349.GA14936@xxxxxxx> <Pine.LNX.4.58.0405121247011.11950@xxxxxxxxxxxxxxxxxxxxxxx> <20040512200305.GA16078@xxxxxxx> <Pine.LNX.4.58.0405121400360.11950@xxxxxxxxxxxxxxxxxxxxxxx> <20040512211255.GA20800@xxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
On Wed, 2004-05-12 at 15:12, Ingo Molnar wrote:
> * Davide Libenzi <davidel@xxxxxxxxxxxxxxx> wrote:
> 
> > int foo(int i) {
> > 
> > 
> >         return i * 1000 / 1000;
> > }
> 
> try unsigned and you'll see:
> 
>         pushl   %ebp
>         movl    %esp, %ebp
>         movl    8(%ebp), %edx
>         movl    %edx, %eax
>         sall    $2, %eax
>         addl    %edx, %eax
>         leal    0(,%eax,4), %edx
>         addl    %edx, %eax
>         leal    0(,%eax,4), %edx
>         addl    %edx, %eax
>         leal    0(,%eax,8), %edx
>         movl    $274877907, %eax
>         mull    %edx
>         movl    %edx, %eax
>         shrl    $6, %eax
>         leave
>         ret
> 
>     Ingo

Being curious, I tried that and got the same results.  But this:

int f(unsigned int x)
{
        return x * (1000 / 1000);
}

creates this:
f:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
        leave
        ret
        .size   f, .-f
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)"

-- 
Zan Lynx <zlynx@xxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part

<Prev in Thread] Current Thread [Next in Thread>