Frank Hofmann <[EMAIL PROTECTED]> wrote:

> I'm looking for a generic opinion on the use of "#pragma pack" for writing 
> Solaris code. I know it's useful for device register sets, or data structures 
> that don't follow ABI layout rules.

Do you know ot hardware that needs registers to be read/written in chunks > one 
byte?

> We use #pragma pack(4) at a few places in Solaris (for example, the SVM 
> on-disk 
> layout data structures on Solaris/x86).
>
> Should such a use be allowed or discouraged for new code ? I.e. if I have a 
> data structure that is packed (no padding, contains misaligned multibyte 
> entities), should I better write a convertor function or were it ok to use 
> #pragma pack(1) ?

The clean and portable way is to have character arrays in structures and to use
converting macros. Sparc processors cannot access unaligned data > one byte.

I know of only one case where obscure packing is needed and in this case even
#pragma pack(1) does not work:

It seems that gcc needs "__attribute__((packed))" past some structure 
definitions
in order to avoid post structure padding for ARM processors.

Jörg

-- 
 EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
       [EMAIL PROTECTED]                (uni)  
       [EMAIL PROTECTED]     (work) Blog: http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to