Changeset 12603


Ignore:
Timestamp:
Jul 30, 2011, 10:15:32 PM (12 years ago)
Author:
jordan
Message:

(trunk, libutp) #4260 "uTP not working when compiler doesn't honor 'pragma pack'" -- apply alus' revised patch for testing.

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

Legend:

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

    r12466 r12603  
    3636}
    3737
    38 #ifdef __GNUC__
    39  #define PACKED_ATTRIBUTE __attribute__((__packed__))
    40 #else
    41  #define PACKED_ATTRIBUTE
    42  #pragma pack(push,1)
    43 #endif
     38#pragma pack(push,1)
    4439
    4540namespace aux
     
    5449
    5550template <class T>
    56 struct PACKED_ATTRIBUTE big_endian
     51struct big_endian
    5752{
    5853        T operator=(T i) { m_integer = aux::host_to_network(i); return i; }
     
    6661typedef big_endian<uint16> uint16_big;
    6762
    68 #ifndef __GNUC__
    69  #pragma pack(pop)
    70 #endif
     63#pragma pack(pop)
    7164
    7265template<typename T> static inline void zeromem(T *a, size_t count = 1) { memset(a, 0, count * sizeof(T)); }
  • trunk/third-party/libutp/utp.cpp

    r12583 r12603  
    9393#define addrfmt(x, s) x.fmt(s, sizeof(s))
    9494
    95 #ifdef __GNUC__
    96  #define PACKED_ATTRIBUTE __attribute__((__packed__))
    97 #else
    98  #define PACKED_ATTRIBUTE
    99  #pragma pack(push,1)
    100 #endif
    101 
    102 struct PACKED_ATTRIBUTE PackedSockAddr {
     95#pragma pack(push,1)
     96
     97struct PackedSockAddr {
    10398
    10499        // The values are always stored here in network byte order
     
    198193};
    199194
    200 struct PACKED_ATTRIBUTE RST_Info {
     195struct RST_Info {
    201196        PackedSockAddr addr;
    202197        uint32 connid;
     
    217212#define PACKET_SIZE_HUGE_BUCKET 4
    218213
    219 struct PACKED_ATTRIBUTE PacketFormat {
     214struct PacketFormat {
    220215        // connection ID
    221216        uint32_big connid;
     
    235230};
    236231
    237 struct PACKED_ATTRIBUTE PacketFormatAck {
     232struct PacketFormatAck {
    238233        PacketFormat pf;
    239234        byte ext_next;
     
    242237};
    243238
    244 struct PACKED_ATTRIBUTE PacketFormatExtensions {
     239struct PacketFormatExtensions {
    245240        PacketFormat pf;
    246241        byte ext_next;
     
    249244};
    250245
    251 struct PACKED_ATTRIBUTE PacketFormatV1 {
     246struct PacketFormatV1 {
    252247        // packet_type (4 high bits)
    253248        // protocol version (4 low bits)
     
    272267};
    273268
    274 struct PACKED_ATTRIBUTE PacketFormatAckV1 {
     269struct PacketFormatAckV1 {
    275270        PacketFormatV1 pf;
    276271        byte ext_next;
     
    279274};
    280275
    281 struct PACKED_ATTRIBUTE PacketFormatExtensionsV1 {
     276struct PacketFormatExtensionsV1 {
    282277        PacketFormatV1 pf;
    283278        byte ext_next;
     
    286281};
    287282
    288 #ifndef __GNUC__
    289  #pragma pack(pop)
    290 #endif
     283#pragma pack(pop)
    291284
    292285enum {
Note: See TracChangeset for help on using the changeset viewer.