]> git.sesse.net Git - vlc/blob - include/common.h
. portage des vlc_threads aux cthreads de Mach pour GNU/Hurd
[vlc] / include / common.h
1 /*****************************************************************************
2  * common.h: common definitions
3  * (c)1998 VideoLAN
4  *****************************************************************************
5  * Collection of usefull common types and macros definitions
6  *****************************************************************************
7  * required headers:
8  *  config.h
9  *****************************************************************************/
10
11 /*****************************************************************************
12  * Basic types definitions
13  *****************************************************************************/
14
15 #include "int_types.h"
16
17 typedef u8                  byte_t;
18
19 /* Boolean type */
20 typedef int                 boolean_t;
21 #ifdef SYS_GNU
22 #define _MACH_I386_BOOLEAN_H_
23 #endif
24
25 /* Counter for statistics and profiling */
26 typedef unsigned long       count_t;
27
28 /*****************************************************************************
29  * Classes declaration
30  *****************************************************************************/
31
32 /* Interface */
33 struct intf_thread_s;
34 struct intf_sys_s;
35 struct intf_console_s;
36 struct intf_msg_s;
37 struct intf_channel_s;
38
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;
44
45 /* Input */
46 struct input_thread_s;
47 struct input_vlan_s;
48 struct input_cfg_s;
49
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;
53
54 /* Audio */
55 struct aout_thread_s;
56 struct aout_sys_s;
57
58 typedef struct aout_thread_s *          p_aout_thread_t;
59 typedef struct aout_sys_s *             p_aout_sys_t;
60
61 /* Video */
62 struct vout_thread_s;
63 struct vout_font_s;
64 struct vout_sys_s;
65 struct vdec_thread_s;
66 struct vpar_thread_s;
67 struct video_parser_s;
68
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;
75
76 /*****************************************************************************
77  * Macros and inline functions
78  *****************************************************************************/
79
80 /* CEIL: division with round to nearest greater integer */
81 #define CEIL(n, d)  ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
82
83 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
84 #define PAD(n, d)   ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
85
86 /* MAX and MIN: self explanatory */
87 #define MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
88 #define MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
89
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
98 #define hton16      htons
99 #define hton32      htonl
100 #define hton64(i)   ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
101 #define ntoh16      ntohs
102 #define ntoh32      ntohl
103 #define ntoh64      hton64
104 #elif __BYTE_ORDER == __BIG_ENDIAN
105 #define hton16      htons
106 #define hton32      htonl
107 #define hton64(i)   ( i )
108 #define ntoh16      ntohs
109 #define ntoh32      ntohl
110 #define ntoh64(i)   ( i )
111 #else
112 /* XXX??: cause a compilation error */
113 #endif
114
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) ) ) )