qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v4 07/43] tcg: Add in_code_gen_buffer


From: Richard Henderson
Subject: Re: [PATCH v4 07/43] tcg: Add in_code_gen_buffer
Date: Tue, 15 Dec 2020 16:43:12 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 12/14/20 4:09 PM, Philippe Mathieu-Daudé wrote:
> On 12/14/20 3:02 PM, Richard Henderson wrote:
>> Create a function to determine if a pointer is within the buffer.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>  include/tcg/tcg.h         |  6 ++++++
>>  accel/tcg/translate-all.c | 26 ++++++++------------------
>>  2 files changed, 14 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
>> index bb1e97b13b..e4d0ace44b 100644
>> --- a/include/tcg/tcg.h
>> +++ b/include/tcg/tcg.h
>> @@ -680,6 +680,12 @@ extern __thread TCGContext *tcg_ctx;
>>  extern void *tcg_code_gen_epilogue;
>>  extern TCGv_env cpu_env;
>>  
>> +static inline bool in_code_gen_buffer(const void *p)
>> +{
>> +    const TCGContext *s = &tcg_init_ctx;
>> +    return (size_t)(p - s->code_gen_buffer) <= s->code_gen_buffer_size;
> 
> If 'p == s->code_gen_buffer + s->code_gen_buffer_size',
> is it really "in" the buffer?

Well, sort of.

Compare the fact that in C, a pointer to the end of an array is valid as a
pointer even though it can't be dereferenced.  This is a pointer to the end of
the buffer.

Extra commentary required?


r~



reply via email to

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