Re: [AD] AL_ prefix clashes with OpenAL

[ Thread Index | Date Index | More Archives ]

Ryan Patterson wrote:
> On 7/7/07, Chris Robinson <chris.kcat@xxxxxxxxxx> wrote:
>> Another idea that just came up with on IRC would be to use a struct of
>> function pointers for the "exported" Allegro functions. The idea would be to
>> have a struct that contains all the functions Allegro can export, then have
>> an inline function load them in the user program.
> Wouldn't that cause an additional pointer dereference for every call
> to an Allegro function? That doesn't sound like a very good idea...
I doubt it would matter for most users. The assembly doesn't look very
different from the two cases anyway:
struct test {
    void (*blah)(void);

void hello(){
    printf( "Hello world\n" );

int main(){
    struct test t;
    t.blah = hello;

    printf( "Ok\n" );
    hello(); // plain
    printf( "Blah\n" );
    t.blah(); // dereference

    pushq    %rbp
    movq    %rsp, %rbp
    subq    $16, %rsp
    movq    $hello, -16(%rbp)
    movl    $.LC1, %edi
    call    puts
    movl    $0, %eax <------- plain
    call    hello <-------------- plain
    movl    $.LC2, %edi
    call    puts
    movq    -16(%rbp), %rax <---- dereference
    call    *%rax <----------- dereference

Mail converted by MHonArc 2.6.19+