Re: Driver structures & alignment

2001-09-15 Thread Warner Losh
In message <[EMAIL PROTECTED]> "David O'Brien" writes: : On Sat, Sep 15, 2001 at 12:13:58PM -0600, Warner Losh wrote: : > In message <[EMAIL PROTECTED]> "David O'Brien" writes: : > : It is best to order this from largest to smallest size if you are worried : > : about alignment holes, etc. : > :

Re: Driver structures & alignment

2001-09-15 Thread Drew Eckhardt
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes: >On Sat, Sep 15, 2001 at 12:13:58PM -0600, Warner Losh wrote: >> unfortunately, there are many device structures that are passed around >> via DMA and hte like that don't let you do this... > >How come? The struct represents some [semi-]p

Re: Driver structures & alignment

2001-09-15 Thread David O'Brien
On Sat, Sep 15, 2001 at 12:13:58PM -0600, Warner Losh wrote: > In message <[EMAIL PROTECTED]> "David O'Brien" writes: > : It is best to order this from largest to smallest size if you are worried > : about alignment holes, etc. > : > : int64_t d; /* 8-byte boundary */ > : int32_t c; /* 4-

Re: Driver structures & alignment

2001-09-15 Thread Warner Losh
In message <[EMAIL PROTECTED]> "David O'Brien" writes: : It is best to order this from largest to smallest size if you are worried : about alignment holes, etc. : : int64_t d; /* 8-byte boundary */ : int32_t c; /* 4-byte boundary */ : int32_t f; /* 4-byte boundary */ : int

Re: Driver structures & alignment

2001-09-15 Thread David O'Brien
On Fri, Sep 14, 2001 at 12:23:44PM +0400, Yar Tikhiy wrote: > E.g., will the following structure: > struct foo { > }; > contain alignment holes in any architecture/compiler? It is best to order this from largest to smallest size if you are worried about alignment holes, etc. int64_t d; /

Re: Driver structures & alignment

2001-09-14 Thread Mike Smith
> In message <[EMAIL PROTECTED]> Mike Smith writes: > : Any form of packing is going to cause problems for items that are > : located in illegal fashions. > > It is almost more appropriate to use bus_space_{read,write} than using > memory mapped structures. The bus macros will work for otherwis

Re: Driver structures & alignment

2001-09-14 Thread Warner Losh
In message <[EMAIL PROTECTED]> Mike Smith writes: : Any form of packing is going to cause problems for items that are : located in illegal fashions. It is almost more appropriate to use bus_space_{read,write} than using memory mapped structures. The bus macros will work for otherwise unaligned

Re: Driver structures & alignment

2001-09-14 Thread Mike Smith
> 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 goi

Re: Driver structures & alignment

2001-09-14 Thread Andrew Gallatin
Peter Wemm writes: > The same goes for __format_arg(n) in stdio.h. And so on. We've been pretty > clean about it so far, but a few have slipped through. > That __format_arg, btw, breaks the Compaq CCC compiler & causes us to have to override stdio.h because of just that one line. Does you

Re: Driver structures & alignment

2001-09-14 Thread Peter Wemm
Terry Lambert wrote: > Mike Smith wrote: > > Having said that, I recommend using __attribute__ ((packed)) > > to explicitly request that a structure be packed. > > Is there a problem with "#pragma pack(1)"? I see it in a > lot of header files... do they need changing? Yes, but it should be: #de

Re: Driver structures & alignment

2001-09-14 Thread Terry Lambert
Mike Smith wrote: > Having said that, I recommend using __attribute__ ((packed)) > to explicitly request that a structure be packed. Is there a problem with "#pragma pack(1)"? I see it in a lot of header files... do they need changing? -- Terry To Unsubscribe: send mail to [EMAIL PROTECTED] wi

Re: Driver structures & alignment

2001-09-14 Thread Yar Tikhiy
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 pr

Re: Driver structures & alignment

2001-09-13 Thread Mike Smith
> 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. Hav

Re: Driver structures & alignment

2001-09-13 Thread Brian Somers
> 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. gcc deals with it, certainly on alpha anyway. However, I don't think anyone would ever bless using

Driver structures & alignment

2001-09-13 Thread Yar Tikhiy
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. Should char arrays be used for all multi-byte elements to avoid alignment problems? And is it OK to rely on sp