tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Implement mode_select for atapi tape drives - round 4



On Sun, 9 Aug 2009, David Laight wrote:

On Sun, Aug 09, 2009 at 09:47:29PM +0200, Manuel Bouyer wrote:

I don't get it. If the hardware (scsi devices in this case) defines
a structure like e.g
struct foo {
        int8_t data1;
        int32_t data2;
        int8_t data3
        int32_t data4;
};
the software on the host side will have to do misaligned accesses whatever
we do, isn't it ? How do we avoid the compiler from padding the members
without __packed ?

For data2 use __attribute__((__aligned__(1)))
and for data4 __attribute__((__aligned__(2)))

Everything in the particular structures that started this discussion are uint8_t so alignment should be a concern here. Unless, of course, the compiler is allowed to force an array of uint8_t to start on a "nice" boundary.



-------------------------------------------------------------------------
|   Paul Goyette   | PGP DSS Key fingerprint: |  E-mail addresses:      |
| Customer Service | FA29 0E3B 35AF E8AE 6651 |  paul at whooppee.com   |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index