MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / SetupTSOEmulation

Function SetupTSOEmulation

Source/Tools/FEXLoader/FEXLoader.cpp:166–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165namespace FEX::TSO {
166void SetupTSOEmulation(FEXCore::Context::Context* CTX) {
167 // We need to check if these are defined or not. This is a very fresh feature.
168#ifndef PR_GET_MEM_MODEL
169#define PR_GET_MEM_MODEL 0x6d4d444c
170#endif
171#ifndef PR_SET_MEM_MODEL
172#define PR_SET_MEM_MODEL 0x4d4d444c
173#endif
174#ifndef PR_SET_MEM_MODEL_DEFAULT
175#define PR_SET_MEM_MODEL_DEFAULT 0
176#endif
177#ifndef PR_SET_MEM_MODEL_TSO
178#define PR_SET_MEM_MODEL_TSO 1
179#endif
180 // Check to see if this is supported.
181 auto Result = prctl(PR_GET_MEM_MODEL, 0, 0, 0, 0);
182 if (Result == -1) {
183 // Unsupported, early exit.
184 return;
185 }
186
187 FEX_CONFIG_OPT(TSOEnabled, TSOENABLED);
188
189 if (!TSOEnabled()) {
190 // TSO emulation isn't even enabled, early exit.
191 return;
192 }
193
194 if (Result == PR_SET_MEM_MODEL_DEFAULT) {
195 // Try to set the TSO mode if we are currently default.
196 Result = prctl(PR_SET_MEM_MODEL, PR_SET_MEM_MODEL_TSO, 0, 0, 0);
197 if (Result == 0) {
198 // TSO mode successfully enabled. Tell the context to disable TSO emulation through atomics.
199 // This flag gets inherited on thread creation, so FEX only needs to set it at the start.
200 CTX->SetHardwareTSOSupport(true);
201 }
202 }
203}
204} // namespace FEX::TSO
205
206namespace FEX::CompatInput {

Callers 1

mainFunction · 0.85

Calls 1

SetHardwareTSOSupportMethod · 0.80

Tested by

no test coverage detected