qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3] implementing victim TLB for QEMU system emul


From: Xin Tong
Subject: Re: [Qemu-devel] [PATCH v3] implementing victim TLB for QEMU system emulated TLB
Date: Sun, 2 Feb 2014 13:01:52 -0600

I am getting some compilation errors while stringnifying the
ADDR_READ, addr_write.

function helper_be_ldq_cmmu

 if (!VICTIM_TLB_HIT(ADDR_READ)) {


macro

#define VICTIM_TLB_HIT(ACCESS_TYPE)                                           \
({                                                                            \
    /* we are about to do a page table walk. our last hope is the             \
     * victim tlb. try to refill from the victim tlb before walking the       \
     * page table. */                                                         \
    int vidx;                                                                 \
    hwaddr tmpiotlb;                                                          \
    CPUTLBEntry tmptlb;                                                       \
    for (vidx = CPU_VTLB_SIZE; vidx >= 0; --vidx) {                           \
        if (env->tlb_v_table[mmu_idx][vidx].#ACCESS_TYPE                      \
            == (addr & TARGET_PAGE_MASK)) {                                   \
            /* found entry in victim tlb, swap tlb and iotlb */               \
            tmptlb = env->tlb_table[mmu_idx][index];                          \
            env->tlb_table[mmu_idx][index] = env->tlb_v_table[mmu_idx][vidx]; \
            env->tlb_v_table[mmu_idx][vidx] = tmptlb;                         \
            tmpiotlb = env->iotlb[mmu_idx][index];                            \


compilation error

/home/xtong/qemu/include/exec/softmmu_template.h: In function
'helper_be_ldq_cmmu':
/home/xtong/qemu/include/exec/softmmu_template.h:266: error: expected
identifier before string constant

Xin

On Sun, Feb 2, 2014 at 12:33 PM, Peter Maydell <address@hidden> wrote:
> On 2 February 2014 18:27, Xin Tong <address@hidden> wrote:
>> On Sun, Feb 2, 2014 at 10:19 AM, Peter Maydell <address@hidden> wrote:
>>> Statement expressions are supported by both gcc and clang,
>>> which is the set of compilers we care about.
>>
>> Ok got it. would moving vtlb_idx inside the macro break the C89 rule
>> of "No Variable declaration in middle of block"
>
> No, because the macro has a block inside it. "block" means
> "a chunk of code inside {}", not "an entire function". You can
> declare variables at the start of functions, or at the start
> of the block in a while loop, or at the start of the blocks in
> an if () {...} else {...}, or (as in this case) at the start of the
> block inside a C statement expr.
>
> If you want to restrict the scope of a variable and you don't
> have a block conveniently to hand, it's always valid just to
> create one: C syntax allows a bare "{ /* code here */ }"
> anywhere a statement is valid. It's almost always the case
> that there's some handy control-flow-mandated block to
> use, though.
>
> thanks
> -- PMM



reply via email to

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