skins2: os2: save and restore FPU cw
[vlc.git] / include / vlc_fixups.h
bloba4b9b2d250c7dbae0ed80ac636238b5df7136e65
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 *****************************************************************************/
21 /**
22 * \file
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 */
31 #endif
33 #ifndef HAVE_LLDIV
34 typedef struct
36 long long quot; /* Quotient. */
37 long long rem; /* Remainder. */
38 } lldiv_t;
39 #endif
41 #if !defined(HAVE_GETENV) || \
42 !defined(HAVE_USELOCALE)
43 # include <stddef.h> /* NULL */
44 #endif
46 #if !defined (HAVE_REWIND) || \
47 !defined (HAVE_GETDELIM)
48 # include <stdio.h> /* FILE */
49 #endif
51 #if !defined (HAVE_POSIX_MEMALIGN) || \
52 !defined (HAVE_STRLCPY) || \
53 !defined (HAVE_STRNDUP) || \
54 !defined (HAVE_STRNLEN)
55 # include <stddef.h> /* size_t */
56 #endif
58 #ifndef HAVE_VASPRINTF
59 # include <stdarg.h> /* va_list */
60 #endif
62 #if !defined (HAVE_GETDELIM) || \
63 !defined (HAVE_GETPID) || \
64 !defined (HAVE_SWAB)
65 # include <sys/types.h> /* ssize_t, pid_t */
66 #endif
68 #if !defined (HAVE_DIRFD) || \
69 !defined (HAVE_FDOPENDIR)
70 # include <dirent.h>
71 #endif
73 #ifdef __cplusplus
74 # define VLC_NOTHROW throw ()
75 extern "C" {
76 #else
77 # define VLC_NOTHROW
78 #endif
80 /* stdio.h */
81 #ifndef HAVE_ASPRINTF
82 int asprintf (char **, const char *, ...);
83 #endif
85 #ifndef HAVE_FLOCKFILE
86 void flockfile (FILE *);
87 int ftrylockfile (FILE *);
88 void funlockfile (FILE *);
89 int getc_unlocked (FILE *);
90 int getchar_unlocked (void);
91 int putc_unlocked (int, FILE *);
92 int putchar_unlocked (int);
93 #endif
95 #ifndef HAVE_GETDELIM
96 ssize_t getdelim (char **, size_t *, int, FILE *);
97 ssize_t getline (char **, size_t *, FILE *);
98 #endif
100 #ifndef HAVE_REWIND
101 void rewind (FILE *);
102 #endif
104 #ifndef HAVE_VASPRINTF
105 int vasprintf (char **, const char *, va_list);
106 #endif
108 /* string.h */
109 #ifndef HAVE_STRCASECMP
110 int strcasecmp (const char *, const char *);
111 #endif
113 #ifndef HAVE_STRCASESTR
114 char *strcasestr (const char *, const char *);
115 #endif
117 #ifndef HAVE_STRDUP
118 char *strdup (const char *);
119 #endif
121 #ifndef HAVE_STRVERSCMP
122 int strverscmp (const char *, const char *);
123 #endif
125 #ifndef HAVE_STRNLEN
126 size_t strnlen (const char *, size_t);
127 #endif
129 #ifndef HAVE_STRNDUP
130 char *strndup (const char *, size_t);
131 #endif
133 #ifndef HAVE_STRLCPY
134 size_t strlcpy (char *, const char *, size_t);
135 #endif
137 #ifndef HAVE_STRSEP
138 char *strsep (char **, const char *);
139 #endif
141 #ifndef HAVE_STRTOK_R
142 char *strtok_r(char *, const char *, char **);
143 #endif
145 /* stdlib.h */
146 #ifndef HAVE_ATOF
147 #ifndef __ANDROID__
148 double atof (const char *);
149 #endif
150 #endif
152 #ifndef HAVE_ATOLL
153 long long atoll (const char *);
154 #endif
156 #ifndef HAVE_LLDIV
157 lldiv_t lldiv (long long, long long);
158 #endif
160 #ifndef HAVE_STRTOF
161 #ifndef __ANDROID__
162 float strtof (const char *, char **);
163 #endif
164 #endif
166 #ifndef HAVE_STRTOLL
167 long long int strtoll (const char *, char **, int);
168 #endif
170 /* time.h */
171 #ifndef HAVE_GMTIME_R
172 struct tm *gmtime_r (const time_t *, struct tm *);
173 #endif
175 #ifndef HAVE_LOCALTIME_R
176 struct tm *localtime_r (const time_t *, struct tm *);
177 #endif
179 /* unistd.h */
180 #ifndef HAVE_GETPID
181 pid_t getpid (void) VLC_NOTHROW;
182 #endif
184 #ifndef HAVE_FSYNC
185 int fsync (int fd);
186 #endif
188 /* dirent.h */
189 #ifndef HAVE_DIRFD
190 int (dirfd) (DIR *);
191 #endif
193 #ifndef HAVE_FDOPENDIR
194 DIR *fdopendir (int);
195 #endif
197 #ifdef __cplusplus
198 } /* extern "C" */
199 #endif
201 /* stdlib.h */
202 #ifndef HAVE_GETENV
203 static inline char *getenv (const char *name)
205 (void)name;
206 return NULL;
208 #endif
210 #ifndef HAVE_SETENV
211 int setenv (const char *, const char *, int);
212 int unsetenv (const char *);
213 #endif
215 #ifndef HAVE_POSIX_MEMALIGN
216 int posix_memalign (void **, size_t, size_t);
217 #endif
219 /* locale.h */
220 #ifndef HAVE_USELOCALE
221 #define LC_ALL_MASK 0
222 #define LC_NUMERIC_MASK 0
223 #define LC_MESSAGES_MASK 0
224 #define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
225 typedef void *locale_t;
226 static inline locale_t uselocale(locale_t loc)
228 (void)loc;
229 return NULL;
231 static inline void freelocale(locale_t loc)
233 (void)loc;
235 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
237 (void)mask; (void)locale; (void)base;
238 return NULL;
240 #endif
242 #if !defined (HAVE_STATIC_ASSERT)
243 # define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
244 # define static_assert _Static_assert
245 #endif
247 /* Alignment of critical static data structures */
248 #ifdef ATTRIBUTE_ALIGNED_MAX
249 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
250 #else
251 # define ATTR_ALIGN(align)
252 #endif
254 /* libintl support */
255 #define _(str) vlc_gettext (str)
256 #define N_(str) gettext_noop (str)
257 #define gettext_noop(str) (str)
259 #ifdef __cplusplus
260 extern "C" {
261 #endif
263 #ifndef HAVE_SWAB
264 void swab (const void *, void *, ssize_t);
265 #endif
267 /* Socket stuff */
268 #ifndef HAVE_INET_PTON
269 int inet_pton(int, const char *, void *);
270 const char *inet_ntop(int, const void *, char *, int);
271 #endif
273 #ifndef HAVE_STRUCT_POLLFD
274 enum
276 POLLIN=1,
277 POLLOUT=2,
278 POLLPRI=4,
279 POLLERR=8, // unsupported stub
280 POLLHUP=16, // unsupported stub
281 POLLNVAL=32 // unsupported stub
284 struct pollfd
286 int fd;
287 unsigned events;
288 unsigned revents;
290 #endif
291 #ifndef HAVE_POLL
292 struct pollfd;
293 int poll (struct pollfd *, unsigned, int);
294 #endif
296 #ifndef HAVE_IF_NAMEINDEX
297 #include <errno.h>
298 struct if_nameindex
300 unsigned if_index;
301 char *if_name;
303 # ifndef HAVE_IF_NAMETOINDEX
304 # define if_nametoindex(name) atoi(name)
305 # endif
306 # define if_nameindex() (errno = ENOBUFS, NULL)
307 # define if_freenameindex(list) (void)0
308 #endif
310 /* search.h */
311 #ifndef HAVE_SEARCH_H
312 typedef struct entry {
313 char *key;
314 void *data;
315 } ENTRY;
317 typedef enum {
318 FIND, ENTER
319 } ACTION;
321 typedef enum {
322 preorder,
323 postorder,
324 endorder,
325 leaf
326 } VISIT;
328 void *tsearch( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
329 void *tfind( const void *key, const void **rootp, int(*cmp)(const void *, const void *) );
330 void *tdelete( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
331 void twalk( const void *root, void(*action)(const void *nodep, VISIT which, int depth) );
332 void tdestroy( void *root, void (*free_node)(void *nodep) );
333 #else // HAVE_SEARCH_H
334 # ifndef HAVE_TDESTROY
335 # define tdestroy vlc_tdestroy
336 # endif
337 #endif
339 /* Random numbers */
340 #ifndef HAVE_NRAND48
341 double erand48 (unsigned short subi[3]);
342 long jrand48 (unsigned short subi[3]);
343 long nrand48 (unsigned short subi[3]);
344 #endif
346 #ifdef __cplusplus
347 } /* extern "C" */
348 #endif
350 #ifdef __OS2__
351 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
352 #endif
354 /* math.h */
356 #ifdef __ANDROID__
357 #define nanf(tagp) NAN
358 #endif
360 #endif /* !LIBVLC_FIXUPS_H */