From owner-freebsd-hackers Thu Sep 13 16: 2:34 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mass.dis.org (mass.dis.org [216.240.45.41]) by hub.freebsd.org (Postfix) with ESMTP id DFE2037B408; Thu, 13 Sep 2001 16:02:29 -0700 (PDT) Received: from mass.dis.org (localhost [127.0.0.1]) by mass.dis.org (8.11.6/8.11.3) with ESMTP id f8DN9vX03967; Thu, 13 Sep 2001 16:09:58 -0700 (PDT) (envelope-from msmith@mass.dis.org) Message-Id: <200109132309.f8DN9vX03967@mass.dis.org> To: Yar Tikhiy Cc: hackers@freebsd.org, msmith@mass.dis.org Subject: Re: Driver structures & alignment In-Reply-To: Message from Yar Tikhiy of "Thu, 13 Sep 2001 23:23:52 +0400." <20010913232352.A23874@snark.rinet.ru> Date: Thu, 13 Sep 2001 16:09:57 -0700 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > 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