qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] definition of struct TCGv_i64_d


From: G 3
Subject: Re: [Qemu-devel] definition of struct TCGv_i64_d
Date: Thu, 27 Oct 2016 12:42:47 -0400


On Oct 21, 2016, at 11:17 AM, Peter Maydell wrote:

On 21 October 2016 at 15:48, Programmingkid <address@hidden> wrote:
In the tcg.h file, there is this line: typedef struct TCGv_i64_d *TCGv_i64;

Would anyone know where the definition of struct TCGv_i64_d is?

There is none, because the "pointers" in these variables are
never dereferenced. These are just magic to let us make use
of the compiler's typechecking -- the actual values in the
TCGv_i64 variables are integers (offsets into arrays describing
the temporaries inside the TCG code). The only way to create a
TCGv_i64 is with MAKE_TCGV_I64, and then you can get back to
the underlying integer (if you're code in tcg/) is with
GET_TCGV_I64.

We used to typedef TCGv_i64 &c as plain "int"s, but then the
compiler doesn't complain if you pass a TCGv_i32 to a function
expecting a TCGv_i64.

thanks
-- PMM

Would you accept a patch that added a comment explaining that struct TCGv_i64 isn't really a structure?

I'm thinking something like this would help:

/*
There is no TCGv_i64_d structure. This is really a way around a gcc issue. TCGv_i64 can be considered a pointer to an integer. Only MAKE_TCGV_I64 can create an instance variable. GET_TCGV_I64 is what is used to access the value.
*/
typedef struct TCGv_i64_d *TCGv_i64;



reply via email to

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