* Nordlund Kim (Nokia-NET/Helsinki) <[EMAIL PROTECTED]> 2006-09-27 11:50
> basic_change() won't work without this patch if we compile the
> kernel with the GCC version in RHEL5...
>
> gcc version 4.1.1 20060817 (Red Hat 4.1.1-18)
>
> which optimizes the code like this (objdump -S inttest.c) ...
>
> int main()
> {
> 0: 55 push %ebp
> 1: 89 e5 mov %esp,%ebp
> int i = 0x80000000;
> do {
> printf(KERN_ERR "in do %d\n", i);
> 3: 68 00 00 00 80 push $0x80000000
> 8: 68 00 00 00 00 push $0x0
> d: e8 fc ff ff ff call e <main+0xe>
> } while (--i > 0);
> printf(KERN_ERR "out of do %d\n", i);
> 12: 68 00 00 00 80 push $0x80000000
> 17: 68 0a 00 00 00 push $0xa
> 1c: e8 fc ff ff ff call 1d <main+0x1d>
> return 0;
> }
> 21: 31 c0 xor %eax,%eax
> 23: c9 leave
> 24: c3 ret
>
> # ./inttest
> in do -2147483648
> out of do -2147483648
Very interesting, naturally I tried the same after Patrick's
comment but gcc 20060901 produced code as expected, thus
staying in the loop. But now after specifying -Os gcc seems
to turn on some optimziation which produces the same code as
above.
I'm not sure I understand this optimization :-)
> So I would suggest to apply this patch to be compatible with the
> GCC version in RHEL5, and simply to make code clearer (to the
> intended idea).
Yes.
-
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