[dpdk-dev] [RFC UNTESTED PATCH] eal_common_cpuflags: Fix %rbx corruption, and simplify the code

H. Peter Anvin hpa at zytor.com
Mon Mar 24 17:11:12 CET 2014


On 03/24/2014 09:06 AM, Neil Horman wrote:
>>
>> If C99-style initializers are permitted in this codebase, I would
>> strongly recommend using them, and then drop the enum field in struct
>> feature_entry and use a macro such as:
>>
> Actually, its a bit simpler than that, the enum parameter is actually completely
> unused, and so can be removed entirely.  The FEAT_DEF macro does what you
> suggest below already, but only for the feature and name fields.
> 
> I'll remove the enum and its definition, and augment the macro to cover the rest
> of the fields.
> 
> Neil
> 
>> #define FEAT(name,leaf,subleaf,reg,bit) \
>> 	[RTE_CPUFLAG_##f] = { leaf, subleaf, reg, bit, #f },
>>
>> (I'd move the string to the end, but that is just a microoptimization.
>> I'm kind of OCD that way.)
>>

The nice thing with the C99 initializer is that even if the order is
mismatched between the .c file and the .h file which defines the enum,
things still work correctly.

	-hpa




More information about the dev mailing list