PPU: Cleanup MacOs executable write protection guards
This commit is contained in:
+25
-3
@@ -434,13 +434,35 @@ namespace asmjit
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
struct jit_write_guard
|
||||
{
|
||||
jit_write_guard() noexcept
|
||||
{
|
||||
pthread_jit_write_protect_np(false);
|
||||
|
||||
// Ensure stores are not reordered by the compiler
|
||||
atomic_fence_acq_rel();
|
||||
}
|
||||
|
||||
~jit_write_guard() noexcept
|
||||
{
|
||||
// Ensure stores are not reordered by the compiler
|
||||
atomic_fence_seq_cst();
|
||||
|
||||
pthread_jit_write_protect_np(true);
|
||||
}
|
||||
};
|
||||
#else
|
||||
#define jit_write_guard [[maybe_unused]] int
|
||||
#endif
|
||||
|
||||
// Build runtime function with asmjit::X86Assembler
|
||||
template <typename FT, typename Asm = native_asm, typename F>
|
||||
inline FT build_function_asm(std::string_view name, F&& builder, ::jit_runtime* custom_runtime = nullptr, bool reduced_size = false)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
pthread_jit_write_protect_np(false);
|
||||
#endif
|
||||
jit_write_guard jit_guard;
|
||||
|
||||
using namespace asmjit;
|
||||
|
||||
auto& rt = custom_runtime ? *custom_runtime : get_global_runtime();
|
||||
|
||||
Reference in New Issue
Block a user