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#ifndef VIXL_GLOBALS_H
28#define VIXL_GLOBALS_H
29
30
31#ifndef __STDC_CONSTANT_MACROS
32#define __STDC_CONSTANT_MACROS
33#endif
34
35#ifndef __STDC_LIMIT_MACROS
36#define __STDC_LIMIT_MACROS
37#endif
38
39#ifndef __STDC_FORMAT_MACROS
40#define __STDC_FORMAT_MACROS
41#endif
42
43extern "C" {
44#include <inttypes.h>
45#include <stdint.h>
46}
47
48#include <cassert>
49#include <cstdarg>
50#include <cstddef>
51#include <cstdio>
52#include <cstdlib>
53
54#include "vixl/platform.h"
55
56
57typedef uint8_t byte;
58
59
60typedef uint16_t float16;
61
62const int KBytes = 1024;
63const int MBytes = 1024 * KBytes;
64
65#define VIXL_ABORT() \
66 do { printf("in %s, line %i", __FILE__, __LINE__); abort(); } while (false)
67#ifdef VIXL_DEBUG
68 #define VIXL_ASSERT(condition) assert(condition)
69 #define VIXL_CHECK(condition) VIXL_ASSERT(condition)
70 #define VIXL_UNIMPLEMENTED() \
71 do { fprintf(stderr, "UNIMPLEMENTED\t"); VIXL_ABORT(); } while (false)
72 #define VIXL_UNREACHABLE() \
73 do { fprintf(stderr, "UNREACHABLE\t"); VIXL_ABORT(); } while (false)
74#else
75 #define VIXL_ASSERT(condition) ((void) 0)
76 #define VIXL_CHECK(condition) assert(condition)
77 #define VIXL_UNIMPLEMENTED() ((void) 0)
78 #define VIXL_UNREACHABLE() ((void) 0)
79#endif
80
81
82
83#define VIXL_CONCAT(a, b) a##b
84#define VIXL_STATIC_ASSERT_LINE(line, condition) \
85 typedef char VIXL_CONCAT(STATIC_ASSERT_LINE_, line)[(condition) ? 1 : -1] \
86 __attribute__((unused))
87#define VIXL_STATIC_ASSERT(condition) \
88 VIXL_STATIC_ASSERT_LINE(__LINE__, condition)
89
90template <typename T1>
91inline void USE(T1) {}
92
93template <typename T1, typename T2>
94inline void USE(T1, T2) {}
95
96template <typename T1, typename T2, typename T3>
97inline void USE(T1, T2, T3) {}
98
99template <typename T1, typename T2, typename T3, typename T4>
100inline void USE(T1, T2, T3, T4) {}
101
102#define VIXL_ALIGNMENT_EXCEPTION() \
103 do { fprintf(stderr, "ALIGNMENT EXCEPTION\t"); VIXL_ABORT(); } while (0)
104
105
106
107
108
109#ifndef __has_warning
110 #define __has_warning(x) 0
111#endif
112
113
114#if __has_warning("-Wimplicit-fallthrough") && __cplusplus >= 201103L
115 #define VIXL_FALLTHROUGH() [[clang::fallthrough]]
116
117#elif __GNUC__ >= 7
118 #define VIXL_FALLTHROUGH() __attribute__((fallthrough))
119#else
120 #define VIXL_FALLTHROUGH() do {} while (0)
121#endif
122
123#if __cplusplus >= 201103L
124 #define VIXL_NO_RETURN [[noreturn]]
125#else
126 #define VIXL_NO_RETURN __attribute__((noreturn))
127#endif
128
129
130
131
132#ifdef VIXL_DEBUG
133 #define VIXL_DEBUG_NO_RETURN VIXL_NO_RETURN
134#else
135 #define VIXL_DEBUG_NO_RETURN
136#endif
137
138#ifdef VIXL_INCLUDE_SIMULATOR
139#ifndef VIXL_GENERATE_SIMULATOR_INSTRUCTIONS_VALUE
140 #define VIXL_GENERATE_SIMULATOR_INSTRUCTIONS_VALUE 1
141#endif
142#else
143#ifndef VIXL_GENERATE_SIMULATOR_INSTRUCTIONS_VALUE
144 #define VIXL_GENERATE_SIMULATOR_INSTRUCTIONS_VALUE 0
145#endif
146#if VIXL_GENERATE_SIMULATOR_INSTRUCTIONS_VALUE
147 #warning "Generating Simulator instructions without Simulator support."
148#endif
149#endif
150
151#ifdef USE_SIMULATOR
152 #error "Please see the release notes for USE_SIMULATOR."
153#endif
154
155#endif
156