From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60317 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTWuH-0000M3-Oa for qemu-devel@nongnu.org; Fri, 17 Dec 2010 04:47:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTWuG-0007uI-NT for qemu-devel@nongnu.org; Fri, 17 Dec 2010 04:47:21 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:52920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTWuG-0007u7-J1 for qemu-devel@nongnu.org; Fri, 17 Dec 2010 04:47:20 -0500 Received: by wyg36 with SMTP id 36so531595wyg.4 for ; Fri, 17 Dec 2010 01:47:19 -0800 (PST) Message-ID: <4D0B31A4.1000200@gmail.com> Date: Fri, 17 Dec 2010 10:47:16 +0100 From: Stefano Bonifazi MIME-Version: 1.0 Subject: Re: [Qemu-devel] classic emulator Vs QEMU-TCG References: <4D0A2E4C.6070307@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mulyadi Santosa Cc: qemu-devel@nongnu.org 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.