Re: [AD] AL_ prefix clashes with OpenAL |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] AL_ prefix clashes with OpenAL
- From: Jon Rafkind <workmin@xxxxxxxxxx>
- Date: Sat, 07 Jul 2007 17:09:04 -0400
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
}
-->
main:
.LFB3:
pushq %rbp
.LCFI2:
movq %rsp, %rbp
.LCFI3:
subq $16, %rsp
.LCFI4:
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
leave
ret