Dag-Erling Smørgrav wrote: > "M. Warner Losh" <i...@bsdimp.com> writes: > > You'll find that a number of structures are potentially already > > allocated with less than required alignment. There's about a dozen > > places in the tree that would start to fail if we did this, or the > > stronger form of __aligned(8). We could add that to the other > > structures, but then we're breaking ABI rules, I think. > > __aligned(4) won't affect struct addrinfo since the sockaddr immediately > follows a socklen_t, which is 32 bits wide and has 32-bit alignment. A > sockaddr_* allocated with malloc() will already be aligned, and so will > a sockaddr_* created on the stack. The only problem is sockaddr_un, > because its size is not a multiple of 4, so if you allocate an array of > sockaddr_un, every other element will be misaligned.
I did a small survey of all the sockaddr_ variants: struct align size modulo where ------------------------------------------------------------------------- osockaddr 2 16 16 <sys/socket.h> sockaddr 1 16 16 <sys/socket.h> sockaddr_at 2 16 16 <netatalk/at.h> sockaddr_dl 2 54 2 <net/if_dl.h> sockaddr_hci 1 34 2 <netgraph/bluetooth/include/ng_btsocket.h> sockaddr_in 4 16 16 <netinet/in.h> sockaddr_in6 4 28 4 <netinet6/in6.h> sockaddr_inarp 4 16 16 <netinet/if_ether.h> sockaddr_ipx 2 16 16 <netipx/ipx.h> sockaddr_l2cap 2 10 2 <netgraph/bluetooth/include/ng_btsocket.h> sockaddr_natm 2 22 2 <netnatm/natm.h> sockaddr_nb 4 56 8 <netsmb/netbios.h> sockaddr_ng 1 16 16 <netgraph/ng_socket.h> sockaddr_rfcomm 1 9 1 <netgraph/bluetooth/include/ng_btsocket.h> sockaddr_sco 1 8 8 <netgraph/bluetooth/include/ng_btsocket.h> sockaddr_storage 8 128 128 <sys/_sockaddr_storage.h> sockaddr_un 1 106 2 <sys/un.h> If we push struct sockaddr to align(4), then we will also have to do the same with all others that are not already aligned to at least 4 bytes. That would be almost all of them. I agree that there will be ABI problems with those structs whose size is not a multiple of 4 (that's the ones with a value < 4 in the "modulo" column above). So we cannot do that, right? Best regards Oliver -- ``We are all but compressed light'' (Albert Einstein) _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"