26 #ifndef LIBVLC_FIXUPS_H
27 # define LIBVLC_FIXUPS_H 1
30 #ifdef HAVE_FEATURES_H
36 #if defined (__cplusplus) && (defined(__MINGW32__) || defined(__UCLIBC__))
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 (__cplusplus) && !defined (HAVE_MAX_ALIGN_T)
133 #ifndef HAVE_ASPRINTF
134 int asprintf (
char **,
const char *, ...);
137 #ifndef HAVE_FLOCKFILE
146 #ifndef HAVE_GETDELIM
147 ssize_t
getdelim (
char **,
size_t *,
int, FILE *);
155 #ifndef HAVE_VASPRINTF
156 int vasprintf (
char **,
const char *, va_list);
161 void *
memrchr(
const void *,
int,
size_t);
164 #ifndef HAVE_STRCASECMP
168 #ifndef HAVE_STRCASESTR
169 char *
strcasestr (
const char *,
const char *);
173 char *
strdup (
const char *);
176 #ifndef HAVE_STRVERSCMP
181 size_t strnlen (
const char *,
size_t);
185 char *
strnstr (
const char *,
const char *,
size_t);
189 char *
strndup (
const char *,
size_t);
193 size_t strlcpy (
char *,
const char *,
size_t);
197 char *
strsep (
char **,
const char *);
200 #ifndef HAVE_STRTOK_R
201 char *
strtok_r(
char *,
const char *,
char **);
207 double atof (
const char *);
212 long long atoll (
const char *);
221 float strtof (
const char *,
char **);
226 long long int strtoll (
const char *,
char **,
int);
230 #ifndef HAVE_GMTIME_R
231 struct tm *
gmtime_r (
const time_t *,
struct tm *);
234 #ifndef HAVE_LOCALTIME_R
235 struct tm *
localtime_r (
const time_t *,
struct tm *);
239 time_t
timegm(
struct tm *);
242 #ifndef HAVE_TIMESPEC_GET
249 #ifndef HAVE_GETTIMEOFDAY
268 #ifndef HAVE_FDOPENDIR
290 int setenv (
const char *,
const char *,
int);
294 #ifndef HAVE_POSIX_MEMALIGN
298 #ifndef HAVE_ALIGNED_ALLOC
306 #if defined (_WIN32) && defined(__MINGW32__)
307 #define aligned_free(ptr) __mingw_aligned_free(ptr)
308 #elif defined (_WIN32) && defined(_MSC_VER)
309 #define aligned_free(ptr) _aligned_free(ptr)
311 #define aligned_free(ptr) free(ptr)
314 #if !defined(HAVE_NEWLOCALE) && defined(HAVE_CXX_LOCALE_T) && defined(__cplusplus)
316 # define HAVE_NEWLOCALE
320 #ifndef HAVE_USELOCALE
321 # ifndef HAVE_NEWLOCALE
322 # define LC_ALL_MASK 0
323 # define LC_NUMERIC_MASK 0
324 # define LC_MESSAGES_MASK 0
325 # define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
334 (void)mask; (void)locale; (void)base;
348 #if !defined (HAVE_STATIC_ASSERT) && !defined(__cpp_static_assert)
349 # define STATIC_ASSERT_CONCAT_(a, b) a##b
350 # define STATIC_ASSERT_CONCAT(a, b) STATIC_ASSERT_CONCAT_(a, b)
351 # define _Static_assert(x, s) extern char STATIC_ASSERT_CONCAT(static_assert_, __LINE__)[sizeof(struct { unsigned:-!(x); })]
352 # define static_assert _Static_assert
356 #define _(str) vlc_gettext (str)
357 #define N_(str) gettext_noop (str)
358 #define gettext_noop(str) (str)
365 void swab (
const void *,
void *, ssize_t);
369 #ifndef HAVE_INET_PTON
371 # include <sys/socket.h>
373 typedef int socklen_t;
375 int inet_pton(
int,
const char *,
void *);
376 const char *
inet_ntop(
int,
const void *,
char *, socklen_t);
379 #ifndef HAVE_STRUCT_POLLFD
391 #define POLLIN (POLLRDNORM|POLLRDBAND)
392 #define POLLOUT (POLLWRNORM|POLLWRBAND)
406 #ifndef HAVE_IF_NAMEINDEX
408 # ifndef HAVE_STRUCT_IF_NAMEINDEX
415 # define if_nameindex() (errno = ENOBUFS, NULL)
416 # define if_freenameindex(list) (void)0
419 #ifndef HAVE_STRUCT_TIMESPEC
437 struct iovec *msg_iov;
440 size_t msg_controllen;
444 # ifndef HAVE_IF_NAMETOINDEX
446 static inline int if_nametoindex(
const char *
name)
453 #ifdef _NEWLIB_VERSION
459 ssize_t
recvmsg(
int,
struct msghdr *,
int);
464 ssize_t
sendmsg(
int,
const struct msghdr *,
int);
468 #ifndef HAVE_SEARCH_H
469 typedef struct entry {
485 void *
tsearch(
const void *key,
void **rootp,
int(*cmp)(
const void *,
const void *) );
486 void *
tfind(
const void *key,
void *
const *rootp,
int(*cmp)(
const void *,
const void *) );
487 void *
tdelete(
const void *key,
void **rootp,
int(*cmp)(
const void *,
const void *) );
488 void twalk(
const void *root,
void(*action)(
const void *nodep,
VISIT which,
int depth) );
489 void *
lfind(
const void *key,
const void *base,
size_t *nmemb,
490 size_t size,
int(*cmp)(
const void *,
const void *) );
494 # ifdef HAVE_SEARCH_H
498 # define lfind(a,b,c,d,e) \
499 lfind((a),(b), &(unsigned){ (*(c) > UINT_MAX) ? UINT_MAX : *(c) }, (d),(e))
502 #ifndef HAVE_TDESTROY
503 void tdestroy(
void *root,
void (*free_node)(
void *nodep) );
507 #ifndef HAVE_GETAUXVAL
526 # ifndef EAI_BADFLAGS
527 # define EAI_BADFLAGS -1
530 # define EAI_NONAME -2
533 # define EAI_AGAIN -3
539 # define EAI_NODATA -5
542 # define EAI_FAMILY -6
544 # ifndef EAI_SOCKTYPE
545 # define EAI_SOCKTYPE -7
548 # define EAI_SERVICE -8
550 # ifndef EAI_ADDRFAMILY
551 # define EAI_ADDRFAMILY -9
554 # define EAI_MEMORY -10
556 # ifndef EAI_OVERFLOW
557 # define EAI_OVERFLOW -11
560 # define EAI_SYSTEM -12
563 # ifndef NI_NUMERICHOST
564 # define NI_NUMERICHOST 0x01
565 # define NI_NUMERICSERV 0x02
566 # define NI_NOFQDN 0x04
567 # define NI_NAMEREQD 0x08
568 # define NI_DGRAM 0x10
572 # define NI_MAXHOST 1025
573 # define NI_MAXSERV 32
576 # define AI_PASSIVE 1
577 # define AI_CANONNAME 2
578 # define AI_NUMERICHOST 4
587 struct sockaddr *ai_addr;
589 struct addrinfo *ai_next;
592 const char *gai_strerror (
int);
594 int getaddrinfo (
const char *node,
const char *service,
595 const struct addrinfo *hints,
struct addrinfo **res);
596 void freeaddrinfo (
struct addrinfo *res);
597 int getnameinfo (
const struct sockaddr *sa, socklen_t salen,
598 char *host,
int hostlen,
char *serv,
int servlen,
614 uint32_t sin6_flowinfo;
615 struct in6_addr sin6_addr;
616 uint32_t sin6_scope_id;
619 # define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
621 static const struct in6_addr in6addr_any =
622 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
626 # define EPROTO (ELAST + 1)
629 # ifndef HAVE_IF_NAMETOINDEX
630 # define if_nametoindex(name) atoi(name)
637 #define nanf(tagp) NAN
641 void sincos(
double,
double *,
double *);
645 #ifndef HAVE_REALPATH
646 char *
realpath(
const char * restrict pathname,
char * restrict resolved_path);
650 #if defined(_WIN32) && defined(__MINGW64_VERSION_MAJOR)
651 # define IN6_IS_ADDR_MULTICAST IN6_IS_ADDR_MULTICAST
655 # define fdatasync fsync
658 # ifndef TIMER_ABSTIME
659 # define TIMER_ABSTIME 0x01
661 # ifndef CLOCK_REALTIME
662 # define CLOCK_REALTIME 0
664 # ifndef CLOCK_MONOTONIC
665 # define CLOCK_MONOTONIC 6
667 # ifndef HAVE_CLOCK_GETTIME
668 int clock_gettime(clockid_t clock_id,
struct timespec *tp);
670 # ifndef HAVE_CLOCK_GETRES
671 int clock_getres(clockid_t clock_id,
struct timespec *tp);
676 # ifndef HAVE_CLOCK_NANOSLEEP
687 #if defined(__cplusplus)
688 #ifndef HAVE_CXX_TYPEOF
689 # include <type_traits>
690 # define typeof(t) std::remove_reference<decltype(t)>::type
const char name[16]
Definition: httpd.c:1267
unsigned short subi[3]
Definition: rand.c:31
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
Definition: getaddrinfo.c:187
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, int hostlen, char *serv, int servlen, int flags)
Definition: getaddrinfo.c:49
Definition: fourcc_gen.c:52
char * key
Definition: vlc_fixups.h:471
void * data
Definition: vlc_fixups.h:472
Definition: vlc_fixups.h:411
unsigned if_index
Definition: vlc_fixups.h:412
char * if_name
Definition: vlc_fixups.h:413
Definition: vlc_fixups.h:76
Definition: vlc_fixups.h:127
Definition: vlc_fixups.h:396
int fd
Definition: vlc_fixups.h:397
short revents
Definition: vlc_fixups.h:399
short events
Definition: vlc_fixups.h:398
Definition: vlc_fixups.h:421
long tv_nsec
Definition: vlc_fixups.h:423
time_t tv_sec
Definition: vlc_fixups.h:422
ssize_t recvmsg(int, struct msghdr *, int)
float strtof(const char *, char **)
int inet_pton(int, const char *, void *)
void * lfind(const void *key, const void *base, size_t *nmemb, size_t size, int(*cmp)(const void *, const void *))
int gettimeofday(struct timeval *, struct timezone *)
ssize_t getdelim(char **, size_t *, int, FILE *)
#define VLC_NOTHROW
Definition: vlc_fixups.h:122
char * strcasestr(const char *, const char *)
double erand48(unsigned short subi[3])
int getc_unlocked(FILE *)
static void freelocale(locale_t loc)
Definition: vlc_fixups.h:329
int posix_memalign(void **, size_t, size_t)
lldiv_t lldiv(long long, long long)
void sincos(double, double *, double *)
int putc_unlocked(int, FILE *)
void * tfind(const void *key, void *const *rootp, int(*cmp)(const void *, const void *))
long nrand48(unsigned short subi[3])
int vasprintf(char **, const char *, va_list)
double atof(const char *)
int putchar_unlocked(int)
static locale_t uselocale(locale_t loc)
Definition: vlc_fixups.h:342
char * strsep(char **, const char *)
void * tsearch(const void *key, void **rootp, int(*cmp)(const void *, const void *))
long long atoll(const char *)
void twalk(const void *root, void(*action)(const void *nodep, VISIT which, int depth))
int setenv(const char *, const char *, int)
int unsetenv(const char *)
void sincosf(float, float *, float *)
time_t timegm(struct tm *)
unsigned long getauxval(unsigned long)
char * strdup(const char *)
const char * inet_ntop(int, const void *, char *, socklen_t)
struct tm * localtime_r(const time_t *, struct tm *)
long jrand48(unsigned short subi[3])
int timespec_get(struct timespec *, int)
size_t strlcpy(char *, const char *, size_t)
ssize_t getline(char **, size_t *, FILE *)
static locale_t newlocale(int mask, const char *locale, locale_t base)
Definition: vlc_fixups.h:333
long long int strtoll(const char *, char **, int)
void swab(const void *, void *, ssize_t)
void * aligned_alloc(size_t, size_t)
int strcasecmp(const char *, const char *)
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
void * tdelete(const void *key, void **rootp, int(*cmp)(const void *, const void *))
char * strtok_r(char *, const char *, char **)
void * memrchr(const void *, int, size_t)
char * strnstr(const char *, const char *, size_t)
void * locale_t
Definition: vlc_fixups.h:327
@ POLLRDBAND
Definition: vlc_fixups.h:389
@ POLLWRBAND
Definition: vlc_fixups.h:387
@ POLLPRI
Definition: vlc_fixups.h:390
@ POLLRDNORM
Definition: vlc_fixups.h:388
@ POLLHUP
Definition: vlc_fixups.h:384
@ POLLNVAL
Definition: vlc_fixups.h:385
@ POLLWRNORM
Definition: vlc_fixups.h:386
@ POLLERR
Definition: vlc_fixups.h:383
int poll(struct pollfd *, unsigned, int)
void tdestroy(void *root, void(*free_node)(void *nodep))
int strverscmp(const char *, const char *)
ssize_t sendmsg(int, const struct msghdr *, int)
char * realpath(const char *restrict pathname, char *restrict resolved_path)
size_t strnlen(const char *, size_t)
VISIT
Definition: vlc_fixups.h:479
@ postorder
Definition: vlc_fixups.h:481
@ leaf
Definition: vlc_fixups.h:483
@ endorder
Definition: vlc_fixups.h:482
@ preorder
Definition: vlc_fixups.h:480
ACTION
Definition: vlc_fixups.h:475
@ FIND
Definition: vlc_fixups.h:476
@ ENTER
Definition: vlc_fixups.h:476
char * strndup(const char *, size_t)
int asprintf(char **, const char *,...)
static char * getenv(const char *name)
Definition: vlc_fixups.h:279
int getchar_unlocked(void)
struct tm * gmtime_r(const time_t *, struct tm *)