X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FBSDSocketAddress.hh;h=ec3edfdf090513e43a38ad27739eb55d120b2536;hb=58a75247c7915bf6fa5e8205d06cdc4a9adfc537;hp=5afd329d0d047a4601755ea232c74eec0be4b1a7;hpb=412024ed31a4ab4eaea7a4165a434f8efebee325;p=senf.git diff --git a/Socket/Protocols/BSDSocketAddress.hh b/Socket/Protocols/BSDSocketAddress.hh index 5afd329..ec3edfd 100644 --- a/Socket/Protocols/BSDSocketAddress.hh +++ b/Socket/Protocols/BSDSocketAddress.hh @@ -27,6 +27,8 @@ #define HH_SENF_Socket_Protocols_BSDSocketAddress_ 1 // Custom includes +#include +#include #include "../../Utils/safe_bool.hh" #include #include @@ -112,8 +114,16 @@ namespace senf { void socklen(socklen_t len); private: - - socklen_t len_; + + // The following incantation is needed to fix the alignment of the sockaddr data members + // which will be added by the derived classes later: The alignment must be forced + // to coincide with the struct sockaddr_storage alignment (which must have the largest + // alignment of all sockaddr types). + union { + socklen_t len_; + boost::type_with_alignment::value> a_; + char _b[boost::alignment_of::value]; + }; }; /** \brief Safe socket address down-cast