[161] in linux-scsi channel archive
Latest GCC ss950430 doesn't grok __attribute__((packed))
daemon@ATHENA.MIT.EDU (Andrew Walker)
Mon May 8 04:28:46 1995
From: andy@keo.kvaerner.no (Andrew Walker)
To: hjl@nynexst.com (H.J. Lu)
Date: Mon, 8 May 1995 08:50:45 +0200 (MET DST)
Cc: lnz@dandelion.com (Leonard N. Zubkoff),
linux-gcc@vger.rutgers.edu (GCC list at vger),
linux-scsi@vger.rutgers.edu (SCSI list at vger)
The latest snapshot of GCC - ss950430 doesn't seem to honour the __atribute__((packed))
directive any more. The Buslogic driver used this feature in the following way to define
a 6 byte struct cmd, but the latest snapshot ignored PACKED and aligned the 'base' field
of the cmd struct on a 4 byte boundary. This broke the driver as the Buslogic expects
a 4 byte address in bytes 2-5 of this command.
In linux/drivers/scsi/buslogic.h, line 47:
#define PACKED __attribute__((packed))
In linux/drivers/scsi/buslogic.c, lines 801-806:
struct mailbox *mb = HOSTDATA(shpnt)->mb;
struct ccb *ccb = HOSTDATA(shpnt)->ccbs;
struct {
unsigned char cmd, count;
void *base PACKED;
} cmd = { CMD_INITEXTMB, BUSLOGIC_MAILBOXES, mb };
I got around this by defining:
struct {
unsigned char cmd, count;
char base[4];
} cmd = { CMD_INITEXTMB, BUSLOGIC_MAILBOXES };
memcpy(cmd.base, &mb, 4);
Is there a reason why __atribute__((packed)) is ignored? If so, what's the cleanest
workaround. I noticed that the Ultrastor drivers also use the PACKED definition so
they might also be broken by the latest snapshot.
-Andy
--
Andy Walker Kvaerner Engineering a.s.
Andrew.Walker@keo.kvaerner.no P.O. Box 222, N-1324 Lysaker, Norway
......if the answer isn't violence, neither is it silence......