Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Sep 2001 16:09:57 -0700
From:      Mike Smith <msmith@freebsd.org>
To:        Yar Tikhiy <yar@freebsd.org>
Cc:        hackers@freebsd.org, msmith@mass.dis.org
Subject:   Re: Driver structures & alignment 
Message-ID:  <200109132309.f8DN9vX03967@mass.dis.org>
In-Reply-To: Message from Yar Tikhiy <yar@freebsd.org>  of "Thu, 13 Sep 2001 23:23:52 %2B0400." <20010913232352.A23874@snark.rinet.ru> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Hi there,
> 
> 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 char arrays be used for all multi-byte elements to
> avoid alignment problems?

No.

> 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?

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109132309.f8DN9vX03967>