[ofw] ib_portinfo_record_t padding history?

Fab Tillier ftillier at microsoft.com
Tue May 18 22:23:18 PDT 2010


Hi Hal,

Hal Rosenstock wrote on Tue, 18 May 2010 at 19:22:37

>> AL_INLINE ib_net16_t AL_API
>> ib_get_attr_offset(
>>        IN              const   uint32_t  attr_size )
>> {
>>        if( attr_size & 0x07 )
>>                return( cl_hton16( (uint16_t)(attr_size >> 3) + 1 ) );
>>        else
>>                return( cl_hton16( (uint16_t)(attr_size >> 3) ) );
>> }
>>
>> Linux
>>
>> static inline ib_net16_t AL_API
>> ib_get_attr_offset(const uint32_t attr_size )
>> {
>>        return( cl_hton16( (uint16_t)(attr_size >> 3) ) );
>> }
> 
> Why does Windows have the if clause in ib_get_attr_off (and not match
> the "Linux" version) ?

So that the returned offset is not rounded down incorrect.  Say the attribute size is not a multiple of 8, the >> 3 would return a value 1 less than required.

Not sure how the Linux code works properly, unless the structure sizes somehow get rounded to a multiple of 8.

-Fab




More information about the ofw mailing list