[ofw] ib_portinfo_record_t padding history?

Hal Rosenstock hal.rosenstock at gmail.com
Wed May 19 06:21:50 PDT 2010


Hi Fab,

On Wed, May 19, 2010 at 1:23 AM, Fab Tillier <ftillier at microsoft.com> wrote:
> 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.

The record structs which are not modulo 8 bytes are explictly padded
out (e.g NodeRecord, LinkRecord, SMInfoRecord, InformInfoRecord). If
this is followed in the struct definitions, then the if clause is
never used.

-- Hal

> -Fab
>
>
>



More information about the ofw mailing list