Go to the documentation of this file.
26 #ifndef LIBVLC_FIXUPS_H
27 # define LIBVLC_FIXUPS_H 1
30 #ifdef HAVE_FEATURES_H
36 #if defined (__cplusplus) && (defined(__MINGW32__) || defined(__UCLIBC__) || defined(__native_client__))
37 # ifndef __STDC_FORMAT_MACROS
38 # define __STDC_FORMAT_MACROS 1
40 # ifndef __STDC_CONSTANT_MACROS
41 # define __STDC_CONSTANT_MACROS 1
43 # ifndef __STDC_LIMIT_MACROS
44 # define __STDC_LIMIT_MACROS 1
49 # ifdef HAVE_THREADS_H
51 # elif !defined(thread_local)
52 # ifdef HAVE_THREAD_LOCAL
53 # define thread_local _Thread_local
54 # elif defined(_MSC_VER)
55 # define thread_local __declspec(thread)
60 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R) \
61 || !defined (HAVE_TIMEGM)
65 #ifndef HAVE_GETTIMEOFDAY
81 #if !defined(HAVE_GETENV) || \
82 !defined(HAVE_USELOCALE)
86 #if !defined (HAVE_REWIND) || \
87 !defined (HAVE_GETDELIM)
91 #if !defined (HAVE_ALIGNED_ALLOC) || \
92 !defined (HAVE_MEMRCHR) || \
93 !defined (HAVE_POSIX_MEMALIGN) || \
94 !defined (HAVE_QSORT_R) || \
95 !defined (HAVE_STRLCPY) || \
96 !defined (HAVE_STRNDUP) || \
97 !defined (HAVE_STRNLEN) || \
98 !defined (HAVE_STRNSTR)
102 #ifndef HAVE_VASPRINTF
106 #if !defined (HAVE_GETDELIM) || \
107 !defined (HAVE_GETPID) || \
109 # include <sys/types.h>
112 #if !defined (HAVE_DIRFD) || \
113 !defined (HAVE_FDOPENDIR)
118 # define VLC_NOTHROW throw ()
125 #if !defined(HAVE_SIGWAIT) && defined(__native_client__)
130 int sigwait(
const sigset_t *set,
int *sig);
134 #if !defined (__cplusplus) && !defined (HAVE_MAX_ALIGN_T)
142 #ifndef HAVE_ASPRINTF
143 int asprintf (
char **,
const char *, ...);
146 #ifndef HAVE_FLOCKFILE
155 #ifndef HAVE_GETDELIM
156 ssize_t
getdelim (
char **,
size_t *,
int, FILE *);
157 ssize_t
getline (
char **,
size_t *, FILE *);
164 #ifndef HAVE_VASPRINTF
165 int vasprintf (
char **,
const char *, va_list);
170 void *
memrchr(
const void *,
int,
size_t);
173 #ifndef HAVE_STRCASECMP
177 #ifndef HAVE_STRCASESTR
178 char *
strcasestr (
const char *,
const char *);
182 char *
strdup (
const char *);
185 #ifndef HAVE_STRVERSCMP
190 size_t strnlen (
const char *,
size_t);
194 char *
strnstr (
const char *,
const char *,
size_t);
198 char *
strndup (
const char *,
size_t);
202 size_t strlcpy (
char *,
const char *,
size_t);
206 char *
strsep (
char **,
const char *);
209 #ifndef HAVE_STRTOK_R
210 char *
strtok_r(
char *,
const char *,
char **);
216 double atof (
const char *);
221 long long atoll (
const char *);
230 float strtof (
const char *,
char **);
235 long long int strtoll (
const char *,
char **,
int);
239 #ifndef HAVE_GMTIME_R
240 struct tm *
gmtime_r (
const time_t *,
struct tm *);
243 #ifndef HAVE_LOCALTIME_R
244 struct tm *
localtime_r (
const time_t *,
struct tm *);
248 time_t
timegm(
struct tm *);
251 #ifndef HAVE_TIMESPEC_GET
258 #ifndef HAVE_GETTIMEOFDAY
272 #ifndef HAVE_PATHCONF
281 #ifndef HAVE_FDOPENDIR
303 int setenv (
const char *,
const char *,
int);
307 #ifndef HAVE_POSIX_MEMALIGN
311 #ifndef HAVE_ALIGNED_ALLOC
319 #if defined (_WIN32) && defined(__MINGW32__)
320 #define aligned_free(ptr) __mingw_aligned_free(ptr)
321 #elif defined (_WIN32) && defined(_MSC_VER)
322 #define aligned_free(ptr) _aligned_free(ptr)
324 #define aligned_free(ptr) free(ptr)
327 #if defined(__native_client__) && defined(__cplusplus)
328 # define HAVE_USELOCALE
331 #if !defined(HAVE_NEWLOCALE) && defined(HAVE_CXX_LOCALE_T) && defined(__cplusplus)
333 # define HAVE_NEWLOCALE
337 #ifndef HAVE_USELOCALE
338 # ifndef HAVE_NEWLOCALE
339 # define LC_ALL_MASK 0
340 # define LC_NUMERIC_MASK 0
341 # define LC_MESSAGES_MASK 0
342 # define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
351 (void)mask; (void)locale; (void)base;
365 #if !defined (HAVE_STATIC_ASSERT) && !defined(__cpp_static_assert)
366 # define STATIC_ASSERT_CONCAT_(a, b) a##b
367 # define STATIC_ASSERT_CONCAT(a, b) STATIC_ASSERT_CONCAT_(a, b)
368 # define _Static_assert(x, s) extern char STATIC_ASSERT_CONCAT(static_assert_, __LINE__)[sizeof(struct { unsigned:-!(x); })]
369 # define static_assert _Static_assert
373 #define _(str) vlc_gettext (str)
374 #define N_(str) gettext_noop (str)
375 #define gettext_noop(str) (str)
382 void swab (
const void *,
void *, ssize_t);
386 #ifndef HAVE_INET_PTON
388 # include <sys/socket.h>
390 typedef int socklen_t;
392 int inet_pton(
int,
const char *,
void *);
393 const char *
inet_ntop(
int,
const void *,
char *, socklen_t);
397 #if defined(__native_client__) && !defined( HAVE_NETINET_TCP_H )
398 # define TCP_NODELAY 1
401 #ifndef HAVE_STRUCT_POLLFD
413 #define POLLIN (POLLRDNORM|POLLRDBAND)
414 #define POLLOUT (POLLWRNORM|POLLWRBAND)
428 #ifndef HAVE_IF_NAMEINDEX
430 # ifndef HAVE_STRUCT_IF_NAMEINDEX
437 # define if_nameindex() (errno = ENOBUFS, NULL)
438 # define if_freenameindex(list) (void)0
441 #ifndef HAVE_STRUCT_TIMESPEC
459 struct iovec *msg_iov;
462 size_t msg_controllen;
466 # ifndef HAVE_IF_NAMETOINDEX
468 static inline int if_nametoindex(
const char *
name)
475 #ifdef _NEWLIB_VERSION
481 ssize_t
recvmsg(
int,
struct msghdr *,
int);
486 ssize_t
sendmsg(
int,
const struct msghdr *,
int);
490 #ifndef HAVE_SEARCH_H
491 typedef struct entry {
507 void *
tsearch(
const void *key,
void **rootp,
int(*cmp)(
const void *,
const void *) );
508 void *
tfind(
const void *key,
void *
const *rootp,
int(*cmp)(
const void *,
const void *) );
509 void *
tdelete(
const void *key,
void **rootp,
int(*cmp)(
const void *,
const void *) );
510 void twalk(
const void *root,
void(*action)(
const void *nodep,
VISIT which,
int depth) );
511 void *
lfind(
const void *key,
const void *base,
size_t *nmemb,
512 size_t size,
int(*cmp)(
const void *,
const void *) );
516 # ifdef HAVE_SEARCH_H
520 # define lfind(a,b,c,d,e) \
521 lfind((a),(b), &(unsigned){ (*(c) > UINT_MAX) ? UINT_MAX : *(c) }, (d),(e))
524 #ifndef HAVE_TDESTROY
525 void tdestroy(
void *root,
void (*free_node)(
void *nodep) );
543 # ifndef EAI_BADFLAGS
544 # define EAI_BADFLAGS -1
547 # define EAI_NONAME -2
550 # define EAI_AGAIN -3
556 # define EAI_NODATA -5
559 # define EAI_FAMILY -6
561 # ifndef EAI_SOCKTYPE
562 # define EAI_SOCKTYPE -7
565 # define EAI_SERVICE -8
567 # ifndef EAI_ADDRFAMILY
568 # define EAI_ADDRFAMILY -9
571 # define EAI_MEMORY -10
573 # ifndef EAI_OVERFLOW
574 # define EAI_OVERFLOW -11
577 # define EAI_SYSTEM -12
580 # ifndef NI_NUMERICHOST
581 # define NI_NUMERICHOST 0x01
582 # define NI_NUMERICSERV 0x02
583 # define NI_NOFQDN 0x04
584 # define NI_NAMEREQD 0x08
585 # define NI_DGRAM 0x10
589 # define NI_MAXHOST 1025
590 # define NI_MAXSERV 32
593 # define AI_PASSIVE 1
594 # define AI_CANONNAME 2
595 # define AI_NUMERICHOST 4
604 struct sockaddr *ai_addr;
606 struct addrinfo *ai_next;
609 const char *gai_strerror (
int);
611 int getaddrinfo (
const char *node,
const char *service,
612 const struct addrinfo *hints,
struct addrinfo **res);
613 void freeaddrinfo (
struct addrinfo *res);
614 int getnameinfo (
const struct sockaddr *sa, socklen_t salen,
615 char *host,
int hostlen,
char *serv,
int servlen,
631 uint32_t sin6_flowinfo;
632 struct in6_addr sin6_addr;
633 uint32_t sin6_scope_id;
636 # define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
638 static const struct in6_addr in6addr_any =
639 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
643 # define EPROTO (ELAST + 1)
646 # ifndef HAVE_IF_NAMETOINDEX
647 # define if_nametoindex(name) atoi(name)
654 #define nanf(tagp) NAN
658 void sincos(
double,
double *,
double *);
659 void sincosf(
float,
float *,
float *);
662 #ifndef HAVE_REALPATH
663 char *
realpath(
const char * restrict pathname,
char * restrict resolved_path);
667 #if defined(_WIN32) && defined(__MINGW64_VERSION_MAJOR)
668 # define IN6_IS_ADDR_MULTICAST IN6_IS_ADDR_MULTICAST
672 # define fdatasync fsync
675 # ifndef TIMER_ABSTIME
676 # define TIMER_ABSTIME 0x01
678 # ifndef CLOCK_REALTIME
679 # define CLOCK_REALTIME 0
681 # ifndef CLOCK_MONOTONIC
682 # define CLOCK_MONOTONIC 6
684 # ifndef HAVE_CLOCK_GETTIME
685 int clock_gettime(clockid_t clock_id,
struct timespec *tp);
687 # ifndef HAVE_CLOCK_GETRES
688 int clock_getres(clockid_t clock_id,
struct timespec *tp);
690 # ifndef HAVE_CLOCK_NANOSLEEP
691 int clock_nanosleep(clockid_t clock_id,
int flags,
int getchar_unlocked(void)
@ FIND
Definition: vlc_fixups.h:498
double atof(const char *)
char * realpath(const char *restrict pathname, char *restrict resolved_path)
@ leaf
Definition: vlc_fixups.h:505
int putc_unlocked(int, FILE *)
ssize_t getdelim(char **, size_t *, int, FILE *)
int strcasecmp(const char *, const char *)
void sincosf(float, float *, float *)
long long rem
Definition: vlc_fixups.h:78
void * tdelete(const void *key, void **rootp, int(*cmp)(const void *, const void *))
size_t strnlen(const char *, size_t)
int fd
Definition: vlc_fixups.h:419
static locale_t uselocale(locale_t loc)
Definition: vlc_fixups.h:359
struct tm * gmtime_r(const time_t *, struct tm *)
int inet_pton(int, const char *, void *)
void * aligned_alloc(size_t, size_t)
@ POLLHUP
Definition: vlc_fixups.h:406
long nrand48(unsigned short subi[3])
void * locale_t
Definition: vlc_fixups.h:344
float strtof(const char *, char **)
Definition: vlc_fixups.h:417
long double ld
Definition: vlc_fixups.h:138
unsigned if_index
Definition: vlc_fixups.h:434
unsigned short subi[3]
Definition: rand.c:49
long pathconf(const char *path, int name)
int poll(struct pollfd *, unsigned, int)
@ POLLRDBAND
Definition: vlc_fixups.h:411
@ postorder
Definition: vlc_fixups.h:503
int unsetenv(const char *)
void sincos(double, double *, double *)
Definition: vlc_fixups.h:75
int strverscmp(const char *, const char *)
static char * getenv(const char *name)
Definition: vlc_fixups.h:292
static void freelocale(locale_t loc)
Definition: vlc_fixups.h:346
char * key
Definition: vlc_fixups.h:493
@ POLLERR
Definition: vlc_fixups.h:405
int asprintf(char **, const char *,...)
void * data
Definition: vlc_fixups.h:494
short revents
Definition: vlc_fixups.h:421
char * strndup(const char *, size_t)
long jrand48(unsigned short subi[3])
long tv_nsec
Definition: vlc_fixups.h:445
lldiv_t lldiv(long long, long long)
@ preorder
Definition: vlc_fixups.h:502
char * strnstr(const char *, const char *, size_t)
void swab(const void *, void *, ssize_t)
@ POLLWRBAND
Definition: vlc_fixups.h:409
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
Definition: getaddrinfo.c:187
long long quot
Definition: vlc_fixups.h:77
time_t tv_sec
Definition: vlc_fixups.h:444
int posix_memalign(void **, size_t, size_t)
@ POLLWRNORM
Definition: vlc_fixups.h:408
char * strcasestr(const char *, const char *)
int timespec_get(struct timespec *, int)
static locale_t newlocale(int mask, const char *locale, locale_t base)
Definition: vlc_fixups.h:350
void * memrchr(const void *, int, size_t)
Definition: vlc_fixups.h:432
short events
Definition: vlc_fixups.h:420
ssize_t recvmsg(int, struct msghdr *, int)
char * strtok_r(char *, const char *, char **)
#define VLC_NOTHROW
Definition: vlc_fixups.h:122
Definition: vlc_fixups.h:136
size_t strlcpy(char *, const char *, size_t)
VISIT
Definition: vlc_fixups.h:501
void * lfind(const void *key, const void *base, size_t *nmemb, size_t size, int(*cmp)(const void *, const void *))
@ endorder
Definition: vlc_fixups.h:504
ssize_t sendmsg(int, const struct msghdr *, int)
@ POLLPRI
Definition: vlc_fixups.h:412
ACTION
Definition: vlc_fixups.h:497
void tdestroy(void *root, void(*free_node)(void *nodep))
char * strdup(const char *)
void * tfind(const void *key, void *const *rootp, int(*cmp)(const void *, const void *))
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, int hostlen, char *serv, int servlen, int flags)
Definition: getaddrinfo.c:49
@ ENTER
Definition: vlc_fixups.h:498
@ POLLRDNORM
Definition: vlc_fixups.h:410
const char name[16]
Definition: httpd.c:1268
Definition: fourcc_gen.c:51
int gettimeofday(struct timeval *, struct timezone *)
long long int strtoll(const char *, char **, int)
int getc_unlocked(FILE *)
struct tm * localtime_r(const time_t *, struct tm *)
time_t timegm(struct tm *)
void * tsearch(const void *key, void **rootp, int(*cmp)(const void *, const void *))
Definition: vlc_fixups.h:443
char * strsep(char **, const char *)
void twalk(const void *root, void(*action)(const void *nodep, VISIT which, int depth))
long long atoll(const char *)
const char * inet_ntop(int, const void *, char *, socklen_t)
int vasprintf(char **, const char *, va_list)
double erand48(unsigned short subi[3])
int setenv(const char *, const char *, int)
@ POLLNVAL
Definition: vlc_fixups.h:407
int putchar_unlocked(int)
long long ll
Definition: vlc_fixups.h:137
char * if_name
Definition: vlc_fixups.h:435
ssize_t getline(char **, size_t *, FILE *)