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 */
47 # include <stdio.h> /* FILE */
50 #if !defined (HAVE_STRLCPY) || \
51 !defined (HAVE_STRNDUP) || \
52 !defined (HAVE_STRNLEN) || \
53 !defined (HAVE_GETCWD)
54 # include <stddef.h> /* size_t */
57 #ifndef HAVE_VASPRINTF
58 # include <stdarg.h> /* va_list */
62 # include <sys/types.h> /* pid_t */
70 char *strdup (const char *);
73 #ifndef HAVE_VASPRINTF
74 int vasprintf (char **, const char *, va_list);
78 int asprintf (char **, const char *, ...);
82 size_t strnlen (const char *, size_t);
86 char *strndup (const char *, size_t);
90 size_t strlcpy (char *, const char *, size_t);
94 float strtof (const char *, char **);
98 double atof (const char *);
102 long long int strtoll (const char *, char **, int);
106 char *strsep (char **, const char *);
110 long long atoll (const char *);
114 lldiv_t lldiv (long long, long long);
117 #ifndef HAVE_STRCASECMP
118 int strcasecmp (const char *, const char *);
121 #ifndef HAVE_STRNCASECMP
122 int strncasecmp (const char *, const char *, size_t);
125 #ifndef HAVE_STRCASESTR
126 char *strcasestr (const char *, const char *);
129 #ifndef HAVE_GMTIME_R
130 struct tm *gmtime_r (const time_t *, struct tm *);
133 #ifndef HAVE_LOCALTIME_R
134 struct tm *localtime_r (const time_t *, struct tm *);
138 void rewind (FILE *);
142 char *getcwd (char *buf, size_t size);
149 #ifndef HAVE_STRTOK_R
150 char *strtok_r(char *, const char *, char **);
158 static inline char *getenv (const char *name)
165 /* Alignment of critical static data structures */
166 #ifdef ATTRIBUTE_ALIGNED_MAX
167 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
169 # define ATTR_ALIGN(align)
172 #ifndef HAVE_USELOCALE
173 #define LC_NUMERIC_MASK 0
174 #define LC_MESSAGES_MASK 0
175 typedef void *locale_t;
176 static inline locale_t uselocale(locale_t loc)
181 static inline void freelocale(locale_t loc)
185 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
187 (void)mask; (void)locale; (void)base;
194 # define opendir Use_vlc_opendir_or_vlc_wopendir_instead!
195 # define readdir Use_vlc_readdir_or_vlc_wreaddir_instead!
196 # define closedir vlc_wclosedir
199 /* libintl support */
200 #define _(str) vlc_gettext (str)
201 #define N_(str) gettext_noop (str)
202 #define gettext_noop(str) (str)
205 void swab (const void *, void *, ssize_t);
209 #ifndef HAVE_INET_PTON
210 # define inet_pton vlc_inet_pton
213 #ifndef HAVE_INET_NTOP
214 # define inet_ntop vlc_inet_ntop
223 POLLERR=8, // unsupported stub
224 POLLHUP=16, // unsupported stub
225 POLLNVAL=32 // unsupported stub
235 # define poll(a, b, c) vlc_poll(a, b, c)
238 #ifndef HAVE_TDESTROY
239 # define tdestroy vlc_tdestroy
242 #endif /* !LIBVLC_FIXUPS_H */