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 # include <time.h> /* time_t */
50 long long quot
; /* Quotient. */
51 long long rem
; /* Remainder. */
55 #if !defined(HAVE_GETENV) || \
56 !defined(HAVE_USELOCALE)
57 # include <stddef.h> /* NULL */
60 #if !defined (HAVE_REWIND) || \
61 !defined (HAVE_GETDELIM)
62 # include <stdio.h> /* FILE */
65 #if !defined (HAVE_POSIX_MEMALIGN) || \
66 !defined (HAVE_STRLCPY) || \
67 !defined (HAVE_STRNDUP) || \
68 !defined (HAVE_STRNLEN)
69 # include <stddef.h> /* size_t */
72 #ifndef HAVE_VASPRINTF
73 # include <stdarg.h> /* va_list */
76 #if !defined (HAVE_GETDELIM) || \
77 !defined (HAVE_GETPID) || \
79 # include <sys/types.h> /* ssize_t, pid_t */
82 #if !defined (HAVE_DIRFD) || \
83 !defined (HAVE_FDOPENDIR)
88 # define VLC_NOTHROW throw ()
96 int asprintf (char **, const char *, ...);
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);
109 #ifndef HAVE_GETDELIM
110 ssize_t
getdelim (char **, size_t *, int, FILE *);
111 ssize_t
getline (char **, size_t *, FILE *);
115 void rewind (FILE *);
118 #ifndef HAVE_VASPRINTF
119 int vasprintf (char **, const char *, va_list);
124 int ffsll(unsigned long long);
127 #ifndef HAVE_STRCASECMP
128 int strcasecmp (const char *, const char *);
131 #ifndef HAVE_STRCASESTR
132 char *strcasestr (const char *, const char *);
136 char *strdup (const char *);
139 #ifndef HAVE_STRVERSCMP
140 int strverscmp (const char *, const char *);
144 size_t strnlen (const char *, size_t);
148 char *strndup (const char *, size_t);
152 size_t strlcpy (char *, const char *, size_t);
156 char *strsep (char **, const char *);
159 #ifndef HAVE_STRTOK_R
160 char *strtok_r(char *, const char *, char **);
166 double atof (const char *);
171 long long atoll (const char *);
175 lldiv_t
lldiv (long long, long long);
180 float strtof (const char *, char **);
185 long long int strtoll (const char *, char **, int);
189 #ifndef HAVE_GMTIME_R
190 struct tm
*gmtime_r (const time_t *, struct tm
*);
193 #ifndef HAVE_LOCALTIME_R
194 struct tm
*localtime_r (const time_t *, struct tm
*);
199 pid_t
getpid (void) VLC_NOTHROW
;
211 #ifndef HAVE_FDOPENDIR
212 DIR *fdopendir (int);
221 static inline char *getenv (const char *name
)
229 int setenv (const char *, const char *, int);
230 int unsetenv (const char *);
233 #ifndef HAVE_POSIX_MEMALIGN
234 int posix_memalign (void **, size_t, size_t);
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
)
249 static inline void freelocale(locale_t loc
)
253 static inline locale_t
newlocale(int mask
, const char * locale
, locale_t base
)
255 (void)mask
; (void)locale
; (void)base
;
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
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)))
269 # define ATTR_ALIGN(align)
272 /* libintl support */
273 #define _(str) vlc_gettext (str)
274 #define N_(str) gettext_noop (str)
275 #define gettext_noop(str) (str)
282 void swab (const void *, void *, ssize_t
);
286 #ifndef HAVE_INET_PTON
287 int inet_pton(int, const char *, void *);
288 const char *inet_ntop(int, const void *, char *, int);
291 #ifndef HAVE_STRUCT_POLLFD
303 #define POLLIN (POLLRDNORM|POLLRDBAND)
304 #define POLLOUT (POLLWRNORM|POLLWRBAND)
315 int poll (struct pollfd
*, unsigned, int);
318 #ifndef HAVE_IF_NAMEINDEX
325 # ifndef HAVE_IF_NAMETOINDEX
326 # define if_nametoindex(name) atoi(name)
328 # define if_nameindex() (errno = ENOBUFS, NULL)
329 # define if_freenameindex(list) (void)0
333 #ifndef HAVE_SEARCH_H
334 typedef struct entry
{
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
363 double erand48 (unsigned short subi
[3]);
364 long jrand48 (unsigned short subi
[3]);
365 long nrand48 (unsigned short subi
[3]);
369 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
378 struct sockaddr
*ai_addr
;
380 struct addrinfo
*ai_next
;
383 void freeaddrinfo (struct addrinfo
*res
);
389 #define nanf(tagp) NAN
393 FILE *vlc_win32_tmpfile(void);
400 #endif /* !LIBVLC_FIXUPS_H */