Socket/Protocols: (hopefully) fix sockaddr alignment issues on 64bit
g0dil [Tue, 25 Nov 2008 12:55:23 +0000 (12:55 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@978 270642c3-0616-0410-b53a-bc976706d245

Socket/Protocols/BSDSocketAddress.hh

index 5afd329..9fbc5f0 100644 (file)
@@ -27,6 +27,8 @@
 #define HH_SENF_Socket_Protocols_BSDSocketAddress_ 1
 
 // Custom includes
+#include <boost/type_traits/alignment_of.hpp>
+#include <boost/type_traits/type_with_alignment.hpp>
 #include "../../Utils/safe_bool.hh"
 #include <sys/socket.h>
 #include <iostream>
@@ -113,7 +115,10 @@ namespace senf {
 
     private:
 
-        socklen_t len_;
+        union {
+            socklen_t len_;
+            boost::type_with_alignment<boost::alignment_of<struct sockaddr_storage>::value> _;
+        };
     };
 
     /** \brief Safe socket address down-cast