By "pad/no-pad option" you mean the "__attribute__ ((packed))" compiler 
attribute? Philip Levis in "TinyOS Programming" (e.g. 
http://csl.stanford.edu/~pal/pubs/tinyos-programming.pdf) explains how 
this works and why it should not be used. According to the above 
referenced document, all fields in an nx_struct are aligned on byte 
boundaries. So I guess this means the structure is "packed".

I would expect the implementation of the nx_ types to be platform 
dependent. If you look at the code for the MicaX platforms, there likely 
is not much to see. However, the implementation for the Telos type of 
platforms might be quite a bit more complex. Maybe this does not show in 
the packet definition, but when accessing those variables, the code must 
do something to change the endianness and to access 2-byte values that 
are not aligned on 2-byte boundaries.

Cheers,
Urs

Michael Schippling wrote:
> I think the pad/no-pad thing is probably a compiler level feature
> and was most certainly for multi-byte objects on differing platforms.
> (The OP's struct had an int16-int8-int16, which on some platforms
> would have been layed out as int16-int8-padbyte-int16...or worse).
> Given that nx_ types are byte arrays they don't need it and are
> probably packed efficiently. Being an old guy I never trust that
> new-fangled stuff and thus avoid it...but thanks for the info.
> 
> MS
> 
> Eric Decker wrote:
>>
>> On Mon, Jan 12, 2009 at 11:17 AM, Michael Schippling <[email protected] 
>> <mailto:[email protected]>> wrote:
>>
>>     There "used to be" a pad/no-pad option especially for this.
>>     Are the nx_ types defined to always be no-pad?
>>
>>
>> I've looked at the code generated and the nx_types are defined as arrays 
>> of uint8_t.  Not sure
>> how the pad no_pad used to work.  I suspect it is for multibyte objects 
>> such as uint16_t etc.
>>
>> But for the question originally asked int8_t were being asked about.
>>
>> eric
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to