Commit bbf85aaf authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Make endianness-conversion macros less fragile.

parent 2b757086
......@@ -21,10 +21,10 @@ THE SOFTWARE.
*/
#if defined(i386) || defined(__mc68020__) || defined(__x86_64__)
#define DO_NTOHS(_d, _s) do { _d = ntohs(*(unsigned short*)(_s)); } while(0)
#define DO_NTOHL(_d, _s) do { _d = ntohl(*(unsigned*)(_s)); } while(0)
#define DO_HTONS(_d, _s) do { *(unsigned short*)(_d) = htons(_s); } while(0)
#define DO_HTONL(_d, _s) do { *(unsigned*)(_d) = htonl(_s); } while(0)
#define DO_NTOHS(_d, _s) do{ _d = ntohs(*(const unsigned short*)(_s)); }while(0)
#define DO_NTOHL(_d, _s) do{ _d = ntohl(*(const unsigned*)(_s)); } while(0)
#define DO_HTONS(_d, _s) do{ *(unsigned short*)(_d) = htons(_s); } while(0)
#define DO_HTONL(_d, _s) do{ *(unsigned*)(_d) = htonl(_s); } while(0)
/* Some versions of gcc seem to be buggy, and ignore the packed attribute.
Disable this code until the issue is clarified. */
/* #elif defined __GNUC__*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment