skins2: fix uninitialized variable
[vlc.git] / include / vlc_fixups.h
blob305de87ef6ee44b661d189a0472585f8c61614f4
1 /*****************************************************************************
2 * vlc_fixups.h: portability fixups included from config.h
3 *****************************************************************************
4 * Copyright © 1998-2008 the VideoLAN project
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 /**
22 * \file
23 * This file is a collection of portability fixes
26 #ifndef LIBVLC_FIXUPS_H
27 # define LIBVLC_FIXUPS_H 1
29 /* C++11 says there's no need to define __STDC_*_MACROS when including
30 * inttypes.h and stdint.h. */
31 #if defined (__cplusplus) && (!defined(HAVE_CXX11) || defined(__MINGW32__))
32 # ifndef __STDC_FORMAT_MACROS
33 # define __STDC_FORMAT_MACROS 1
34 # endif
35 # ifndef __STDC_CONSTANT_MACROS
36 # define __STDC_CONSTANT_MACROS 1
37 # endif
38 # ifndef __STDC_LIMIT_MACROS
39 # define __STDC_LIMIT_MACROS 1
40 # endif
41 #endif
43 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R)
44 # include <time.h> /* time_t */
45 #endif
47 #ifndef HAVE_LLDIV
48 typedef struct
50 long long quot; /* Quotient. */
51 long long rem; /* Remainder. */
52 } lldiv_t;
53 #endif
55 #if !defined(HAVE_GETENV) || \
56 !defined(HAVE_USELOCALE)
57 # include <stddef.h> /* NULL */
58 #endif
60 #if !defined (HAVE_REWIND) || \
61 !defined (HAVE_GETDELIM)
62 # include <stdio.h> /* FILE */
63 #endif
65 #if !defined (HAVE_POSIX_MEMALIGN) || \
66 !defined (HAVE_STRLCPY) || \
67 !defined (HAVE_STRNDUP) || \
68 !defined (HAVE_STRNLEN)
69 # include <stddef.h> /* size_t */
70 #endif
72 #ifndef HAVE_VASPRINTF
73 # include <stdarg.h> /* va_list */
74 #endif
76 #if !defined (HAVE_GETDELIM) || \
77 !defined (HAVE_GETPID) || \
78 !defined (HAVE_SWAB)
79 # include <sys/types.h> /* ssize_t, pid_t */
80 #endif
82 #if !defined (HAVE_DIRFD) || \
83 !defined (HAVE_FDOPENDIR)
84 # include <dirent.h>
85 #endif
87 #ifdef __cplusplus
88 # define VLC_NOTHROW throw ()
89 extern "C" {
90 #else
91 # define VLC_NOTHROW
92 #endif
94 /* stdio.h */
95 #ifndef HAVE_ASPRINTF
96 int asprintf (char **, const char *, ...);
97 #endif
99 #ifndef HAVE_FLOCKFILE
100 void flockfile (FILE *);
101 int ftrylockfile (FILE *);
102 void funlockfile (FILE *);
103 int getc_unlocked (FILE *);
104 int getchar_unlocked (void);
105 int putc_unlocked (int, FILE *);
106 int putchar_unlocked (int);
107 #endif
109 #ifndef HAVE_GETDELIM
110 ssize_t getdelim (char **, size_t *, int, FILE *);
111 ssize_t getline (char **, size_t *, FILE *);
112 #endif
114 #ifndef HAVE_REWIND
115 void rewind (FILE *);
116 #endif
118 #ifndef HAVE_VASPRINTF
119 int vasprintf (char **, const char *, va_list);
120 #endif
122 /* string.h */
123 #ifndef HAVE_FFSLL
124 int ffsll(unsigned long long);
125 #endif
127 #ifndef HAVE_STRCASECMP
128 int strcasecmp (const char *, const char *);
129 #endif
131 #ifndef HAVE_STRCASESTR
132 char *strcasestr (const char *, const char *);
133 #endif
135 #ifndef HAVE_STRDUP
136 char *strdup (const char *);
137 #endif
139 #ifndef HAVE_STRVERSCMP
140 int strverscmp (const char *, const char *);
141 #endif
143 #ifndef HAVE_STRNLEN
144 size_t strnlen (const char *, size_t);
145 #endif
147 #ifndef HAVE_STRNDUP
148 char *strndup (const char *, size_t);
149 #endif
151 #ifndef HAVE_STRLCPY
152 size_t strlcpy (char *, const char *, size_t);
153 #endif
155 #ifndef HAVE_STRSEP
156 char *strsep (char **, const char *);
157 #endif
159 #ifndef HAVE_STRTOK_R
160 char *strtok_r(char *, const char *, char **);
161 #endif
163 /* stdlib.h */
164 #ifndef HAVE_ATOF
165 #ifndef __ANDROID__
166 double atof (const char *);
167 #endif
168 #endif
170 #ifndef HAVE_ATOLL
171 long long atoll (const char *);
172 #endif
174 #ifndef HAVE_LLDIV
175 lldiv_t lldiv (long long, long long);
176 #endif
178 #ifndef HAVE_STRTOF
179 #ifndef __ANDROID__
180 float strtof (const char *, char **);
181 #endif
182 #endif
184 #ifndef HAVE_STRTOLL
185 long long int strtoll (const char *, char **, int);
186 #endif
188 /* time.h */
189 #ifndef HAVE_GMTIME_R
190 struct tm *gmtime_r (const time_t *, struct tm *);
191 #endif
193 #ifndef HAVE_LOCALTIME_R
194 struct tm *localtime_r (const time_t *, struct tm *);
195 #endif
197 /* unistd.h */
198 #ifndef HAVE_GETPID
199 pid_t getpid (void) VLC_NOTHROW;
200 #endif
202 #ifndef HAVE_FSYNC
203 int fsync (int fd);
204 #endif
206 /* dirent.h */
207 #ifndef HAVE_DIRFD
208 int (dirfd) (DIR *);
209 #endif
211 #ifndef HAVE_FDOPENDIR
212 DIR *fdopendir (int);
213 #endif
215 #ifdef __cplusplus
216 } /* extern "C" */
217 #endif
219 /* stdlib.h */
220 #ifndef HAVE_GETENV
221 static inline char *getenv (const char *name)
223 (void)name;
224 return NULL;
226 #endif
228 #ifndef HAVE_SETENV
229 int setenv (const char *, const char *, int);
230 int unsetenv (const char *);
231 #endif
233 #ifndef HAVE_POSIX_MEMALIGN
234 int posix_memalign (void **, size_t, size_t);
235 #endif
237 /* locale.h */
238 #ifndef HAVE_USELOCALE
239 #define LC_ALL_MASK 0
240 #define LC_NUMERIC_MASK 0
241 #define LC_MESSAGES_MASK 0
242 #define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
243 typedef void *locale_t;
244 static inline locale_t uselocale(locale_t loc)
246 (void)loc;
247 return NULL;
249 static inline void freelocale(locale_t loc)
251 (void)loc;
253 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
255 (void)mask; (void)locale; (void)base;
256 return NULL;
258 #endif
260 #if !defined (HAVE_STATIC_ASSERT) && !defined(__cpp_static_assert)
261 # define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
262 # define static_assert _Static_assert
263 #endif
265 /* Alignment of critical static data structures */
266 #ifdef ATTRIBUTE_ALIGNED_MAX
267 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
268 #else
269 # define ATTR_ALIGN(align)
270 #endif
272 /* libintl support */
273 #define _(str) vlc_gettext (str)
274 #define N_(str) gettext_noop (str)
275 #define gettext_noop(str) (str)
277 #ifdef __cplusplus
278 extern "C" {
279 #endif
281 #ifndef HAVE_SWAB
282 void swab (const void *, void *, ssize_t);
283 #endif
285 /* Socket stuff */
286 #ifndef HAVE_INET_PTON
287 int inet_pton(int, const char *, void *);
288 const char *inet_ntop(int, const void *, char *, int);
289 #endif
291 #ifndef HAVE_STRUCT_POLLFD
292 enum
294 POLLERR=0x1,
295 POLLHUP=0x2,
296 POLLNVAL=0x4,
297 POLLWRNORM=0x10,
298 POLLWRBAND=0x20,
299 POLLRDNORM=0x100,
300 POLLRDBAND=0x200,
301 POLLPRI=0x400,
303 #define POLLIN (POLLRDNORM|POLLRDBAND)
304 #define POLLOUT (POLLWRNORM|POLLWRBAND)
306 struct pollfd
308 int fd;
309 unsigned events;
310 unsigned revents;
312 #endif
313 #ifndef HAVE_POLL
314 struct pollfd;
315 int poll (struct pollfd *, unsigned, int);
316 #endif
318 #ifndef HAVE_IF_NAMEINDEX
319 #include <errno.h>
320 struct if_nameindex
322 unsigned if_index;
323 char *if_name;
325 # ifndef HAVE_IF_NAMETOINDEX
326 # define if_nametoindex(name) atoi(name)
327 # endif
328 # define if_nameindex() (errno = ENOBUFS, NULL)
329 # define if_freenameindex(list) (void)0
330 #endif
332 /* search.h */
333 #ifndef HAVE_SEARCH_H
334 typedef struct entry {
335 char *key;
336 void *data;
337 } ENTRY;
339 typedef enum {
340 FIND, ENTER
341 } ACTION;
343 typedef enum {
344 preorder,
345 postorder,
346 endorder,
347 leaf
348 } VISIT;
350 void *tsearch( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
351 void *tfind( const void *key, const void **rootp, int(*cmp)(const void *, const void *) );
352 void *tdelete( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
353 void twalk( const void *root, void(*action)(const void *nodep, VISIT which, int depth) );
354 void tdestroy( void *root, void (*free_node)(void *nodep) );
355 #else // HAVE_SEARCH_H
356 # ifndef HAVE_TDESTROY
357 # define tdestroy vlc_tdestroy
358 # endif
359 #endif
361 /* Random numbers */
362 #ifndef HAVE_NRAND48
363 double erand48 (unsigned short subi[3]);
364 long jrand48 (unsigned short subi[3]);
365 long nrand48 (unsigned short subi[3]);
366 #endif
368 #ifdef __OS2__
369 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
371 struct addrinfo
373 int ai_flags;
374 int ai_family;
375 int ai_socktype;
376 int ai_protocol;
377 size_t ai_addrlen;
378 struct sockaddr *ai_addr;
379 char *ai_canonname;
380 struct addrinfo *ai_next;
383 void freeaddrinfo (struct addrinfo *res);
384 #endif
386 /* math.h */
388 #ifndef HAVE_NANF
389 #define nanf(tagp) NAN
390 #endif
392 #ifdef _WIN32
393 FILE *vlc_win32_tmpfile(void);
394 #endif
396 #ifdef __cplusplus
397 } /* extern "C" */
398 #endif
400 #endif /* !LIBVLC_FIXUPS_H */