From 5df3c77cf2a9982c9f5735885d3513ddc6548f8c Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Wed, 10 Aug 2011 14:51:59 +0000 Subject: [PATCH] =?utf8?q?#4260=20"=C2=B5TP=20not=20working=20on=20embedde?= =?utf8?q?d=20device"=20--=20apply=20the=20changes=20from=20https://github?= =?utf8?q?.com/ghazel/libutp=20rather=20than=20http://github.com/bittorren?= =?utf8?q?t/libutp?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- third-party/libutp/templates.h | 10 +++++++++- third-party/libutp/utp.cpp | 16 ++++++++-------- third-party/libutp/utypes.h | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/third-party/libutp/templates.h b/third-party/libutp/templates.h index 9e98fb3d7..ca89ae462 100644 --- a/third-party/libutp/templates.h +++ b/third-party/libutp/templates.h @@ -19,6 +19,14 @@ #endif #endif +#ifdef __GNUC__ +// Used for gcc tool chains accepting but not supporting pragma pack +// See http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html +#define PACKED_ATTRIBUTE __attribute__((__packed__)) +#else +#define PACKED_ATTRIBUTE +#endif + // Utility templates #undef min #undef max @@ -48,7 +56,7 @@ namespace aux } template -struct big_endian +struct PACKED_ATTRIBUTE big_endian { T operator=(T i) { m_integer = aux::host_to_network(i); return i; } operator T() const { return aux::network_to_host(m_integer); } diff --git a/third-party/libutp/utp.cpp b/third-party/libutp/utp.cpp index c5f431ee5..99ad98fa7 100644 --- a/third-party/libutp/utp.cpp +++ b/third-party/libutp/utp.cpp @@ -94,7 +94,7 @@ char addrbuf2[65]; #pragma pack(push,1) -struct PackedSockAddr { +struct PACKED_ATTRIBUTE PackedSockAddr { // The values are always stored here in network byte order union { @@ -192,7 +192,7 @@ struct PackedSockAddr { } }; -struct RST_Info { +struct PACKED_ATTRIBUTE RST_Info { PackedSockAddr addr; uint32 connid; uint32 timestamp; @@ -211,7 +211,7 @@ struct RST_Info { #define PACKET_SIZE_BIG 1400 #define PACKET_SIZE_HUGE_BUCKET 4 -struct PacketFormat { +struct PACKED_ATTRIBUTE PacketFormat { // connection ID uint32_big connid; uint32_big tv_sec; @@ -229,21 +229,21 @@ struct PacketFormat { uint16_big ack_nr; }; -struct PacketFormatAck { +struct PACKED_ATTRIBUTE PacketFormatAck { PacketFormat pf; byte ext_next; byte ext_len; byte acks[4]; }; -struct PacketFormatExtensions { +struct PACKED_ATTRIBUTE PacketFormatExtensions { PacketFormat pf; byte ext_next; byte ext_len; byte extensions[8]; }; -struct PacketFormatV1 { +struct PACKED_ATTRIBUTE PacketFormatV1 { // packet_type (4 high bits) // protocol version (4 low bits) byte ver_type; @@ -266,14 +266,14 @@ struct PacketFormatV1 { uint16_big ack_nr; }; -struct PacketFormatAckV1 { +struct PACKED_ATTRIBUTE PacketFormatAckV1 { PacketFormatV1 pf; byte ext_next; byte ext_len; byte acks[4]; }; -struct PacketFormatExtensionsV1 { +struct PACKED_ATTRIBUTE PacketFormatExtensionsV1 { PacketFormatV1 pf; byte ext_next; byte ext_len; diff --git a/third-party/libutp/utypes.h b/third-party/libutp/utypes.h index d4f4b17ec..673554e24 100644 --- a/third-party/libutp/utypes.h +++ b/third-party/libutp/utypes.h @@ -36,7 +36,7 @@ typedef const char * cstr; typedef char * str; #ifndef __cplusplus -#include +typedef uint8 bool; #endif #endif //__UTYPES_H__ -- 2.40.0