forked from andoma/movian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.h
114 lines (88 loc) · 2.43 KB
/
compiler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Copyright (C) 2007-2015 Lonelycoder AB
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http:https://www.gnu.org/licenses/>.
*
* This program is also available under a commercial proprietary license.
* For more information, contact [email protected]
*/
#pragma once
#ifdef _MSC_VER
#define attribute_printf(a, b)
#else
#define attribute_printf(a, b) __attribute__((format(printf, a, b)))
#endif
#ifdef _MSC_VER
#define attribute_malloc
#else
#define attribute_malloc __attribute__((malloc))
#endif
#ifdef _MSC_VER
#define attribute_noreturn
#else
#define attribute_noreturn __attribute__((noreturn))
#endif
#ifdef _MSC_VER
#define attribute_unused_result
#else
#define attribute_unused_result __attribute__((warn_unused_result))
#endif
#ifdef _MSC_VER
#define attribute_null_sentinel
#else
#define attribute_null_sentinel __attribute__((__sentinel__(0)))
#endif
#ifdef _MSC_VER
#define attribute_unused
#else
#define attribute_unused __attribute__((unused))
#endif
#ifdef _MSC_VER
#define strdup _strdup
#define alloca _alloca
#define __builtin_constant_p(x) 0
#define snprintf sprintf_s
#define strtok_r strtok_s
#endif
#ifdef _MSC_VER
#pragma section(".CRT$XCU",read)
#define INITIALIZER(f) \
static void __cdecl f(void); \
__declspec(allocate(".CRT$XCU")) void (__cdecl*f##_)(void) = f; \
static void __cdecl f(void)
#elif defined(__GNUC__)
#define INITIALIZER(f) \
static void f(void) __attribute__((constructor)); \
static void f(void)
#endif
#define HTS_GLUE(a, b) a ## b
#define HTS_JOIN(a, b) HTS_GLUE(a, b)
#ifndef _MSC_VER
#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#ifdef __GNUC__
#ifndef likely
#define likely(x) __builtin_expect((x),1)
#endif
#ifndef unlikely
#define unlikely(x) __builtin_expect((x),0)
#endif
#else
#ifndef likely
#define likely(x) (x)
#endif
#ifndef unlikely
#define unlikely(x) (x)
#endif
#endif