Skip to content

Commit

Permalink
Use pthread_jit_write_protect_supported_np as a guard instead of just…
Browse files Browse the repository at this point in the history
… exiting when it returns false.
  • Loading branch information
vnmakarov committed Feb 1, 2024
1 parent 003505d commit c911cb9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mir.c
Original file line number Diff line number Diff line change
Expand Up @@ -4322,13 +4322,10 @@ static int mem_protect (void *addr, size_t len, int prot) {
#if !defined(__APPLE__) || !defined(__aarch64__)
return mprotect (addr, len, prot);
#else
if (!pthread_jit_write_protect_supported_np ()) {
fprintf (stderr, "unsupported pthread_jit_write_protect_np -- good bye!\n");
exit (1);
}
if (prot & PROT_WRITE) pthread_jit_write_protect_np (FALSE);
if ((prot & PROT_WRITE) && pthread_jit_write_protect_supported_np ())
pthread_jit_write_protect_np (FALSE);
if (prot & PROT_READ) {
pthread_jit_write_protect_np (TRUE);
if (pthread_jit_write_protect_supported_np ()) pthread_jit_write_protect_np (TRUE);
sys_icache_invalidate (addr, len);
} else if (0) {
if (mprotect (addr, len, prot) != 0) {
Expand Down

0 comments on commit c911cb9

Please sign in to comment.