1 /*****************************************************************************
2 * 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
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 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 General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, 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_STRLCPY) || \
52 !defined (HAVE_STRNDUP) || \
53 !defined (HAVE_STRNLEN)
54 # include <stddef.h> /* size_t */
57 #ifndef HAVE_VASPRINTF
58 # include <stdarg.h> /* va_list */
61 #if !defined (HAVE_GETDELIM) || \
62 !defined (HAVE_GETPID) || \
64 # include <sys/types.h> /* ssize_t, pid_t */
67 #if !defined (HAVE_DIRFD) || \
68 !defined (HAVE_FDOPENDIR)
78 int asprintf (char **, const char *, ...);
81 #ifndef HAVE_FLOCKFILE
82 void flockfile (FILE *);
83 int ftrylockfile (FILE *);
84 void funlockfile (FILE *);
85 int getc_unlocked (FILE *);
86 int getchar_unlocked (void);
87 int putc_unlocked (int, FILE *);
88 int putchar_unlocked (int);
92 ssize_t
getdelim (char **, size_t *, int, FILE *);
93 ssize_t
getline (char **, size_t *, FILE *);
100 #ifndef HAVE_VASPRINTF
101 int vasprintf (char **, const char *, va_list);
105 #ifndef HAVE_STRCASECMP
106 int strcasecmp (const char *, const char *);
109 #ifndef HAVE_STRCASESTR
110 char *strcasestr (const char *, const char *);
114 char *strdup (const char *);
117 #ifndef HAVE_STRNCASECMP
118 int strncasecmp (const char *, const char *, size_t);
122 size_t strnlen (const char *, size_t);
126 char *strndup (const char *, size_t);
130 size_t strlcpy (char *, const char *, size_t);
134 char *strsep (char **, const char *);
137 #ifndef HAVE_STRTOK_R
138 char *strtok_r(char *, const char *, char **);
144 double atof (const char *);
149 long long atoll (const char *);
153 lldiv_t
lldiv (long long, long long);
158 float strtof (const char *, char **);
163 long long int strtoll (const char *, char **, int);
167 #ifndef HAVE_GMTIME_R
168 struct tm
*gmtime_r (const time_t *, struct tm
*);
171 #ifndef HAVE_LOCALTIME_R
172 struct tm
*localtime_r (const time_t *, struct tm
*);
186 #if defined(__APPLE__) || defined(__OS2__)
192 #ifndef HAVE_FDOPENDIR
193 DIR *fdopendir (int);
202 static inline char *getenv (const char *name
)
210 int setenv (const char *, const char *, int);
211 int unsetenv (const char *);
215 #ifndef HAVE_USELOCALE
216 #define LC_NUMERIC_MASK 0
217 #define LC_MESSAGES_MASK 0
218 typedef void *locale_t
;
219 static inline locale_t
uselocale(locale_t loc
)
224 static inline void freelocale(locale_t loc
)
228 static inline locale_t
newlocale(int mask
, const char * locale
, locale_t base
)
230 (void)mask
; (void)locale
; (void)base
;
235 /* Alignment of critical static data structures */
236 #ifdef ATTRIBUTE_ALIGNED_MAX
237 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
239 # define ATTR_ALIGN(align)
242 /* libintl support */
243 #define _(str) vlc_gettext (str)
244 #define N_(str) gettext_noop (str)
245 #define gettext_noop(str) (str)
248 void swab (const void *, void *, ssize_t
);
252 #ifndef HAVE_INET_PTON
253 # define inet_pton vlc_inet_pton
256 #ifndef HAVE_INET_NTOP
257 # define inet_ntop vlc_inet_ntop
260 #ifndef HAVE_STRUCT_POLLFD
266 POLLERR
=8, // unsupported stub
267 POLLHUP
=16, // unsupported stub
268 POLLNVAL
=32 // unsupported stub
279 # define poll(a, b, c) vlc_poll(a, b, c)
280 #elif defined (HAVE_MAEMO)
282 # define poll(a, b, c) vlc_poll(a, b, c)
283 int vlc_poll (struct pollfd
*, unsigned, int);
286 #ifndef HAVE_IF_NAMEINDEX
293 # ifndef HAVE_IF_NAMETOINDEX
294 # define if_nametoindex(name) atoi(name)
296 # define if_nameindex() (errno = ENOBUFS, NULL)
297 # define if_freenameindex(list) (void)0
301 #ifndef HAVE_SEARCH_H
302 typedef struct entry
{
318 void *tsearch( const void *key
, void **rootp
, int(*cmp
)(const void *, const void *) );
319 void *tfind( const void *key
, const void **rootp
, int(*cmp
)(const void *, const void *) );
320 void *tdelete( const void *key
, void **rootp
, int(*cmp
)(const void *, const void *) );
321 void twalk( const void *root
, void(*action
)(const void *nodep
, VISIT which
, int depth
) );
322 void tdestroy( void *root
, void (*free_node
)(void *nodep
) );
323 #else // HAVE_SEARCH_H
324 # ifndef HAVE_TDESTROY
325 # define tdestroy vlc_tdestroy
331 double erand48 (unsigned short subi
[3]);
332 long jrand48 (unsigned short subi
[3]);
333 long nrand48 (unsigned short subi
[3]);
339 # define __cplusplus 0
341 # include <pthread.h>
342 # if __cplusplus == 0
345 char *tempnam(const char *, const char *);
349 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
352 #endif /* !LIBVLC_FIXUPS_H */