[MPlayer-cvslog] r33217 - trunk/gui/util/bitmap.c

Clément Bœsch ubitux at gmail.com
Wed Apr 6 09:23:27 CEST 2011


On Wed, Apr 06, 2011 at 09:12:57AM +0200, Clément Bœsch wrote:
> > And what's the point of the "static"? Is ext on the function's stack not ok?
> > 
> 
> Not exported symbol. Can be inlined in case of functions.
> 

Mmh I guess it was in the function scope (don't have the original mail
anyway) so well, instead of writing each time the content of the array on
the stack, it just uses the immediate static allocation:

    void f1(void)
    {
            static const char *x[] = {"foo", "bar", "bla"};
            int i;
            for (i = 0; i < sizeof(x)/sizeof(*x); i++)
                    printf("x[%d]=%s\n", i, x[i]);
    }

    Dump of assembler code for function f1:
       0x00000000004002b0 <+0>:     sub    $0x8,%rsp
       0x00000000004002b4 <+4>:     mov    $0x46bc24,%edx
       0x00000000004002b9 <+9>:     xor    %esi,%esi
       0x00000000004002bb <+11>:    mov    $0x46bc28,%edi
       0x00000000004002c0 <+16>:    xor    %eax,%eax
       0x00000000004002c2 <+18>:    callq  0x400e50 <printf>
       0x00000000004002c7 <+23>:    mov    $0x46bc32,%edx
       0x00000000004002cc <+28>:    mov    $0x1,%esi
       0x00000000004002d1 <+33>:    mov    $0x46bc28,%edi
       0x00000000004002d6 <+38>:    xor    %eax,%eax
       0x00000000004002d8 <+40>:    callq  0x400e50 <printf>
       0x00000000004002dd <+45>:    mov    $0x46bc36,%edx
       0x00000000004002e2 <+50>:    mov    $0x2,%esi
       0x00000000004002e7 <+55>:    mov    $0x46bc28,%edi
       0x00000000004002ec <+60>:    xor    %eax,%eax
       0x00000000004002ee <+62>:    add    $0x8,%rsp
       0x00000000004002f2 <+66>:    jmpq   0x400e50 <printf>
    End of assembler dump.

    void f2(void)
    {
            const char *x[] = {"foo", "bar", "bla"};
            int i;
            for (i = 0; i < sizeof(x)/sizeof(*x); i++)
                    printf("x[%d]=%s\n", i, x[i]);
    }

    (gdb) disassemble f2
    Dump of assembler code for function f2:
       0x0000000000400300 <+0>:     sub    $0x28,%rsp
       0x0000000000400304 <+4>:     mov    $0x46bc24,%edx
       0x0000000000400309 <+9>:     xor    %esi,%esi
       0x000000000040030b <+11>:    mov    $0x46bc28,%edi
       0x0000000000400310 <+16>:    xor    %eax,%eax
       0x0000000000400312 <+18>:    movq   $0x46bc24,(%rsp)     ; "foo"
       0x000000000040031a <+26>:    movq   $0x46bc32,0x8(%rsp)  ; "bar"
       0x0000000000400323 <+35>:    movq   $0x46bc36,0x10(%rsp) ; "bla"
       0x000000000040032c <+44>:    callq  0x400e50 <printf>
       0x0000000000400331 <+49>:    mov    0x8(%rsp),%rdx
       0x0000000000400336 <+54>:    mov    $0x1,%esi
       0x000000000040033b <+59>:    mov    $0x46bc28,%edi
       0x0000000000400340 <+64>:    xor    %eax,%eax
       0x0000000000400342 <+66>:    callq  0x400e50 <printf>
       0x0000000000400347 <+71>:    mov    0x10(%rsp),%rdx
       0x000000000040034c <+76>:    mov    $0x2,%esi
       0x0000000000400351 <+81>:    mov    $0x46bc28,%edi
       0x0000000000400356 <+86>:    xor    %eax,%eax
       0x0000000000400358 <+88>:    add    $0x28,%rsp
       0x000000000040035c <+92>:    jmpq   0x400e50 <printf>
    End of assembler dump.


-- 
Clément B.


More information about the MPlayer-cvslog mailing list