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.38 2001/08/14 04:52:39 sam Exp $
8 * Authors: Samuel Hocevar <sam@via.ecp.fr>
9 * Vincent Seguin <seguin@via.ecp.fr>
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.
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.
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 *****************************************************************************/
26 /*****************************************************************************
29 *****************************************************************************/
31 /*****************************************************************************
32 * Basic types definitions
33 *****************************************************************************/
35 #include "int_types.h"
40 #ifdef BOOLEAN_T_IN_SYS_TYPES_H
41 # include <sys/types.h>
42 #elif defined(BOOLEAN_T_IN_PTHREAD_H)
44 #elif defined(BOOLEAN_T_IN_CTHREADS_H)
45 # include <cthreads.h>
47 typedef int boolean_t;
50 # define _MACH_I386_BOOLEAN_H_
53 /* ptrdiff_t definition */
60 /* Not portable in a 64-bit environment. */
61 typedef int ptrdiff_t;
65 /* Counter for statistics and profiling */
66 typedef unsigned long count_t;
68 /* DCT elements types */
70 typedef short dctelem_t;
72 typedef int dctelem_t;
75 /*****************************************************************************
77 *****************************************************************************/
83 typedef struct plugin_bank_s * p_plugin_bank_t;
84 typedef struct plugin_info_s * p_plugin_info_t;
88 struct playlist_item_s;
90 typedef struct playlist_s * p_playlist_t;
91 typedef struct playlist_item_s * p_playlist_item_t;
96 struct intf_console_s;
98 struct intf_channel_s;
100 typedef struct intf_thread_s * p_intf_thread_t;
101 typedef struct intf_sys_s * p_intf_sys_t;
102 typedef struct intf_console_s * p_intf_console_t;
103 typedef struct intf_msg_s * p_intf_msg_t;
104 typedef struct intf_channel_s * p_intf_channel_t;
107 struct input_thread_s;
108 struct input_channel_s;
111 typedef struct input_thread_s * p_input_thread_t;
112 typedef struct input_channel_s * p_input_channel_t;
113 typedef struct input_cfg_s * p_input_cfg_t;
116 struct aout_thread_s;
119 typedef struct aout_thread_s * p_aout_thread_t;
120 typedef struct aout_sys_s * p_aout_sys_t;
123 struct vout_thread_s;
126 struct vdec_thread_s;
127 struct vpar_thread_s;
128 struct video_parser_s;
130 typedef struct vout_thread_s * p_vout_thread_t;
131 typedef struct vout_font_s * p_vout_font_t;
132 typedef struct vout_sys_s * p_vout_sys_t;
133 typedef struct vdec_thread_s * p_vdec_thread_t;
134 typedef struct vpar_thread_s * p_vpar_thread_t;
135 typedef struct video_parser_s * p_video_parser_t;
139 struct data_packet_s;
140 struct es_descriptor_s;
141 struct pgrm_descriptor_s;
143 /*****************************************************************************
144 * Macros and inline functions
145 *****************************************************************************/
146 #ifdef NTOHL_IN_SYS_PARAM_H
147 # include <sys/param.h>
149 # include <winsock.h>
151 # include <netinet/in.h>
154 /* CEIL: division with round to nearest greater integer */
155 #define CEIL(n, d) ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
157 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
158 #define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
160 /* MAX and MIN: self explanatory */
162 # define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
165 # define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
168 /* MSB (big endian)/LSB (little endian) conversions - network order is always
169 * MSB, and should be used for both network communications and files. Note that
170 * byte orders other than little and big endians are not supported, but only
171 * the VAX seems to have such exotic properties - note that these 'functions'
172 * needs <netinet/in.h> or the local equivalent. */
173 /* FIXME: hton64 should be declared as an extern inline function to avoid
174 * border effects (see byteorder.h) */
176 # define hton16 htons
177 # define hton32 htonl
178 # define hton64(i) ( i )
179 # define ntoh16 ntohs
180 # define ntoh32 ntohl
181 # define ntoh64(i) ( i )
183 # define hton16 htons
184 # define hton32 htonl
185 # define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
186 # define ntoh16 ntohs
187 # define ntoh32 ntohl
188 # define ntoh64 hton64
191 /* Macros with automatic casts */
192 #define U64_AT(p) ( ntoh64 ( *( (u64 *)(p) ) ) )
193 #define U32_AT(p) ( ntoh32 ( *( (u32 *)(p) ) ) )
194 #define U16_AT(p) ( ntoh16 ( *( (u16 *)(p) ) ) )
196 /* win32, cl and icl support */
197 #if defined( _MSC_VER )
198 # define __attribute__(x)
199 # define __inline__ __inline
200 # define strncasecmp strnicmp
201 # define strcasecmp stricmp
202 # define S_ISBLK(m) (0)
203 # define S_ISCHR(m) (0)
204 # define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO)
205 # define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
208 # define I64C(x) x##LL
212 # ifndef _OFF_T_DEFINED
213 typedef __int64 off_t;
214 # define _OFF_T_DEFINED
217 # define snprintf _snprintf /* snprintf not defined in mingw32 (bug?) */