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 *****************************************************************************/
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
35 # ifndef __STDC_CONSTANT_MACROS
36 # define __STDC_CONSTANT_MACROS 1
38 # ifndef __STDC_LIMIT_MACROS
39 # define __STDC_LIMIT_MACROS 1
43 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R) \
44 || !defined (HAVE_TIMEGM)
45 # include <time.h> /* time_t */
51 long long quot
; /* Quotient. */
52 long long rem
; /* Remainder. */
56 #if !defined(HAVE_GETENV) || \
57 !defined(HAVE_USELOCALE)
58 # include <stddef.h> /* NULL */
61 #if !defined (HAVE_REWIND) || \
62 !defined (HAVE_GETDELIM)
63 # include <stdio.h> /* FILE */
66 #if !defined (HAVE_POSIX_MEMALIGN) || \
67 !defined (HAVE_STRLCPY) || \
68 !defined (HAVE_STRNDUP) || \
69 !defined (HAVE_STRNLEN)
70 # include <stddef.h> /* size_t */
73 #ifndef HAVE_VASPRINTF
74 # include <stdarg.h> /* va_list */
77 #if !defined (HAVE_GETDELIM) || \
78 !defined (HAVE_GETPID) || \
80 # include <sys/types.h> /* ssize_t, pid_t */
83 #if !defined (HAVE_DIRFD) || \
84 !defined (HAVE_FDOPENDIR)
89 # define VLC_NOTHROW throw ()
97 int asprintf (char **, const char *, ...);
100 #ifndef HAVE_FLOCKFILE
101 void flockfile (FILE *);
102 int ftrylockfile (FILE *);
103 void funlockfile (FILE *);
104 int getc_unlocked (FILE *);
105 int getchar_unlocked (void);
106 int putc_unlocked (int, FILE *);
107 int putchar_unlocked (int);
110 #ifndef HAVE_GETDELIM
111 ssize_t
getdelim (char **, size_t *, int, FILE *);
112 ssize_t
getline (char **, size_t *, FILE *);
116 void rewind (FILE *);
119 #ifndef HAVE_VASPRINTF
120 int vasprintf (char **, const char *, va_list);
125 int ffsll(unsigned long long);
128 #ifndef HAVE_STRCASECMP
129 int strcasecmp (const char *, const char *);
132 #ifndef HAVE_STRCASESTR
133 char *strcasestr (const char *, const char *);
137 char *strdup (const char *);
140 #ifndef HAVE_STRVERSCMP
141 int strverscmp (const char *, const char *);
145 size_t strnlen (const char *, size_t);
149 char * strnstr (const char *, const char *, size_t);
153 char *strndup (const char *, size_t);
157 size_t strlcpy (char *, const char *, size_t);
161 char *strsep (char **, const char *);
164 #ifndef HAVE_STRTOK_R
165 char *strtok_r(char *, const char *, char **);
171 double atof (const char *);
176 long long atoll (const char *);
180 lldiv_t
lldiv (long long, long long);
185 float strtof (const char *, char **);
190 long long int strtoll (const char *, char **, int);
194 #ifndef HAVE_GMTIME_R
195 struct tm
*gmtime_r (const time_t *, struct tm
*);
198 #ifndef HAVE_LOCALTIME_R
199 struct tm
*localtime_r (const time_t *, struct tm
*);
203 time_t timegm(struct tm
*);
206 #ifndef HAVE_TIMESPEC_GET
209 int timespec_get(struct timespec
*, int);
214 pid_t
getpid (void) VLC_NOTHROW
;
226 #ifndef HAVE_FDOPENDIR
227 DIR *fdopendir (int);
236 static inline char *getenv (const char *name
)
244 int setenv (const char *, const char *, int);
245 int unsetenv (const char *);
248 #ifndef HAVE_POSIX_MEMALIGN
249 int posix_memalign (void **, size_t, size_t);
253 #ifndef HAVE_USELOCALE
254 #define LC_ALL_MASK 0
255 #define LC_NUMERIC_MASK 0
256 #define LC_MESSAGES_MASK 0
257 #define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
258 typedef void *locale_t
;
259 static inline locale_t
uselocale(locale_t loc
)
264 static inline void freelocale(locale_t loc
)
268 static inline locale_t
newlocale(int mask
, const char * locale
, locale_t base
)
270 (void)mask
; (void)locale
; (void)base
;
275 #if !defined (HAVE_STATIC_ASSERT) && !defined(__cpp_static_assert)
276 # define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
277 # define static_assert _Static_assert
280 /* Alignment of critical static data structures */
281 #ifdef ATTRIBUTE_ALIGNED_MAX
282 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
284 # define ATTR_ALIGN(align)
287 /* libintl support */
288 #define _(str) vlc_gettext (str)
289 #define N_(str) gettext_noop (str)
290 #define gettext_noop(str) (str)
297 void swab (const void *, void *, ssize_t
);
301 #ifndef HAVE_INET_PTON
302 int inet_pton(int, const char *, void *);
303 const char *inet_ntop(int, const void *, char *, int);
306 #ifndef HAVE_STRUCT_POLLFD
318 #define POLLIN (POLLRDNORM|POLLRDBAND)
319 #define POLLOUT (POLLWRNORM|POLLWRBAND)
330 int poll (struct pollfd
*, unsigned, int);
333 #ifndef HAVE_IF_NAMEINDEX
340 # ifndef HAVE_IF_NAMETOINDEX
341 # define if_nametoindex(name) atoi(name)
343 # define if_nameindex() (errno = ENOBUFS, NULL)
344 # define if_freenameindex(list) (void)0
348 #ifndef HAVE_SEARCH_H
349 typedef struct entry
{
365 void *tsearch( const void *key
, void **rootp
, int(*cmp
)(const void *, const void *) );
366 void *tfind( const void *key
, const void **rootp
, int(*cmp
)(const void *, const void *) );
367 void *tdelete( const void *key
, void **rootp
, int(*cmp
)(const void *, const void *) );
368 void twalk( const void *root
, void(*action
)(const void *nodep
, VISIT which
, int depth
) );
369 void tdestroy( void *root
, void (*free_node
)(void *nodep
) );
370 #else // HAVE_SEARCH_H
371 # ifndef HAVE_TDESTROY
372 # define tdestroy vlc_tdestroy
378 double erand48 (unsigned short subi
[3]);
379 long jrand48 (unsigned short subi
[3]);
380 long nrand48 (unsigned short subi
[3]);
384 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
393 struct sockaddr
*ai_addr
;
395 struct addrinfo
*ai_next
;
398 void freeaddrinfo (struct addrinfo
*res
);
404 #define nanf(tagp) NAN
408 FILE *vlc_win32_tmpfile(void);
415 #endif /* !LIBVLC_FIXUPS_H */