Fix unaligned access faults on alpha.
This one is strange and goes against my rusty compiler knowledge.
The global declaration
struct sockaddr whereto;
produces for both i386 && alpha:
.comm whereto,16,1
which means common storage, byte aligned. Ahem. I though structs
were supposed to be ALDOUBLE always? I mean, w/o pragma packed?
Later on, this address is coerced to:
to = (struct sockaddr_in *)&whereto;
Up until now, we've been fine on alpha because the address
just ended up aligned to a 4 byte boundary. Lately, though,
it end up as:
0000000120027b0f B whereto
And, tra la, you get unaligned access faults. The solution I picked, in
lieu of understanding what the compiler was doing, is to put whereto
as a union of a sockaddr and sockaddr_in. That's more formally correct
if somewhat awkward looking.
This commit is contained in:
+9
-1
@@ -146,7 +146,15 @@ int options;
|
||||
int mx_dup_ck = MAX_DUP_CHK;
|
||||
char rcvd_tbl[MAX_DUP_CHK / 8];
|
||||
|
||||
struct sockaddr whereto; /* who to ping */
|
||||
/*
|
||||
* Use a union to coerce alignment to at least sockaddr_in's alignment.
|
||||
* This avoids unaligned access faults on alpha.
|
||||
*/
|
||||
union {
|
||||
struct sockaddr _w2; /* who to ping */
|
||||
struct sockaddr_in _w2_in; /* who to ping */
|
||||
} ww;
|
||||
#define whereto ww._w2
|
||||
int datalen = DEFDATALEN;
|
||||
int s; /* socket file descriptor */
|
||||
u_char outpack[MAXPACKET];
|
||||
|
||||
Reference in New Issue
Block a user