Get rid of those ugly hton and ntoh functions (should fix the solaris

port).
parent 8682819d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* common.h: common definitions * common.h: common definitions
*------------------------------------------------------------------------------- *-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN * (c)1999-2001 VideoLAN
* $Id: common.h,v 1.2 2002/03/24 15:56:08 asmax Exp $ * $Id: common.h,v 1.3 2002/03/25 03:48:58 bozo Exp $
* *
* Authors: Benoit Steiner <benny@via.ecp.fr> * Authors: Benoit Steiner <benny@via.ecp.fr>
* *
...@@ -113,18 +113,30 @@ typedef unsigned long count; ...@@ -113,18 +113,30 @@ typedef unsigned long count;
// MSB/LSB (ie big endian/little endian) convertions - network order is always // MSB/LSB (ie big endian/little endian) convertions - network order is always
// MSB, and should be used for both network communications and files // MSB, and should be used for both network communications and files
#define hton16 htons //#define hton16 htons
#define hton32 htonl //#define hton32 htonl
#define ntoh16 ntohs //#define ntoh16 ntohs
#define ntoh32 ntohl //#define ntoh32 ntohl
// Macros used to read a TS packet // Macros used to read a TS packet
#define U32_AT(p) ( ntoh32(*((u32 *)&(p))) ) //#define U16_AT(p) ( ntoh16(*((u16 *)&(p))) )
#define U16_AT(p) ( ntoh16(*((u16 *)&(p))) ) //#define U32_AT(p) ( ntoh32(*((u32 *)&(p))) )
#define U16_AT(p) ( (((u16)((u8*)&(p))[0]) << 8) \
| (((u32)((u8*)&(p))[1])) )
#define U32_AT(p) ( (((u32)((u8*)&(p))[0]) << 24) \
| (((u32)((u8*)&(p))[1]) << 16) \
| (((u32)((u8*)&(p))[2]) << 8) \
| (((u32)((u8*)&(p))[3])) )
// Macros used to write a TS packet // Macros used to write a TS packet
#define SET_U16_TO(p, n) ( *((u16*)&p) = hton16(n) ) //#define SET_U16_TO(p, n) ( *((u16*)&p) = hton16(n) )
#define SET_U32_TO(p, n) ( *((u32*)&p) = hton32(n) ) //#define SET_U32_TO(p, n) ( *((u32*)&p) = hton32(n) )
#define SET_U16_TO(p, n) ((u8*)&(p))[0] = (n) >> 8; \
((u8*)&(p))[1] = (n);
#define SET_U32_TO(p, n) ((u8*)&(p))[0] = (n) >> 24; \
((u8*)&(p))[1] = (n) >> 16; \
((u8*)&(p))[2] = (n) >> 8; \
((u8*)&(p))[3] = (n);
#else #else
......
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