-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathos.h
More file actions
263 lines (222 loc) · 6.19 KB
/
os.h
File metadata and controls
263 lines (222 loc) · 6.19 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// Copyright (C) 2017-2018 Egor Pugin <[email protected]>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include "platform.h"
#include <sw/manager/version.h>
namespace sw
{
// Some system headers or GCC predefined macros conflict with identifiers in
// this file. Undefine them here.
#undef NetBSD
#undef mips
#undef sparc
// from Modules/CMakeDetermineSystem.cmake
enum class OSType
{
UnknownOS,
AIX,
Android,
BSD_OS,
Cygwin,
FreeBSD,
HP_UX,
IRIX,
Linux,
GNU_kFreeBSD,
NetBSD,
OpenBSD,
OFS1,
SCO_OpenServer5,
SCO_UnixWare7,
SCO_UnixWare_pre7,
SCO_XENIX,
Solaris,
SunOS,
Tru64,
Ultrix,
Windows,
WindowsCE,
// add apple's tvos/watchos etc.
Darwin,
Macos,
IOS,
};
// from llvm/ADT/Triple.h
enum class ArchType
{
UnknownArch,
arm, // ARM (little endian): arm, armv.*, xscale
armeb, // ARM (big endian): armeb
aarch64, // AArch64 (little endian): aarch64
aarch64_be, // AArch64 (big endian): aarch64_be
avr, // AVR: Atmel AVR microcontroller
bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
hexagon, // Hexagon: hexagon
mips, // MIPS: mips, mipsallegrex
mipsel, // MIPSEL: mipsel, mipsallegrexel
mips64, // MIPS64: mips64
mips64el, // MIPS64EL: mips64el
msp430, // MSP430: msp430
nios2, // NIOSII: nios2
ppc, // PPC: powerpc
ppc64, // PPC64: powerpc64, ppu
ppc64le, // PPC64LE: powerpc64le
r600, // R600: AMD GPUs HD2XXX - HD6XXX
amdgcn, // AMDGCN: AMD GCN GPUs
riscv32, // RISC-V (32-bit): riscv32
riscv64, // RISC-V (64-bit): riscv64
sparc, // Sparc: sparc
sparcv9, // Sparcv9: Sparcv9
sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
systemz, // SystemZ: s390x
tce, // TCE (http://tce.cs.tut.fi/): tce
tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
thumb, // Thumb (little endian): thumb, thumbv.*
thumbeb, // Thumb (big endian): thumbeb
x86, // X86: i[3-9]86
x86_64, // X86-64: amd64, x86_64
xcore, // XCore: xcore
nvptx, // NVPTX: 32-bit
nvptx64, // NVPTX: 64-bit
le32, // le32: generic little-endian 32-bit CPU (PNaCl)
le64, // le64: generic little-endian 64-bit CPU (PNaCl)
amdil, // AMDIL
amdil64, // AMDIL with 64-bit pointers
hsail, // AMD HSAIL
hsail64, // AMD HSAIL with 64-bit pointers
spir, // SPIR: standard portable IR for OpenCL 32-bit version
spir64, // SPIR: standard portable IR for OpenCL 64-bit version
kalimba, // Kalimba: generic kalimba
shave, // SHAVE: Movidius vector VLIW processors
lanai, // Lanai: Lanai 32-bit
wasm32, // WebAssembly with 32-bit pointers
wasm64, // WebAssembly with 64-bit pointers
renderscript32, // 32-bit RenderScript
renderscript64, // 64-bit RenderScript
};
// from llvm/ADT/Triple.h
enum class SubArchType
{
NoSubArch,
ARMSubArch_v8_2a,
ARMSubArch_v8_1a,
ARMSubArch_v8,
ARMSubArch_v8r,
ARMSubArch_v8m_baseline,
ARMSubArch_v8m_mainline,
ARMSubArch_v7,
ARMSubArch_v7em,
ARMSubArch_v7m,
ARMSubArch_v7s,
ARMSubArch_v7k,
ARMSubArch_v7ve,
ARMSubArch_v6,
ARMSubArch_v6m,
ARMSubArch_v6k,
ARMSubArch_v6t2,
ARMSubArch_v5,
ARMSubArch_v5te,
ARMSubArch_v4t,
KalimbaSubArch_v3,
KalimbaSubArch_v4,
KalimbaSubArch_v5
};
// from llvm/ADT/Triple.h
enum class EnvironmentType
{
UnknownEnvironment,
GNU,
GNUABI64,
GNUEABI,
GNUEABIHF,
GNUX32,
CODE16,
EABI,
EABIHF,
Android,
Musl,
MuslEABI,
MuslEABIHF,
MSVC,
Itanium,
Cygnus,
AMDOpenCL,
CoreCLR,
OpenCL,
};
// from llvm/ADT/Triple.h
enum class ObjectFormatType
{
UnknownObjectFormat,
COFF,
ELF,
MachO,
Wasm,
};
enum class ShellType
{
UnknownShell,
Batch,
Bat = Batch,
Shell,
Sh = Shell,
};
SW_BUILDER_API
String toString(OSType e);
SW_BUILDER_API
String toString(ArchType e);
SW_BUILDER_API
String toStringWindows(ArchType e);
SW_BUILDER_API
String toString(SubArchType e);
SW_BUILDER_API
String toString(EnvironmentType e);
SW_BUILDER_API
String toString(ObjectFormatType e);
SW_BUILDER_API
String toTripletString(OSType e);
SW_BUILDER_API
String toTripletString(ArchType e);
SW_BUILDER_API
String toTripletString(SubArchType e);
struct SW_BUILDER_API OS
{
OSType Type = OSType::UnknownOS;
ArchType Arch = ArchType::UnknownArch;
SubArchType SubArch = SubArchType::NoSubArch;
EnvironmentType EnvironmentType1 = EnvironmentType::UnknownEnvironment;
ObjectFormatType ObjectFormatType1 = ObjectFormatType::UnknownObjectFormat;
::primitives::version::Version Version;
// TODO:
bool support_dynamic_loading = true;
bool is(OSType t) const { return Type == t; }
bool isApple() const;
bool is(ArchType t) const { return Arch == t; }
bool is(SubArchType t) const { return SubArch == t; }
bool is(EnvironmentType t) const { return EnvironmentType1 == t; }
bool is(ObjectFormatType t) const { return ObjectFormatType1 == t; }
// rename?
bool canRunTargetExecutables(const OS &target_os) const;
String getExecutableExtension() const;
String getStaticLibraryExtension() const;
String getSharedLibraryExtension() const;
String getObjectFileExtension() const;
String getLibraryPrefix() const;
String getShellExtension() const;
ShellType getShellType() const;
bool operator<(const OS &rhs) const;
bool operator==(const OS &rhs) const;
};
SW_BUILDER_API
const OS &getHostOS();
// hidden
namespace detail
{
SW_BUILDER_API
bool isHostCygwin();
}
}