1 /*****************************************************************************
2 * common.h: common definitions
4 *****************************************************************************
5 * Collection of usefull common types and macros definitions
6 *****************************************************************************
9 *****************************************************************************/
11 /*****************************************************************************
12 * Basic types definitions
13 *****************************************************************************/
15 /* Basic types definitions */
16 typedef signed char s8;
17 typedef signed short s16;
18 typedef signed int s32;
19 typedef signed long long s64;
20 typedef unsigned char u8;
21 typedef unsigned short u16;
22 typedef unsigned int u32;
23 typedef unsigned long long u64;
28 typedef int boolean_t;
30 /* Counter for statistics and profiling */
31 typedef unsigned long count_t;
33 /*****************************************************************************
35 *****************************************************************************/
40 struct intf_console_s;
42 struct intf_channel_s;
44 typedef struct intf_thread_s * p_intf_thread_t;
45 typedef struct intf_sys_s * p_intf_sys_t;
46 typedef struct intf_console_s * p_intf_console_t;
47 typedef struct intf_msg_s * p_intf_msg_t;
48 typedef struct intf_channel_s * p_intf_channel_t;
51 struct input_thread_s;
55 typedef struct input_thread_s * p_input_thread_t;
56 typedef struct input_vlan_s * p_input_vlan_t;
57 typedef struct input_cfg_s * p_input_cfg_t;
63 typedef struct aout_thread_s * p_aout_thread_t;
64 typedef struct aout_sys_s * p_aout_sys_t;
72 struct video_parser_s;
74 typedef struct vout_thread_s * p_vout_thread_t;
75 typedef struct vout_font_s * p_vout_font_t;
76 typedef struct vout_sys_s * p_vout_sys_t;
77 typedef struct vdec_thread_s * p_vdec_thread_t;
78 typedef struct vpar_thread_s * p_vpar_thread_t;
79 typedef struct video_parser_s * p_video_parser_t;
81 /*****************************************************************************
82 * Macros and inline functions
83 *****************************************************************************/
85 /* CEIL: division with round to nearest greater integer */
86 #define CEIL(n, d) ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
88 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
89 #define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
91 /* MAX and MIN: self explanatory */
92 #define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
93 #define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
95 /* MSB (big endian)/LSB (little endian) convertions - network order is always
96 * MSB, and should be used for both network communications and files. Note that
97 * byte orders other than little and big endians are not supported, but only
98 * the VAX seems to have such exotic properties - note that these 'functions'
99 * needs <netinet/in.h> or the local equivalent. */
100 /* ?? hton64 should be declared as an extern inline function to avoid border
101 * effects (see byteorder.h) */
102 #if __BYTE_ORDER == __LITTLE_ENDIAN
105 #define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
108 #define ntoh64 hton64
109 #elif __BYTE_ORDER == __BIG_ENDIAN
112 #define hton64(i) ( i )
115 #define ntoh64(i) ( i )
117 /* ?? cause a compilation error */
120 /* Macros used by input to access the TS buffer */
121 #define U32_AT(p) ( ntohl ( *( (u32 *)(p) ) ) )
122 #define U16_AT(p) ( ntohs ( *( (u16 *)(p) ) ) )