]> git.sesse.net Git - vlc/blob - include/common.h
* Fixed the BeOS compile typo.
[vlc] / include / common.h
1 /*****************************************************************************
2  * common.h: common definitions
3  * Collection of useful common types and macros definitions
4  *****************************************************************************
5  * Copyright (C) 1998, 1999, 2000 VideoLAN
6  * $Id: common.h,v 1.32 2001/05/30 17:03:11 sam Exp $
7  *
8  * Authors: Samuel Hocevar <sam@via.ecp.fr>
9  *          Vincent Seguin <seguin@via.ecp.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /*****************************************************************************
27  * required headers:
28  *  config.h
29  *****************************************************************************/
30
31 /*****************************************************************************
32  * Basic types definitions
33  *****************************************************************************/
34
35 #include "int_types.h"
36
37 typedef u8                  byte_t;
38
39 /* Boolean type */
40 #ifdef BOOLEAN_T_IN_SYS_TYPES_H
41 #   include <sys/types.h>
42 #elif defined(BOOLEAN_T_IN_PTHREAD_H)
43 #   include <pthread.h>
44 #else
45 typedef int                 boolean_t;
46 #endif
47 #ifdef SYS_GNU
48 #   define _MACH_I386_BOOLEAN_H_
49 #endif
50
51 /* ptrdiff_t definition */
52 #ifdef HAVE_STDDEF_H
53 #   include <stddef.h>
54 #else
55 #   include <malloc.h>
56 #   ifndef _PTRDIFF_T
57 #       define _PTRDIFF_T
58 /* Not portable in a 64-bit environment. */
59 typedef int                 ptrdiff_t;
60 #   endif
61 #endif
62
63 /* Counter for statistics and profiling */
64 typedef unsigned long       count_t;
65
66 /* DCT elements types */
67 #ifndef VDEC_DFT
68 typedef short dctelem_t;
69 #else
70 typedef int dctelem_t;
71 #endif
72
73 /*****************************************************************************
74  * Classes declaration
75  *****************************************************************************/
76
77 /* Plugins */
78 struct plugin_bank_s;
79 struct plugin_info_s;
80
81 typedef struct plugin_bank_s *          p_plugin_bank_t;
82 typedef struct plugin_info_s *          p_plugin_info_t;
83
84 /* Plugins */
85 struct playlist_s;
86 struct playlist_item_s;
87
88 typedef struct playlist_s *             p_playlist_t;
89 typedef struct playlist_item_s *        p_playlist_item_t;
90
91 /* Interface */
92 struct intf_thread_s;
93 struct intf_sys_s;
94 struct intf_console_s;
95 struct intf_msg_s;
96 struct intf_channel_s;
97
98 typedef struct intf_thread_s *          p_intf_thread_t;
99 typedef struct intf_sys_s *             p_intf_sys_t;
100 typedef struct intf_console_s *         p_intf_console_t;
101 typedef struct intf_msg_s *             p_intf_msg_t;
102 typedef struct intf_channel_s *         p_intf_channel_t;
103
104 /* Input */
105 struct input_thread_s;
106 struct input_channel_s;
107 struct input_cfg_s;
108
109 typedef struct input_thread_s *         p_input_thread_t;
110 typedef struct input_channel_s *        p_input_channel_t;
111 typedef struct input_cfg_s *            p_input_cfg_t;
112
113 /* Audio */
114 struct aout_thread_s;
115 struct aout_sys_s;
116
117 typedef struct aout_thread_s *          p_aout_thread_t;
118 typedef struct aout_sys_s *             p_aout_sys_t;
119
120 /* Video */
121 struct vout_thread_s;
122 struct vout_font_s;
123 struct vout_sys_s;
124 struct vdec_thread_s;
125 struct vpar_thread_s;
126 struct video_parser_s;
127
128 typedef struct vout_thread_s *          p_vout_thread_t;
129 typedef struct vout_font_s *            p_vout_font_t;
130 typedef struct vout_sys_s *             p_vout_sys_t;
131 typedef struct vdec_thread_s *          p_vdec_thread_t;
132 typedef struct vpar_thread_s *          p_vpar_thread_t;
133 typedef struct video_parser_s *         p_video_parser_t;
134
135 /* Misc */
136 struct macroblock_s;
137 struct data_packet_s;
138 struct es_descriptor_s;
139
140 /*****************************************************************************
141  * Macros and inline functions
142  *****************************************************************************/
143
144 #ifdef NTOHL_IN_SYS_PARAM_H
145 #   include <sys/param.h>
146 #elif defined(WIN32)
147 #else
148 #   include <netinet/in.h>
149 #endif
150
151 /* CEIL: division with round to nearest greater integer */
152 #define CEIL(n, d)  ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
153
154 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
155 #define PAD(n, d)   ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
156
157 /* MAX and MIN: self explanatory */
158 #ifndef MAX
159 #define MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
160 #endif
161 #ifndef MIN
162 #define MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
163 #endif
164
165 /* MSB (big endian)/LSB (little endian) conversions - network order is always
166  * MSB, and should be used for both network communications and files. Note that
167  * byte orders other than little and big endians are not supported, but only
168  * the VAX seems to have such exotic properties - note that these 'functions'
169  * needs <netinet/in.h> or the local equivalent. */
170 /* FIXME: hton64 should be declared as an extern inline function to avoid
171  * border effects (see byteorder.h) */
172 #if WORDS_BIGENDIAN
173 #define hton16      htons
174 #define hton32      htonl
175 #define hton64(i)   ( i )
176 #define ntoh16      ntohs
177 #define ntoh32      ntohl
178 #define ntoh64(i)   ( i )
179 #else
180 #define hton16      htons
181 #define hton32      htonl
182 #define hton64(i)   ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
183 #define ntoh16      ntohs
184 #define ntoh32      ntohl
185 #define ntoh64      hton64
186 #endif
187
188 /* Macros with automatic casts */
189 #define U64_AT(p)   ( ntoh64 ( *( (u64 *)(p) ) ) )
190 #define U32_AT(p)   ( ntoh32 ( *( (u32 *)(p) ) ) )
191 #define U16_AT(p)   ( ntoh16 ( *( (u16 *)(p) ) ) )
192