Mozilla: More (final?) Win32 compile fixes for XulRunner 1.9.2
[vlc/asuraparaju-public.git] / include / vlc_fixups.h
blobc832197680ca0f879602a79360885294bdafdd27
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 *****************************************************************************/
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_STRLCPY) || \
52 !defined (HAVE_STRNDUP) || \
53 !defined (HAVE_STRNLEN) || \
54 !defined (HAVE_GETCWD)
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 #ifdef __cplusplus
69 extern "C" {
70 #endif
72 #ifndef HAVE_STRDUP
73 char *strdup (const char *);
74 #endif
76 #ifndef HAVE_VASPRINTF
77 int vasprintf (char **, const char *, va_list);
78 #endif
80 #ifndef HAVE_ASPRINTF
81 int asprintf (char **, const char *, ...);
82 #endif
84 #ifndef HAVE_STRNLEN
85 size_t strnlen (const char *, size_t);
86 #endif
88 #ifndef HAVE_STRNDUP
89 char *strndup (const char *, size_t);
90 #endif
92 #ifndef HAVE_STRLCPY
93 size_t strlcpy (char *, const char *, size_t);
94 #endif
96 #ifndef HAVE_STRTOF
97 float strtof (const char *, char **);
98 #endif
100 #ifndef HAVE_ATOF
101 double atof (const char *);
102 #endif
104 #ifndef HAVE_STRTOLL
105 long long int strtoll (const char *, char **, int);
106 #endif
108 #ifndef HAVE_STRSEP
109 char *strsep (char **, const char *);
110 #endif
112 #ifndef HAVE_ATOLL
113 long long atoll (const char *);
114 #endif
116 #ifndef HAVE_LLDIV
117 lldiv_t lldiv (long long, long long);
118 #endif
120 #ifndef HAVE_STRCASECMP
121 int strcasecmp (const char *, const char *);
122 #endif
124 #ifndef HAVE_STRNCASECMP
125 int strncasecmp (const char *, const char *, size_t);
126 #endif
128 #ifndef HAVE_STRCASESTR
129 char *strcasestr (const char *, const char *);
130 #endif
132 #ifndef HAVE_GMTIME_R
133 struct tm *gmtime_r (const time_t *, struct tm *);
134 #endif
136 #ifndef HAVE_LOCALTIME_R
137 struct tm *localtime_r (const time_t *, struct tm *);
138 #endif
140 #ifndef HAVE_REWIND
141 void rewind (FILE *);
142 #endif
144 #ifndef HAVE_GETCWD
145 char *getcwd (char *buf, size_t size);
146 #endif
148 #ifndef HAVE_GETDELIM
149 ssize_t getdelim (char **, size_t *, int, FILE *);
150 ssize_t getline (char **, size_t *, FILE *);
151 #endif
153 #ifndef HAVE_GETPID
154 pid_t getpid (void);
155 #endif
157 #ifndef HAVE_STRTOK_R
158 char *strtok_r(char *, const char *, char **);
159 #endif
161 #ifdef __cplusplus
162 } /* extern "C" */
163 #endif
165 #ifndef HAVE_GETENV
166 static inline char *getenv (const char *name)
168 (void)name;
169 return NULL;
171 #endif
173 /* Alignment of critical static data structures */
174 #ifdef ATTRIBUTE_ALIGNED_MAX
175 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
176 #else
177 # define ATTR_ALIGN(align)
178 #endif
180 #ifndef HAVE_USELOCALE
181 #define LC_NUMERIC_MASK 0
182 #define LC_MESSAGES_MASK 0
183 typedef void *locale_t;
184 static inline locale_t uselocale(locale_t loc)
186 (void)loc;
187 return NULL;
189 static inline void freelocale(locale_t loc)
191 (void)loc;
193 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
195 (void)mask; (void)locale; (void)base;
196 return NULL;
198 #endif
200 #ifdef WIN32
201 # include <dirent.h>
202 # define opendir Use_vlc_opendir_or_vlc_wopendir_instead!
203 # define readdir Use_vlc_readdir_or_vlc_wreaddir_instead!
204 # define closedir vlc_wclosedir
205 #endif
207 /* libintl support */
208 #define _(str) vlc_gettext (str)
209 #define N_(str) gettext_noop (str)
210 #define gettext_noop(str) (str)
212 #ifndef HAVE_SWAB
213 void swab (const void *, void *, ssize_t);
214 #endif
216 /* Socket stuff */
217 #ifndef HAVE_INET_PTON
218 # define inet_pton vlc_inet_pton
219 #endif
221 #ifndef HAVE_INET_NTOP
222 # define inet_ntop vlc_inet_ntop
223 #endif
225 #ifndef HAVE_POLL
226 enum
228 POLLIN=1,
229 POLLOUT=2,
230 POLLPRI=4,
231 POLLERR=8, // unsupported stub
232 POLLHUP=16, // unsupported stub
233 POLLNVAL=32 // unsupported stub
236 struct pollfd
238 int fd;
239 unsigned events;
240 unsigned revents;
243 # define poll(a, b, c) vlc_poll(a, b, c)
244 #endif
246 #ifndef HAVE_TDESTROY
247 # define tdestroy vlc_tdestroy
248 #endif
250 /* Random numbers */
251 #ifndef HAVE_NRAND48
252 double erand48 (unsigned short subi[3]);
253 long jrand48 (unsigned short subi[3]);
254 long nrand48 (unsigned short subi[3]);
255 #endif
257 #endif /* !LIBVLC_FIXUPS_H */