On Thu, Sep 13, 2001 at 04:09:57PM -0700, Mike Smith wrote:
> > 
> > Is there a single blessed way to define packed structures
> > for use in drivers?  I suspect that using "#pragma pack(1)"
> > will lead to alignment errors in non-Intel architectures.
> 
> Any form of packing is going to cause problems for items that are
> located in illegal fashions. 
> 
> Having said that, I recommend using __attribute__ ((packed))
> to explicitly request that a structure be packed.

Should the __attribute__ be supplied to each structure's member?
Or can it be the whole structure's attribute?
 
> > And is it OK to rely on specially crafted structures, like
> > "struct fs" in /sys/ufs/ffs/fs.h where multi-byte elements
> > are pre-aligned by the structure's design, being contiguous?
> 
> "rely" in what fashion?
 
E.g., will the following structure:
struct foo {
        int16_t a;
        int16_t b;
        int32_t c; /* 4-byte boundary */
        int64_t d; /* 8-byte boundary */
        int8_t  e[4];
        int32_t f; /* 4-byte boundary */
};
contain alignment holes in any architecture/compiler?

-- 
Yar

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to