qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Bonifazi <stefboombastic@gmail.com>
To: Mulyadi Santosa <mulyadi.santosa@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] classic emulator Vs QEMU-TCG
Date: Fri, 17 Dec 2010 10:47:16 +0100	[thread overview]
Message-ID: <4D0B31A4.1000200@gmail.com> (raw)
In-Reply-To: <AANLkTimVz3=rzvcSkpTRzP9JRvnCD98XGrt9r-saMN4q@mail.gmail.com>

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	other threads:[~2010-12-17  9:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-16 15:20 [Qemu-devel] classic emulator Vs QEMU-TCG Stefano Bonifazi
2010-12-16 15:41 ` Peter Maydell
2010-12-17 13:49   ` Stefano Bonifazi
2010-12-16 15:57 ` Mulyadi Santosa
2010-12-17  9:47   ` Stefano Bonifazi [this message]
2010-12-17 10:18     ` Mulyadi Santosa
2010-12-17 13:51     ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D0B31A4.1000200@gmail.com \
    --to=stefboombastic@gmail.com \
    --cc=mulyadi.santosa@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).