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: Stefano Bonifazi
Subject: Re: [Qemu-devel] classic emulator Vs QEMU-TCG
Date: Fri, 17 Dec 2010 10:47:16 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7

On 12/16/2010 04:57 PM, Mulyadi Santosa wrote:
With my limited C knowledge, I saw that as a instruction jump (to
tb_ptr). The "code_gen_prologue" seems to me like a cast..... casting
each opcode in tb_ptr as uint8_t.... with maximum length=1024
Hi! Thank you for your reply!

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 :[
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) :[

So inside code_gen_prologue array there is stored some function (in binary code) that takes a tb_ptr as argument and returns a long .. I have to check what it is inside there for understanding how the translated target code is run now ;)

I hope that's the right interpretation...I must admit Qemu is full of
gcc and C tricks here and there...
Yes! I've only had some experience in OO programming, really always avoided defines and odd compiler directives in my code before..

 Best Regards!
Stefano B.



reply via email to

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