1 /*
2  *  Tvheadend - structures
3  *  Copyright (C) 2007 Andreas Öman
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef TVH_COMPAT_H
19 #define TVH_COMPAT_H
20 
21 #if ENABLE_ANDROID
22 #ifndef index
23 #define index(...) strchr(__VA_ARGS__)
24 #endif
25 #ifndef pthread_yield
26 #define pthread_yield() sched_yield()
27 #endif
28 #define S_IEXEC S_IXUSR
29 #include <time64.h>
30 // 32-bit Android has only timegm64() and not timegm().
31 // We replicate the behaviour of timegm() when the result overflows time_t.
32 
33 #endif /* ENABLE_ANDROID */
34 
35 #ifndef ENABLE_EPOLL_CREATE1
36 #define epoll_create1(EPOLL_CLOEXEC) epoll_create(n)
37 #endif
38 #ifndef ENABLE_INOTIFY_INIT1
39 #define inotify_init1(IN_CLOEXEC) inotify_init()
40 #endif
41 
42 #if (defined(PLATFORM_DARWIN) || defined(PLATFORM_FREEBSD)) && !defined(MSG_MORE)
43 #define MSG_MORE 0
44 #endif
45 
46 #endif /* TVH_COMPAT_H */
47 
48 #ifdef COMPAT_IPTOS
49 
50 #ifndef IPTOS_DSCP_MASK
51 #define	IPTOS_DSCP_MASK		0xfc
52 #endif
53 #ifndef IPTOS_DSCP
54 #define	IPTOS_DSCP(x)		((x) & IPTOS_DSCP_MASK)
55 #endif
56 #ifndef IPTOS_DSCP_AF11
57 #define	IPTOS_DSCP_AF11		0x28
58 #define	IPTOS_DSCP_AF12		0x30
59 #define	IPTOS_DSCP_AF13		0x38
60 #define	IPTOS_DSCP_AF21		0x48
61 #define	IPTOS_DSCP_AF22		0x50
62 #define	IPTOS_DSCP_AF23		0x58
63 #define	IPTOS_DSCP_AF31		0x68
64 #define	IPTOS_DSCP_AF32		0x70
65 #define	IPTOS_DSCP_AF33		0x78
66 #define	IPTOS_DSCP_AF41		0x88
67 #define	IPTOS_DSCP_AF42		0x90
68 #define	IPTOS_DSCP_AF43		0x98
69 #define	IPTOS_DSCP_EF		0xb8
70 #endif
71 
72 #ifndef IPTOS_CLASS_MASK
73 #define	IPTOS_CLASS_MASK	0xe0
74 #endif
75 #ifndef IPTOS_CLASS
76 #define	IPTOS_CLASS(class)	((class) & IPTOS_CLASS_MASK)
77 #endif
78 #ifndef IPTOS_CLASS_CS0
79 #define	IPTOS_CLASS_CS0		0x00
80 #define	IPTOS_CLASS_CS1		0x20
81 #define	IPTOS_CLASS_CS2		0x40
82 #define	IPTOS_CLASS_CS3		0x60
83 #define	IPTOS_CLASS_CS4		0x80
84 #define	IPTOS_CLASS_CS5		0xa0
85 #define	IPTOS_CLASS_CS6		0xc0
86 #define	IPTOS_CLASS_CS7		0xe0
87 #endif
88 
89 #define	IPTOS_CLASS_DEFAULT	IPTOS_CLASS_CS0
90 
91 #endif /* COMPAT_IPTOS */
92 
93