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 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R)
30 # include <time.h> /* time_t */
36 long long quot; /* Quotient. */
37 long long rem; /* Remainder. */
41 #if !defined(HAVE_GETENV) || \
42 !defined(HAVE_USELOCALE)
43 # include <stddef.h> /* NULL */
46 #if !defined (HAVE_REWIND) || \
47 !defined (HAVE_GETDELIM)
48 # include <stdio.h> /* FILE */
51 #if !defined (HAVE_POSIX_MEMALIGN) || \
52 !defined (HAVE_STRLCPY) || \
53 !defined (HAVE_STRNDUP) || \
54 !defined (HAVE_STRNLEN)
55 # include <stddef.h> /* size_t */
58 #ifndef HAVE_VASPRINTF
59 # include <stdarg.h> /* va_list */
62 #if !defined (HAVE_GETDELIM) || \
63 !defined (HAVE_GETPID) || \
65 # include <sys/types.h> /* ssize_t, pid_t */
68 #if !defined (HAVE_DIRFD) || \
69 !defined (HAVE_FDOPENDIR)
79 int asprintf (char **, const char *, ...);
82 #ifndef HAVE_FLOCKFILE
83 void flockfile (FILE *);
84 int ftrylockfile (FILE *);
85 void funlockfile (FILE *);
86 int getc_unlocked (FILE *);
87 int getchar_unlocked (void);
88 int putc_unlocked (int, FILE *);
89 int putchar_unlocked (int);
93 ssize_t getdelim (char **, size_t *, int, FILE *);
94 ssize_t getline (char **, size_t *, FILE *);
101 #ifndef HAVE_VASPRINTF
102 int vasprintf (char **, const char *, va_list);
106 #ifndef HAVE_STRCASECMP
107 int strcasecmp (const char *, const char *);
110 #ifndef HAVE_STRCASESTR
111 char *strcasestr (const char *, const char *);
115 char *strdup (const char *);
118 #ifndef HAVE_STRNCASECMP
119 int strncasecmp (const char *, const char *, size_t);
122 #ifndef HAVE_STRVERSCMP
123 int strverscmp (const char *, const char *);
127 size_t strnlen (const char *, size_t);
131 char *strndup (const char *, size_t);
135 size_t strlcpy (char *, const char *, size_t);
139 char *strsep (char **, const char *);
142 #ifndef HAVE_STRTOK_R
143 char *strtok_r(char *, const char *, char **);
149 double atof (const char *);
154 long long atoll (const char *);
158 lldiv_t lldiv (long long, long long);
163 float strtof (const char *, char **);
168 long long int strtoll (const char *, char **, int);
172 #ifndef HAVE_GMTIME_R
173 struct tm *gmtime_r (const time_t *, struct tm *);
176 #ifndef HAVE_LOCALTIME_R
177 struct tm *localtime_r (const time_t *, struct tm *);
194 #ifndef HAVE_FDOPENDIR
195 DIR *fdopendir (int);
204 static inline char *getenv (const char *name)
212 int setenv (const char *, const char *, int);
213 int unsetenv (const char *);
216 #ifndef HAVE_POSIX_MEMALIGN
217 int posix_memalign (void **, size_t, size_t);
221 #ifndef HAVE_USELOCALE
222 #define LC_NUMERIC_MASK 0
223 #define LC_MESSAGES_MASK 0
224 typedef void *locale_t;
225 static inline locale_t uselocale(locale_t loc)
230 static inline void freelocale(locale_t loc)
234 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
236 (void)mask; (void)locale; (void)base;
241 #if !defined (HAVE_STATIC_ASSERT)
242 # define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
243 # define static_assert _Static_assert
246 /* Alignment of critical static data structures */
247 #ifdef ATTRIBUTE_ALIGNED_MAX
248 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
250 # define ATTR_ALIGN(align)
253 /* libintl support */
254 #define _(str) vlc_gettext (str)
255 #define N_(str) gettext_noop (str)
256 #define gettext_noop(str) (str)
259 void swab (const void *, void *, ssize_t);
263 #ifndef HAVE_INET_PTON
264 int inet_pton(int, const char *, void *);
265 const char *inet_ntop(int, const void *, char *, int);
268 #ifndef HAVE_STRUCT_POLLFD
274 POLLERR=8, // unsupported stub
275 POLLHUP=16, // unsupported stub
276 POLLNVAL=32 // unsupported stub
288 int poll (struct pollfd *, unsigned, int);
291 #ifndef HAVE_IF_NAMEINDEX
298 # ifndef HAVE_IF_NAMETOINDEX
299 # define if_nametoindex(name) atoi(name)
301 # define if_nameindex() (errno = ENOBUFS, NULL)
302 # define if_freenameindex(list) (void)0
306 #ifndef HAVE_SEARCH_H
307 typedef struct entry {
323 void *tsearch( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
324 void *tfind( const void *key, const void **rootp, int(*cmp)(const void *, const void *) );
325 void *tdelete( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
326 void twalk( const void *root, void(*action)(const void *nodep, VISIT which, int depth) );
327 void tdestroy( void *root, void (*free_node)(void *nodep) );
328 #else // HAVE_SEARCH_H
329 # ifndef HAVE_TDESTROY
330 # define tdestroy vlc_tdestroy
336 double erand48 (unsigned short subi[3]);
337 long jrand48 (unsigned short subi[3]);
338 long nrand48 (unsigned short subi[3]);
342 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
345 #endif /* !LIBVLC_FIXUPS_H */