qemu-ppc
[Top][All Lists]
Advanced

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

Re: [Qemu-ppc] [Qemu-devel] [QEMU PATCH v7 2/3] migration: migrate QTAIL


From: Jianjun Duan
Subject: Re: [Qemu-ppc] [Qemu-devel] [QEMU PATCH v7 2/3] migration: migrate QTAILQ
Date: Wed, 26 Oct 2016 09:58:07 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0


On 10/26/2016 05:29 AM, Halil Pasic wrote:
> 
> 
> On 10/22/2016 12:52 AM, Jianjun Duan wrote:
>> +#define RAW_FIELD(base, offset)                                             
>>    \
>> +        ((char *) (base) + offset)
>> +
> 
> Seems you partially adopted Paolo's suggestion for improving the
> macros. Is there a particular reason why you did not follow it more
> closely? I find the solution with field_at_offset(base, offset, type)
> more readable than with RAW_FIELD(base, offset).
> 
field_at_offset is too general. We only use (void **) and (void ***)
here. For pointer arithmetic, I think RAW_FIELD is more straightforward.

Thanks,
Jianjun
>> +/*
>> + * Offsets of layout of a tail queue head.
>> + */
>> +#define QTAILQ_FIRST_OFFSET 0
>> +#define QTAILQ_LAST_OFFSET (sizeof(void *))
>> +/*
>> + * Raw access of elements of a tail queue
>> + */
>> +#define QTAILQ_RAW_FIRST(head)                                              
>>    \
>> +        (*((void **) (RAW_FIELD(head,  QTAILQ_FIRST_OFFSET))))
>> +#define QTAILQ_RAW_LAST(head)                                               
>>    \
>> +        (*((void ***) (RAW_FIELD(head,  QTAILQ_LAST_OFFSET))))
>> +
>> +/*
>> + * Offsets of layout of a tail queue element.
>> + */
>> +#define QTAILQ_NEXT_OFFSET 0
>> +#define QTAILQ_PREV_OFFSET (sizeof(void *))
>> +
>> +/*
>> + * Raw access of elements of a tail entry
>> + */
>> +#define QTAILQ_RAW_NEXT(elm, entry)                                         
>>    \
>> +        (*((void **) (RAW_FIELD(elm, entry + QTAILQ_NEXT_OFFSET))))
>> +#define QTAILQ_RAW_PREV(elm, entry)                                         
>>    \
>> +        (*((void ***) (RAW_FIELD(elm, entry + QTAILQ_PREV_OFFSET))))
>> +/*
>> + * Tail queue tranversal using pointer arithmetic.
>> + */




reply via email to

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