qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] classic emulator Vs QEMU-TCG


From: Andreas Färber
Subject: Re: [Qemu-devel] classic emulator Vs QEMU-TCG
Date: Fri, 17 Dec 2010 14:51:38 +0100

Hi,

Am 17.12.2010 um 10:47 schrieb Stefano Bonifazi:

I've got an explanation from a C guru :)

((long REGPARM (*)(void *))code_gen_prologue)(tb_ptr)
---------
(long REGPARM (*)(void *)) is a type: a pointer pointing to a function, which takes one (void*) parameter. code_gen_prologue is an>array, array's name when used is considered to be a pointer to its first element, thus you are casting here pointer to the first byte of>array to pointer to function (...). Ellipsis with tb_ptr mean 'call function under this address and pass there whatever tb_ptr is'

Now everything is very clear for me :)
I do know pointer to functions, and if I had got:

long REGPARM (*myfunc)(void *)

I would have recognized it.. but removing the function pointer name, leaving only the * was enough for me to be lost :[

Feel free to take the next step then and read CODING_GUIDELINES to create and submit your first Git patch to make the code more readable for others. Introducing a typedef for the cast might not be a bad idea.

also the definition of code_gen_prologue was tricky:
uint8_t code_gen_prologue[1024] code_gen_section;
that code_gen_section at first confused my idea of a normal variable definition as "type identifier" .. until I found out it was a define for a compiler directive (alignment) :[

Would capitalizing code_gen_section have helped to recognize it as a preprocessor define? Another patch idea. :)

Regards,
Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]