26#ifndef LIBVLC_FIXUPS_H
27# define LIBVLC_FIXUPS_H 1
31#ifndef _CRT_NONSTDC_NO_DEPRECATE
33# if !(defined(_GAMING_XBOX_SCARLETT) || defined(_GAMING_XBOX_XBOXONE) || defined(_XBOX_ONE))
34# define _CRT_NONSTDC_NO_DEPRECATE
37#ifndef _CRT_SECURE_NO_WARNINGS
38#define _CRT_SECURE_NO_WARNINGS 1
40#if defined(_GAMING_XBOX_SCARLETT) || defined(_GAMING_XBOX_XBOXONE) || defined(_XBOX_ONE)
42# undef _CRT_DECLARE_NONSTDC_NAMES
43# define _CRT_DECLARE_NONSTDC_NAMES 0
48#define S_IWUSR _S_IWRITE
49#define S_IRUSR _S_IREAD
50#define S_IFIFO _S_IFIFO
52#define S_IFCHR _S_IFCHR
53#define S_IFREG _S_IFREG
54#define S_IFDIR _S_IFDIR
55#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
56#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
60typedef unsigned short mode_t;
63#define strncasecmp _strnicmp
64#define snwprintf _snwprintf
67#define _CRT_SUPPRESS_RESTRICT
68#define DECLSPEC_RESTRICT
71#if defined(_M_X64) && !defined(__x86_64__)
74#if defined(_M_IX86) && !defined(__i386__)
77#if defined(_M_ARM64) && !defined(__aarch64__)
80#if defined(_M_ARM) && !defined(__arm__)
83#if defined(_M_IX86_FP) && _M_IX86_FP == 1 && !defined(__SSE__)
86#if defined(_M_IX86_FP) && _M_IX86_FP == 2 && !defined(__SSE2__)
93# if !defined(NOMINMAX)
97# if !defined(_USE_MATH_DEFINES)
99# define _USE_MATH_DEFINES
105#ifdef HAVE_FEATURES_H
111#if defined (__cplusplus) && defined(__UCLIBC__)
112# ifndef __STDC_FORMAT_MACROS
113# define __STDC_FORMAT_MACROS 1
115# ifndef __STDC_CONSTANT_MACROS
116# define __STDC_CONSTANT_MACROS 1
118# ifndef __STDC_LIMIT_MACROS
119# define __STDC_LIMIT_MACROS 1
124# ifdef HAVE_THREADS_H
126# elif !defined(thread_local)
127# ifdef HAVE_THREAD_LOCAL
128# define thread_local _Thread_local
129# elif defined(_MSC_VER)
130# define thread_local __declspec(thread)
135#if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R) \
136 || !defined (HAVE_TIMEGM)
140#ifndef HAVE_GETTIMEOFDAY
156#if !defined(HAVE_GETENV) || \
157 !defined(HAVE_USELOCALE)
161#if !defined (HAVE_REWIND) || \
162 !defined (HAVE_GETDELIM)
166#if !defined (HAVE_ALIGNED_ALLOC) || \
167 !defined (HAVE_MEMRCHR) || \
168 !defined (HAVE_POSIX_MEMALIGN) || \
169 !defined (HAVE_QSORT_R) || \
170 !defined (HAVE_STRLCPY) || \
171 !defined (HAVE_STRNDUP) || \
172 !defined (HAVE_STRNLEN) || \
173 !defined (HAVE_STRNSTR)
177#ifndef HAVE_VASPRINTF
181#if !defined (HAVE_GETDELIM) || \
182 !defined (HAVE_GETPID) || \
183 !defined (HAVE_SWAB) || \
184 !defined (HAVE_WRITEV) || \
185 !defined (HAVE_READV)
186# include <sys/types.h>
188# if defined(_CRT_INTERNAL_NONSTDC_NAMES) && !_CRT_INTERNAL_NONSTDC_NAMES
194#if !defined (HAVE_DIRFD) || \
195 !defined (HAVE_FDOPENDIR)
200# define VLC_NOTHROW throw ()
207#if !defined (__cplusplus) && !defined (HAVE_MAX_ALIGN_T)
216int asprintf (
char **,
const char *, ...);
219#ifndef HAVE_FLOCKFILE
229ssize_t
getdelim (
char **,
size_t *,
int, FILE *);
237#ifndef HAVE_VASPRINTF
238int vasprintf (
char **,
const char *, va_list);
243void *
memrchr(
const void *,
int,
size_t);
246#ifndef HAVE_STRCASECMP
250#ifndef HAVE_STRCASESTR
255char *
strdup (
const char *);
258#ifndef HAVE_STRVERSCMP
263size_t strnlen (
const char *,
size_t);
267char *
strnstr (
const char *,
const char *,
size_t);
271char *
strndup (
const char *,
size_t);
275size_t strlcpy (
char *,
const char *,
size_t);
279char *
strsep (
char **,
const char *);
283char *
strtok_r(
char *,
const char *,
char **);
289double atof (
const char *);
294long long atoll (
const char *);
303float strtof (
const char *,
char **);
308long long int strtoll (
const char *,
char **,
int);
314ssize_t
readv(
int,
const struct iovec *,
int);
319ssize_t
writev(
int,
const struct iovec *,
int);
324struct tm *
gmtime_r (
const time_t *,
struct tm *);
327#ifndef HAVE_LOCALTIME_R
328struct tm *
localtime_r (
const time_t *,
struct tm *);
332time_t
timegm(
struct tm *);
335#ifndef HAVE_TIMESPEC_GET
342#ifndef HAVE_GETTIMEOFDAY
347#if defined(WIN32) && !defined(WINSTORECOMPAT)
348#include <winapifamily.h>
349#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
351#define getpid() GetCurrentProcessId()
369#ifndef HAVE_FDOPENDIR
391int setenv (
const char *,
const char *,
int);
395#ifndef HAVE_POSIX_MEMALIGN
399#ifndef HAVE_ALIGNED_ALLOC
408#define aligned_free(ptr) _aligned_free(ptr)
410#define aligned_free(ptr) free(ptr)
413#if !defined(HAVE_NEWLOCALE) && defined(HAVE_CXX_LOCALE_T) && defined(__cplusplus)
415# define HAVE_NEWLOCALE
419#ifndef HAVE_USELOCALE
420# ifndef HAVE_NEWLOCALE
421# define LC_ALL_MASK 0
422# define LC_NUMERIC_MASK 0
423# define LC_MESSAGES_MASK 0
424# define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
433 (void)mask; (void)locale; (void)base;
448#define _(str) vlc_gettext (str)
449#define N_(str) gettext_noop (str)
450#define gettext_noop(str) (str)
459void swab (
const void *,
void *, ssize_t);
464#ifndef HAVE_INET_PTON
469# include <sys/socket.h>
471typedef int socklen_t;
478const char *
inet_ntop(
int,
const void *,
char *, socklen_t);
481#ifndef HAVE_STRUCT_POLLFD
493#define POLLIN (POLLRDNORM|POLLRDBAND)
494#define POLLOUT (POLLWRNORM|POLLWRBAND)
508#ifndef HAVE_IF_NAMEINDEX
516# ifndef HAVE_STRUCT_IF_NAMEINDEX
523# define if_nameindex() (errno = ENOBUFS, NULL)
524# define if_freenameindex(list) (void)0
527#ifndef HAVE_STRUCT_TIMESPEC
545 struct iovec *msg_iov;
548 size_t msg_controllen;
552# ifndef HAVE_IF_NAMETOINDEX
560static inline int if_nametoindex(
const char *
name)
567#ifdef _NEWLIB_VERSION
573ssize_t
recvmsg(
int,
struct msghdr *,
int);
578ssize_t
sendmsg(
int,
const struct msghdr *,
int);
590void *
tsearch(
const void *key,
void **rootp,
int(*cmp)(
const void *,
const void *) );
591void *
tfind(
const void *key,
void *
const *rootp,
int(*cmp)(
const void *,
const void *) );
592void *
tdelete(
const void *key,
void **rootp,
int(*cmp)(
const void *,
const void *) );
593void twalk(
const void *root,
void(*action)(
const void *nodep,
VISIT which,
int depth) );
596void *
lfind(
const void *key,
const void *base,
size_t *nmemb,
597 size_t size,
int(*cmp)(
const void *,
const void *) );
602void tdestroy(
void *root,
void (*free_node)(
void *nodep) );
606#ifndef HAVE_GETAUXVAL
626# define EAI_BADFLAGS -1
629# define EAI_NONAME -2
638# define EAI_NODATA -5
641# define EAI_FAMILY -6
644# define EAI_SOCKTYPE -7
647# define EAI_SERVICE -8
649# ifndef EAI_ADDRFAMILY
650# define EAI_ADDRFAMILY -9
653# define EAI_MEMORY -10
656# define EAI_OVERFLOW -11
659# define EAI_SYSTEM -12
662# ifndef NI_NUMERICHOST
663# define NI_NUMERICHOST 0x01
664# define NI_NUMERICSERV 0x02
665# define NI_NOFQDN 0x04
666# define NI_NAMEREQD 0x08
667# define NI_DGRAM 0x10
671# define NI_MAXHOST 1025
672# define NI_MAXSERV 32
676# define AI_CANONNAME 2
677# define AI_NUMERICHOST 4
686 struct sockaddr *ai_addr;
688 struct addrinfo *ai_next;
694# include <sys/socket.h>
697const char *gai_strerror (
int);
699int getaddrinfo (
const char *node,
const char *service,
700 const struct addrinfo *hints,
struct addrinfo **res);
701void freeaddrinfo (
struct addrinfo *res);
702int getnameinfo (
const struct sockaddr *sa, socklen_t salen,
703 char *host,
int hostlen,
char *serv,
int servlen,
719 uint32_t sin6_flowinfo;
720 struct in6_addr sin6_addr;
721 uint32_t sin6_scope_id;
724# define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
726# define INET6_ADDRSTRLEN 46
728static const struct in6_addr in6addr_any =
729 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
731#define IN6ADDR_ANY_INIT \
732 { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } }
736# define EPROTO (ELAST + 1)
739# ifndef HAVE_IF_NAMETOINDEX
740# define if_nametoindex(name) atoi(name)
744# if defined(__STDC_VERSION__) && \
745 __STDC_VERSION__ >= 201112L && __STDC_VERSION__ < 202311L
747# ifndef static_assert
748# define static_assert _Static_assert
756#define nanf(tagp) NAN
760void sincos(
double,
double *,
double *);
765char *
realpath(
const char * restrict pathname,
char * restrict resolved_path);
769#if defined(_WIN32) && defined(__MINGW64_VERSION_MAJOR)
770# define IN6_IS_ADDR_MULTICAST IN6_IS_ADDR_MULTICAST
774# define fdatasync fsync
783# ifndef TIMER_ABSTIME
784# define TIMER_ABSTIME 0x01
786# ifndef CLOCK_REALTIME
787# define CLOCK_REALTIME 0
789# ifndef CLOCK_MONOTONIC
790# define CLOCK_MONOTONIC 6
792# ifndef HAVE_CLOCK_GETTIME
793int clock_gettime(clockid_t clock_id,
struct timespec *tp);
795# ifndef HAVE_CLOCK_GETRES
796int clock_getres(clockid_t clock_id,
struct timespec *tp);
801# ifndef HAVE_CLOCK_NANOSLEEP
815# if defined(_CRT_INTERNAL_NONSTDC_NAMES) && !_CRT_INTERNAL_NONSTDC_NAMES
818static inline char *
strdup(
const char *str)
823# define O_WRONLY _O_WRONLY
824# define O_CREAT _O_CREAT
825# define O_APPEND _O_APPEND
826# define O_TRUNC _O_TRUNC
827# define O_BINARY _O_BINARY
828# define O_EXCL _O_EXCL
829# define O_RDWR _O_RDWR
830# define O_TEXT _O_TEXT
831# define O_NOINHERIT _O_NOINHERIT
832# define O_RDONLY _O_RDONLY
842#if defined(__cplusplus)
843#ifndef HAVE_CXX_TYPEOF
844# include <type_traits>
845# define typeof(t) std::remove_reference<decltype(t)>::type
const char name[16]
Definition: httpd.c:1281
unsigned short subi[3]
Definition: rand.c:32
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: vlc_fixups.h:519
unsigned if_index
Definition: vlc_fixups.h:520
char * if_name
Definition: vlc_fixups.h:521
Definition: vlc_fixups.h:151
long long rem
Definition: vlc_fixups.h:153
long long quot
Definition: vlc_fixups.h:152
Definition: vlc_fixups.h:209
long long ll
Definition: vlc_fixups.h:210
long double ld
Definition: vlc_fixups.h:211
Definition: vlc_fixups.h:498
int fd
Definition: vlc_fixups.h:499
short revents
Definition: vlc_fixups.h:501
short events
Definition: vlc_fixups.h:500
Definition: vlc_fixups.h:529
long tv_nsec
Definition: vlc_fixups.h:531
time_t tv_sec
Definition: vlc_fixups.h:530
This file is a collection of common definitions and types.
ssize_t recvmsg(int, struct msghdr *, int)
float strtof(const char *, char **)
void * tfind(const void *key, void *const *rootp, int(*cmp)(const void *, const void *))
int inet_pton(int, const char *, void *)
ssize_t readv(int, const struct iovec *, int)
int gettimeofday(struct timeval *, struct timezone *)
ssize_t getdelim(char **, size_t *, int, FILE *)
#define VLC_NOTHROW
Definition: vlc_fixups.h:204
double erand48(unsigned short subi[3])
int getc_unlocked(FILE *)
void * aligned_alloc(size_t, size_t)
static void freelocale(locale_t loc)
Definition: vlc_fixups.h:428
int posix_memalign(void **, size_t, size_t)
char * strdup(const char *)
lldiv_t lldiv(long long, long long)
void sincos(double, double *, double *)
int putc_unlocked(int, FILE *)
const char * inet_ntop(int, const void *, char *, socklen_t)
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:441
struct tm * localtime_r(const time_t *, struct tm *)
char * strnstr(const char *, const char *, size_t)
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 * realpath(const char *restrict pathname, char *restrict resolved_path)
long jrand48(unsigned short subi[3])
int timespec_get(struct timespec *, int)
size_t strlcpy(char *, const char *, size_t)
static char * getenv(const char *name)
Definition: vlc_fixups.h:380
ssize_t getline(char **, size_t *, FILE *)
static locale_t newlocale(int mask, const char *locale, locale_t base)
Definition: vlc_fixups.h:432
ssize_t writev(int, const struct iovec *, int)
void * lfind(const void *key, const void *base, size_t *nmemb, size_t size, int(*cmp)(const void *, const void *))
long long int strtoll(const char *, char **, int)
void * tdelete(const void *key, void **rootp, int(*cmp)(const void *, const void *))
void swab(const void *, void *, ssize_t)
int strcasecmp(const char *, const char *)
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
void * locale_t
Definition: vlc_fixups.h:426
int poll(struct pollfd *, unsigned, int)
void * tsearch(const void *key, void **rootp, int(*cmp)(const void *, const void *))
@ POLLRDBAND
Definition: vlc_fixups.h:491
@ POLLWRBAND
Definition: vlc_fixups.h:489
@ POLLPRI
Definition: vlc_fixups.h:492
@ POLLRDNORM
Definition: vlc_fixups.h:490
@ POLLHUP
Definition: vlc_fixups.h:486
@ POLLNVAL
Definition: vlc_fixups.h:487
@ POLLWRNORM
Definition: vlc_fixups.h:488
@ POLLERR
Definition: vlc_fixups.h:485
void tdestroy(void *root, void(*free_node)(void *nodep))
char * strndup(const char *, size_t)
char * strtok_r(char *, const char *, char **)
void * memrchr(const void *, int, size_t)
char * strcasestr(const char *, const char *)
struct tm * gmtime_r(const time_t *, struct tm *)
int strverscmp(const char *, const char *)
ssize_t sendmsg(int, const struct msghdr *, int)
size_t strnlen(const char *, size_t)
VISIT
Definition: vlc_fixups.h:584
@ postorder
Definition: vlc_fixups.h:586
@ leaf
Definition: vlc_fixups.h:588
@ endorder
Definition: vlc_fixups.h:587
@ preorder
Definition: vlc_fixups.h:585
int asprintf(char **, const char *,...)
int getchar_unlocked(void)
char * strsep(char **, const char *)