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 #include "int_types.h"
20 typedef int boolean_t;
22 #define _MACH_I386_BOOLEAN_H_
25 /* Counter for statistics and profiling */
26 typedef unsigned long count_t;
28 /*****************************************************************************
30 *****************************************************************************/
35 struct intf_console_s;
37 struct intf_channel_s;
39 typedef struct intf_thread_s * p_intf_thread_t;
40 typedef struct intf_sys_s * p_intf_sys_t;
41 typedef struct intf_console_s * p_intf_console_t;
42 typedef struct intf_msg_s * p_intf_msg_t;
43 typedef struct intf_channel_s * p_intf_channel_t;
46 struct input_thread_s;
50 typedef struct input_thread_s * p_input_thread_t;
51 typedef struct input_vlan_s * p_input_vlan_t;
52 typedef struct input_cfg_s * p_input_cfg_t;
58 typedef struct aout_thread_s * p_aout_thread_t;
59 typedef struct aout_sys_s * p_aout_sys_t;
67 struct video_parser_s;
69 typedef struct vout_thread_s * p_vout_thread_t;
70 typedef struct vout_font_s * p_vout_font_t;
71 typedef struct vout_sys_s * p_vout_sys_t;
72 typedef struct vdec_thread_s * p_vdec_thread_t;
73 typedef struct vpar_thread_s * p_vpar_thread_t;
74 typedef struct video_parser_s * p_video_parser_t;
76 /*****************************************************************************
77 * Macros and inline functions
78 *****************************************************************************/
80 /* CEIL: division with round to nearest greater integer */
81 #define CEIL(n, d) ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
83 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
84 #define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
86 /* MAX and MIN: self explanatory */
87 #define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
88 #define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
90 /* MSB (big endian)/LSB (little endian) convertions - network order is always
91 * MSB, and should be used for both network communications and files. Note that
92 * byte orders other than little and big endians are not supported, but only
93 * the VAX seems to have such exotic properties - note that these 'functions'
94 * needs <netinet/in.h> or the local equivalent. */
95 /* FIXME??: hton64 should be declared as an extern inline function to avoid border
96 * effects (see byteorder.h) */
97 #if __BYTE_ORDER == __LITTLE_ENDIAN
100 #define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
103 #define ntoh64 hton64
104 #elif __BYTE_ORDER == __BIG_ENDIAN
107 #define hton64(i) ( i )
110 #define ntoh64(i) ( i )
112 /* XXX??: cause a compilation error */
115 /* Macros used by input to access the TS buffer */
116 #define U32_AT(p) ( ntohl ( *( (u32 *)(p) ) ) )
117 #define U16_AT(p) ( ntohs ( *( (u16 *)(p) ) ) )