Changeset 12466


Ignore:
Timestamp:
May 28, 2011, 12:50:11 AM (10 years ago)
Author:
jordan
Message:

(trunk libutp) #4260 "uTP not working on embedded device" -- use attribute ((packed)) on gcc compilers as suggested by KyleK

Location:
trunk/third-party/libutp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/third-party/libutp/templates.h

    r11919 r12466  
    3636}
    3737
    38 #pragma pack(push,1)
     38#ifdef __GNUC__
     39 #define PACKED_ATTRIBUTE __attribute__((__packed__))
     40#else
     41 #define PACKED_ATTRIBUTE
     42 #pragma pack(push,1)
     43#endif
    3944
    4045namespace aux
     
    4954
    5055template <class T>
    51 struct big_endian
     56struct PACKED_ATTRIBUTE big_endian
    5257{
    5358        T operator=(T i) { m_integer = aux::host_to_network(i); return i; }
     
    6166typedef big_endian<uint16> uint16_big;
    6267
    63 #pragma pack(pop)
     68#ifndef __GNUC__
     69 #pragma pack(pop)
     70#endif
    6471
    6572template<typename T> static inline void zeromem(T *a, size_t count = 1) { memset(a, 0, count * sizeof(T)); }
  • trunk/third-party/libutp/utp.cpp

    r12140 r12466  
    9393#define addrfmt(x, s) x.fmt(s, sizeof(s))
    9494
    95 #pragma pack(push,1)
    96 
    97 struct PackedSockAddr {
     95#ifdef __GNUC__
     96 #define PACKED_ATTRIBUTE __attribute__((__packed__))
     97#else
     98 #define PACKED_ATTRIBUTE
     99 #pragma pack(push,1)
     100#endif
     101
     102struct PACKED_ATTRIBUTE PackedSockAddr {
    98103
    99104        // The values are always stored here in network byte order
     
    193198};
    194199
    195 struct RST_Info {
     200struct PACKED_ATTRIBUTE RST_Info {
    196201        PackedSockAddr addr;
    197202        uint32 connid;
     
    212217#define PACKET_SIZE_HUGE_BUCKET 4
    213218
    214 struct PacketFormat {
     219struct PACKED_ATTRIBUTE PacketFormat {
    215220        // connection ID
    216221        uint32_big connid;
     
    230235};
    231236
    232 struct PacketFormatAck {
     237struct PACKED_ATTRIBUTE PacketFormatAck {
    233238        PacketFormat pf;
    234239        byte ext_next;
     
    237242};
    238243
    239 struct PacketFormatExtensions {
     244struct PACKED_ATTRIBUTE PacketFormatExtensions {
    240245        PacketFormat pf;
    241246        byte ext_next;
     
    244249};
    245250
    246 struct PacketFormatV1 {
     251struct PACKED_ATTRIBUTE PacketFormatV1 {
    247252        // packet_type (4 high bits)
    248253        // protocol version (4 low bits)
     
    267272};
    268273
    269 struct PacketFormatAckV1 {
     274struct PACKED_ATTRIBUTE PacketFormatAckV1 {
    270275        PacketFormatV1 pf;
    271276        byte ext_next;
     
    274279};
    275280
    276 struct PacketFormatExtensionsV1 {
     281struct PACKED_ATTRIBUTE PacketFormatExtensionsV1 {
    277282        PacketFormatV1 pf;
    278283        byte ext_next;
     
    281286};
    282287
    283 #pragma pack(pop)
     288#ifndef __GNUC__
     289 #pragma pack(pop)
     290#endif
    284291
    285292enum {
Note: See TracChangeset for help on using the changeset viewer.