From: Jordan Lee <jordan@transmissionbt.com> Date: Wed, 10 Aug 2011 14:51:59 +0000 (+0000) Subject: #4260 "µTP not working on embedded device" -- apply the changes from https://github... X-Git-Tag: 2.40b1~242 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5df3c77cf2a9982c9f5735885d3513ddc6548f8c;p=transmission #4260 "µTP not working on embedded device" -- apply the changes from https://github.com/ghazel/libutp rather than http://github.com/bittorrent/libutp --- 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 <class T> -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 <stdbool.h> +typedef uint8 bool; #endif #endif //__UTYPES_H__