lkml.org 
[lkml]   [2004]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: MSEC_TO_JIFFIES is messed up...
From
Date
On Wed, 2004-05-12 at 15:12, Ingo Molnar wrote:
> * Davide Libenzi <davidel@xmailserver.org> 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@acm.org>
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 14:03    [from the cache]
©2003-2011 Jasper Spaans