From: deweerdt@free.fr
To: Arjan van de Ven <arjan@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Frederik Deweerdt <deweerdt@free.fr>,
Jan Engelhardt <jengelh@linux01.gwdg.de>,
linux-kernel@vger.kernel.org, tglx@linutronix.de
Subject: Re: -mm merge plans for 2.6.21
Date: Fri, 09 Feb 2007 15:05:10 +0100 [thread overview]
Message-ID: <1171029910.45cc7f967fdfe@imp.free.fr> (raw)
In-Reply-To: <1171024332.8675.155.camel@laptopd505.fenrus.org>
Quoting Arjan van de Ven <arjan@infradead.org>:
>
> >
> > As long as nobody takes the address of them (which wouldn't compile today
> > anyway) then the compiler should be able to not allocate store for these.
> > That they're const might help too.
>
> are you really sure?
I've run some tests, and the compiler seems to do the right thing -I must admit,
that I trusted the compiler to do it blindly on my first attempt :)- , see
below:
> cat flag.h
static const int __attribute__((__deprecated__)) SA_INTERRUPT = 0x123456;
> cat use_flag.c
#include <stdio.h>
#include "flag.h"
int main()
{
int flags = SA_INTERRUPT;
printf("%d", flags);
}
> cat dont_use_flag.c
#include <stdio.h>
#include "flag.h"
int main()
{
int flags = 0;
printf("%d", flags);
}
> gcc --version
gcc (GCC) 4.1.1 (Gentoo 4.1.1-r3)
> for i in *use_flag.c; do gcc -o $(echo $i | sed 's/.c//') -O2 -g $i; done
use_flag.c: In function 'main':
use_flag.c:6: warning: 'SA_INTERRUPT' is deprecated (declared at flag.h:1)
> size *use_flag
text data bss dec hex filename
897 260 4 1161 489 dont_use_flag
897 260 4 1161 489 use_flag
# The relevant parts of the compiled code, see how the flag is replaced with
# the const value in the code. It does not result in a code size increment.
> objdump -d {dont_,}use_flag | grep -A11 '<main>'
080483b0 <main>:
80483b0: 8d 4c 24 04 lea 0x4(%esp),%ecx
80483b4: 83 e4 f0 and $0xfffffff0,%esp
80483b7: ff 71 fc pushl 0xfffffffc(%ecx)
80483ba: 31 c0 xor %eax,%eax
80483bc: 55 push %ebp
80483bd: 89 e5 mov %esp,%ebp
80483bf: 51 push %ecx
80483c0: 83 ec 14 sub $0x14,%esp
80483c3: 89 44 24 04 mov %eax,0x4(%esp)
80483c7: c7 04 24 b8 84 04 08 movl $0x80484b8,(%esp)
80483ce: e8 05 ff ff ff call 80482d8 <printf@plt>
--
080483b0 <main>:
80483b0: 8d 4c 24 04 lea 0x4(%esp),%ecx
80483b4: 83 e4 f0 and $0xfffffff0,%esp
80483b7: ff 71 fc pushl 0xfffffffc(%ecx)
80483ba: b8 56 34 12 00 mov $0x123456,%eax
80483bf: 55 push %ebp
80483c0: 89 e5 mov %esp,%ebp
80483c2: 51 push %ecx
80483c3: 83 ec 14 sub $0x14,%esp
80483c6: 89 44 24 04 mov %eax,0x4(%esp)
80483ca: c7 04 24 b8 84 04 08 movl $0x80484b8,(%esp)
80483d1: e8 02 ff ff ff call 80482d8 <printf@plt>
======== With 3.4.3 ==========
$ gcc --version
gcc (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.fc3)
$ size {dont_,}use_flag
text data bss dec hex filename
851 256 4 1111 457 dont_use_flag
855 256 4 1115 45b use_flag
[def@bigboss ~]$ objdump -d {dont_,}use_flag | grep -A11 '<main>'
08048368 <main>:
8048368: 55 push %ebp
8048369: 89 e5 mov %esp,%ebp
804836b: 83 ec 08 sub $0x8,%esp
804836e: 83 e4 f0 and $0xfffffff0,%esp
8048371: 83 ec 18 sub $0x18,%esp
8048374: 6a 00 push $0x0
8048376: 68 64 84 04 08 push $0x8048464
804837b: e8 30 ff ff ff call 80482b0 <printf@plt>
--
08048368 <main>:
8048368: 55 push %ebp
8048369: 89 e5 mov %esp,%ebp
804836b: 83 ec 08 sub $0x8,%esp
804836e: 83 e4 f0 and $0xfffffff0,%esp
8048371: 83 ec 18 sub $0x18,%esp
8048374: 68 56 34 12 00 push $0x123456
8048379: 68 68 84 04 08 push $0x8048468
804837e: e8 2d ff ff ff call 80482b0 <printf@plt>
So I'd say that both in 3.4.3 and 4.1.1, no extra space is needed for the "const
static int" flag.
Regards,
Frederik
next prev parent reply other threads:[~2007-02-09 13:06 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-08 23:07 -mm merge plans for 2.6.21 Andrew Morton
2007-02-08 23:12 ` Roland Dreier
2007-02-08 23:29 ` Jan Engelhardt
2007-02-08 23:44 ` Andrew Morton
2007-02-09 15:02 ` Thomas Gleixner
2007-02-09 10:57 ` Frederik Deweerdt
2007-02-09 11:24 ` Arjan van de Ven
2007-02-09 11:39 ` Andrew Morton
2007-02-09 12:32 ` Arjan van de Ven
2007-02-09 14:05 ` deweerdt [this message]
2007-02-09 13:04 ` Andi Kleen
2007-02-09 12:27 ` Jan Engelhardt
2007-02-10 11:42 ` Arnd Bergmann
2007-02-10 14:19 ` Frederik Deweerdt
2007-02-08 23:34 ` Kyle McMartin
2007-02-08 23:53 ` Andrew Morton
2007-02-09 0:55 ` Paul Mackerras
2007-02-09 1:00 ` Andrew Morton
2007-02-09 5:32 ` Bharata B Rao
2007-02-09 8:26 ` Sébastien Dugué
2007-02-09 9:05 ` Andrew Morton
2007-02-09 10:10 ` Sébastien Dugué
2007-02-09 9:54 ` Lenar Lõhmus
2007-02-09 10:12 ` Andrew Morton
2007-02-09 12:48 ` James
2007-02-09 12:59 ` Lenar Lõhmus
2007-02-09 17:35 ` David Woodhouse
2007-02-09 21:45 ` Andrew Morton
2007-02-09 21:49 ` Russell King
2007-02-09 21:53 ` David Woodhouse
2007-02-09 22:03 ` Russell King
2007-02-09 22:12 ` David Woodhouse
2007-02-09 22:42 ` David Woodhouse
2007-02-10 2:05 ` Oleg Verych
2007-02-09 22:00 ` Andrew Morton
2007-02-09 22:06 ` Russell King
2007-02-09 21:59 ` David Woodhouse
2007-02-09 22:50 ` Davide Libenzi
2007-02-10 10:22 ` Heiko Carstens
2007-02-10 10:32 ` David Woodhouse
2007-02-10 21:34 ` Ralf Baechle
2007-02-11 4:53 ` Davide Libenzi
2007-02-11 15:33 ` David Woodhouse
2007-02-11 16:09 ` Ralf Baechle
2007-02-11 16:14 ` Heiko Carstens
2007-02-11 16:34 ` Davide Libenzi
2007-02-11 18:01 ` Ralf Baechle
2007-02-10 21:05 ` Ralf Baechle
2007-02-11 10:37 ` Andi Kleen
2007-02-10 13:03 ` Andi Kleen
2007-02-09 19:37 ` Alan
2007-02-09 21:51 ` Andrew Morton
2007-02-10 1:15 ` Carl-Daniel Hailfinger
2007-02-10 1:29 ` Andrew Morton
2007-02-10 13:06 ` Andi Kleen
2007-02-10 13:48 ` Alan
2007-02-10 14:43 ` Andi Kleen
2007-02-12 20:56 ` Doug Thompson
2007-02-12 21:46 ` Andi Kleen
2007-02-12 22:45 ` Doug Thompson
2007-02-09 22:18 ` Guillaume Chazarain
2007-02-10 9:58 ` -mm merge plans for 2.6.21 -- md-dm-reduce-stack-usage-with-stacked-block-devices.patch Heiko Carstens
2007-02-10 22:35 ` Alasdair G Kergon
2007-02-11 0:31 ` -mm merge plans for 2.6.21 Dave Jones
-- strict thread matches above, loose matches on Subject: below --
2007-02-09 2:57 Parag Warudkar
2007-02-09 3:05 ` Andrew Morton
[not found] <fa.7Z67qjqJwFP7+8QiVtu5tq6CZyU@ifi.uio.no>
[not found] ` <fa.4Y/nCUol/tGEodoOl/Jm9nf2AEA@ifi.uio.no>
[not found] ` <fa.TgZy4z2lRhwhAWCUE8IuGvMVUCU@ifi.uio.no>
[not found] ` <fa.HINMjdGzCuxlEiWtVvmNz7Pv9Pc@ifi.uio.no>
[not found] ` <fa.2ClW7C4ZyCP9QlT4vg7CbzjSqwg@ifi.uio.no>
2007-02-10 17:04 ` Robert Hancock
2007-01-12 23:19 ` Frederik Deweerdt
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=1171029910.45cc7f967fdfe@imp.free.fr \
--to=deweerdt@free.fr \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=jengelh@linux01.gwdg.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.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