On 4/18/22 05:38, yangxiaojuan wrote:
On 2022/4/16 上午9:04, Richard Henderson wrote:
+int cpu_csr_offset(unsigned csr_num);
...
+static const uint64_t csr_offsets[] = {
There's no reason for this array to be uint64_t.
It really should match the function.
Yes, we shoud do this.
If we use 'int', we may get a warning:
../target/loongarch/csr_helper.c:49:30: warning: overflow in implicit constant conversion
[-Woverflow]
[LOONGARCH_CSR_CPUID] = offsetof(CPUState, cpu_index)
^~~~~~~~
How about use 'long'? I had tested it no warning.
That is because offsetof() result is size_t, which is unsigned, and a "negative" unsigned
number is a large positive. Cast each offsetof to int.
r~