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