Skip to content

Commit

Permalink
Make #pragma pack() work on Solaris
Browse files Browse the repository at this point in the history
  • Loading branch information
Carson Gaspar committed Dec 12, 2011
1 parent 2c678a2 commit dcf7394
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ template <typename T> static inline T clamp(T v, T mi, T ma)
return v;
}

#if (defined(__SVR4) && defined(__sun))
#pragma pack(1)
#else
#pragma pack(push,1)
#endif

namespace aux
{
Expand All @@ -68,7 +72,11 @@ typedef big_endian<int32> int32_big;
typedef big_endian<uint32> uint32_big;
typedef big_endian<uint16> uint16_big;

#if (defined(__SVR4) && defined(__sun))
#pragma pack(0)
#else
#pragma pack(pop)
#endif

template<typename T> static inline void zeromem(T *a, size_t count = 1) { memset(a, 0, count * sizeof(T)); }

Expand Down
8 changes: 8 additions & 0 deletions utp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ char addrbuf[65];
char addrbuf2[65];
#define addrfmt(x, s) x.fmt(s, sizeof(s))

#if (defined(__SVR4) && defined(__sun))
#pragma pack(1)
#else
#pragma pack(push,1)
#endif

struct PACKED_ATTRIBUTE PackedSockAddr {

Expand Down Expand Up @@ -280,7 +284,11 @@ struct PACKED_ATTRIBUTE PacketFormatExtensionsV1 {
byte extensions[8];
};

#if (defined(__SVR4) && defined(__sun))
#pragma pack(0)
#else
#pragma pack(pop)
#endif

enum {
ST_DATA = 0, // Data packet.
Expand Down

0 comments on commit dcf7394

Please sign in to comment.