vlc_fixups.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_fixups.h: portability fixups included from config.h
00003  *****************************************************************************
00004  * Copyright © 1998-2008 the VideoLAN project
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2.1 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00019  *****************************************************************************/
00020 
00021 /**
00022  * \file
00023  * This file is a collection of portability fixes
00024  */
00025 
00026 #ifndef LIBVLC_FIXUPS_H
00027 # define LIBVLC_FIXUPS_H 1
00028 
00029 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R)
00030 # include <time.h> /* time_t */
00031 #endif
00032 
00033 #ifndef HAVE_LLDIV
00034 typedef struct
00035 {
00036     long long quot; /* Quotient. */
00037     long long rem;  /* Remainder. */
00038 } lldiv_t;
00039 #endif
00040 
00041 #if !defined(HAVE_GETENV) || \
00042     !defined(HAVE_USELOCALE)
00043 # include <stddef.h> /* NULL */
00044 #endif
00045 
00046 #if !defined (HAVE_REWIND) || \
00047     !defined (HAVE_GETDELIM)
00048 # include <stdio.h> /* FILE */
00049 #endif
00050 
00051 #if !defined (HAVE_POSIX_MEMALIGN) || \
00052     !defined (HAVE_STRLCPY) || \
00053     !defined (HAVE_STRNDUP) || \
00054     !defined (HAVE_STRNLEN)
00055 # include <stddef.h> /* size_t */
00056 #endif
00057 
00058 #ifndef HAVE_VASPRINTF
00059 # include <stdarg.h> /* va_list */
00060 #endif
00061 
00062 #if !defined (HAVE_GETDELIM) || \
00063     !defined (HAVE_GETPID)   || \
00064     !defined (HAVE_SWAB)
00065 # include <sys/types.h> /* ssize_t, pid_t */
00066 #endif
00067 
00068 #if !defined (HAVE_DIRFD) || \
00069     !defined (HAVE_FDOPENDIR)
00070 # include <dirent.h>
00071 #endif
00072 
00073 #ifdef __cplusplus
00074 extern "C" {
00075 #endif
00076 
00077 /* stdio.h */
00078 #ifndef HAVE_ASPRINTF
00079 int asprintf (char **, const char *, ...);
00080 #endif
00081 
00082 #ifndef HAVE_FLOCKFILE
00083 void flockfile (FILE *);
00084 int ftrylockfile (FILE *);
00085 void funlockfile (FILE *);
00086 int getc_unlocked (FILE *);
00087 int getchar_unlocked (void);
00088 int putc_unlocked (int, FILE *);
00089 int putchar_unlocked (int);
00090 #endif
00091 
00092 #ifndef HAVE_GETDELIM
00093 ssize_t getdelim (char **, size_t *, int, FILE *);
00094 ssize_t getline (char **, size_t *, FILE *);
00095 #endif
00096 
00097 #ifndef HAVE_REWIND
00098 void rewind (FILE *);
00099 #endif
00100 
00101 #ifndef HAVE_VASPRINTF
00102 int vasprintf (char **, const char *, va_list);
00103 #endif
00104 
00105 /* string.h */
00106 #ifndef HAVE_STRCASECMP
00107 int strcasecmp (const char *, const char *);
00108 #endif
00109 
00110 #ifndef HAVE_STRCASESTR
00111 char *strcasestr (const char *, const char *);
00112 #endif
00113 
00114 #ifndef HAVE_STRDUP
00115 char *strdup (const char *);
00116 #endif
00117 
00118 #ifndef HAVE_STRNCASECMP
00119 int strncasecmp (const char *, const char *, size_t);
00120 #endif
00121 
00122 #ifndef HAVE_STRVERSCMP
00123 int strverscmp (const char *, const char *);
00124 #endif
00125 
00126 #ifndef HAVE_STRNLEN
00127 size_t strnlen (const char *, size_t);
00128 #endif
00129 
00130 #ifndef HAVE_STRNDUP
00131 char *strndup (const char *, size_t);
00132 #endif
00133 
00134 #ifndef HAVE_STRLCPY
00135 size_t strlcpy (char *, const char *, size_t);
00136 #endif
00137 
00138 #ifndef HAVE_STRSEP
00139 char *strsep (char **, const char *);
00140 #endif
00141 
00142 #ifndef HAVE_STRTOK_R
00143 char *strtok_r(char *, const char *, char **);
00144 #endif
00145 
00146 /* stdlib.h */
00147 #ifndef HAVE_ATOF
00148 #ifndef __ANDROID__
00149 double atof (const char *);
00150 #endif
00151 #endif
00152 
00153 #ifndef HAVE_ATOLL
00154 long long atoll (const char *);
00155 #endif
00156 
00157 #ifndef HAVE_LLDIV
00158 lldiv_t lldiv (long long, long long);
00159 #endif
00160 
00161 #ifndef HAVE_STRTOF
00162 #ifndef __ANDROID__
00163 float strtof (const char *, char **);
00164 #endif
00165 #endif
00166 
00167 #ifndef HAVE_STRTOLL
00168 long long int strtoll (const char *, char **, int);
00169 #endif
00170 
00171 /* time.h */
00172 #ifndef HAVE_GMTIME_R
00173 struct tm *gmtime_r (const time_t *, struct tm *);
00174 #endif
00175 
00176 #ifndef HAVE_LOCALTIME_R
00177 struct tm *localtime_r (const time_t *, struct tm *);
00178 #endif
00179 
00180 /* unistd.h */
00181 #ifndef HAVE_GETPID
00182 pid_t getpid (void);
00183 #endif
00184 
00185 #ifndef HAVE_FSYNC
00186 int fsync (int fd);
00187 #endif
00188 
00189 /* dirent.h */
00190 #ifndef HAVE_DIRFD
00191 int (dirfd) (DIR *);
00192 #endif
00193 
00194 #ifndef HAVE_FDOPENDIR
00195 DIR *fdopendir (int);
00196 #endif
00197 
00198 #ifdef __cplusplus
00199 } /* extern "C" */
00200 #endif
00201 
00202 /* stdlib.h */
00203 #ifndef HAVE_GETENV
00204 static inline char *getenv (const char *name)
00205 {
00206     (void)name;
00207     return NULL;
00208 }
00209 #endif
00210 
00211 #ifndef HAVE_SETENV
00212 int setenv (const char *, const char *, int);
00213 int unsetenv (const char *);
00214 #endif
00215 
00216 #ifndef HAVE_POSIX_MEMALIGN
00217 int posix_memalign (void **, size_t, size_t);
00218 #endif
00219 
00220 /* locale.h */
00221 #ifndef HAVE_USELOCALE
00222 #define LC_NUMERIC_MASK  0
00223 #define LC_MESSAGES_MASK 0
00224 typedef void *locale_t;
00225 static inline locale_t uselocale(locale_t loc)
00226 {
00227     (void)loc;
00228     return NULL;
00229 }
00230 static inline void freelocale(locale_t loc)
00231 {
00232     (void)loc;
00233 }
00234 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
00235 {
00236     (void)mask; (void)locale; (void)base;
00237     return NULL;
00238 }
00239 #endif
00240 
00241 #if !defined (HAVE_STATIC_ASSERT)
00242 # define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
00243 # define static_assert _Static_assert
00244 #endif
00245 
00246 /* Alignment of critical static data structures */
00247 #ifdef ATTRIBUTE_ALIGNED_MAX
00248 #   define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
00249 #else
00250 #   define ATTR_ALIGN(align)
00251 #endif
00252 
00253 /* libintl support */
00254 #define _(str)            vlc_gettext (str)
00255 #define N_(str)           gettext_noop (str)
00256 #define gettext_noop(str) (str)
00257 
00258 #ifndef HAVE_SWAB
00259 void swab (const void *, void *, ssize_t);
00260 #endif
00261 
00262 /* Socket stuff */
00263 #ifndef HAVE_INET_PTON
00264 int inet_pton(int, const char *, void *);
00265 const char *inet_ntop(int, const void *, char *, int);
00266 #endif
00267 
00268 #ifndef HAVE_STRUCT_POLLFD
00269 enum
00270 {
00271     POLLIN=1,
00272     POLLOUT=2,
00273     POLLPRI=4,
00274     POLLERR=8,  // unsupported stub
00275     POLLHUP=16, // unsupported stub
00276     POLLNVAL=32 // unsupported stub
00277 };
00278 
00279 struct pollfd
00280 {
00281     int fd;
00282     unsigned events;
00283     unsigned revents;
00284 };
00285 #endif
00286 #ifndef HAVE_POLL
00287 struct pollfd;
00288 int poll (struct pollfd *, unsigned, int);
00289 #endif
00290 
00291 #ifndef HAVE_IF_NAMEINDEX
00292 #include <errno.h>
00293 struct if_nameindex
00294 {
00295     unsigned if_index;
00296     char    *if_name;
00297 };
00298 # ifndef HAVE_IF_NAMETOINDEX
00299 #  define if_nametoindex(name)   atoi(name)
00300 # endif
00301 # define if_nameindex()         (errno = ENOBUFS, NULL)
00302 # define if_freenameindex(list) (void)0
00303 #endif
00304 
00305 /* search.h */
00306 #ifndef HAVE_SEARCH_H
00307 typedef struct entry {
00308     char *key;
00309     void *data;
00310 } ENTRY;
00311 
00312 typedef enum {
00313     FIND, ENTER
00314 } ACTION;
00315 
00316 typedef enum {
00317     preorder,
00318     postorder,
00319     endorder,
00320     leaf
00321 } VISIT;
00322 
00323 void *tsearch( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
00324 void *tfind( const void *key, const void **rootp, int(*cmp)(const void *, const void *) );
00325 void *tdelete( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
00326 void twalk( const void *root, void(*action)(const void *nodep, VISIT which, int depth) );
00327 void tdestroy( void *root, void (*free_node)(void *nodep) );
00328 #else // HAVE_SEARCH_H
00329 # ifndef HAVE_TDESTROY
00330 #  define tdestroy vlc_tdestroy
00331 # endif
00332 #endif
00333 
00334 /* Random numbers */
00335 #ifndef HAVE_NRAND48
00336 double erand48 (unsigned short subi[3]);
00337 long jrand48 (unsigned short subi[3]);
00338 long nrand48 (unsigned short subi[3]);
00339 #endif
00340 
00341 #ifdef __OS2__
00342 # undef HAVE_FORK   /* Implementation of fork() is imperfect on OS/2 */
00343 #endif
00344 
00345 #endif /* !LIBVLC_FIXUPS_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines