qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH for-4.1 v2 32/36] cpu: Move icount_decr to CPUNe


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH for-4.1 v2 32/36] cpu: Move icount_decr to CPUNegativeOffsetState
Date: Mon, 29 Apr 2019 08:32:20 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 4/29/19 7:48 AM, Peter Maydell wrote:
>> -static void align_clocks(SyncClocks *sc, const CPUState *cpu)
>> +static void align_clocks(SyncClocks *sc, CPUState *cpu)
>>  {
>>      int64_t cpu_icount;
>>
>> @@ -62,7 +62,7 @@ static void align_clocks(SyncClocks *sc, const CPUState 
>> *cpu)
>>          return;
>>      }
>>
>> -    cpu_icount = cpu->icount_extra + cpu->icount_decr.u16.low;
>> +    cpu_icount = cpu->icount_extra + cpu_neg(cpu)->icount_decr.u16.low;
>>      sc->diff_clk += cpu_icount_to_ns(sc->last_cpu_icount - cpu_icount);
>>      sc->last_cpu_icount = cpu_icount;
> 
> Why does this require that we remove the 'const' from the cpu
> argument to the function ?

Because

  CPUNegativeOffsetState *cpu_neg(CPUState *);

and this isn't c++ so we can't overload with another

  const CPUNegativeOffsetState *cpu_neg(const CPUState *);

and it doesn't seem worthwhile to preserve constness here.

>> @@ -265,7 +265,7 @@ static void cpu_common_reset(CPUState *cpu)
>>      cpu->mem_io_pc = 0;
>>      cpu->mem_io_vaddr = 0;
>>      cpu->icount_extra = 0;
>> -    atomic_set(&cpu->icount_decr.u32, 0);
>> +    atomic_set(&cpu->icount_decr_ptr->u32, 0);
>>      cpu->can_do_io = 1;
>>      cpu->exception_index = -1;
>>      cpu->crash_occurred = false;
> 
> What determines when we need to access the icount fields
> via icount_decr_ptr versus when we can just directly
> access icount_decr ?

NEED_CPU_H.  To access the field directly you need ArchCPU defined.


r~



reply via email to

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