mirror of
https://codeberg.org/wownero/RandomX.git
synced 2026-10-17 05:41:32 +02:00
Faster W^X policy for apple silicon macs
This commit is contained in:
@@ -35,6 +35,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
#include <mach/vm_statistics.h>
|
||||
#include <TargetConditionals.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
@@ -129,11 +131,19 @@ static inline void pageProtect(void* ptr, std::size_t bytes, int rules) {
|
||||
}
|
||||
|
||||
void setPagesRW(void* ptr, std::size_t bytes) {
|
||||
#if defined(__APPLE__) && defined(__aarch64__) && TARGET_OS_OSX
|
||||
pthread_jit_write_protect_np(false);
|
||||
#else
|
||||
pageProtect(ptr, bytes, PAGE_READWRITE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setPagesRX(void* ptr, std::size_t bytes) {
|
||||
#if defined(__APPLE__) && defined(__aarch64__) && TARGET_OS_OSX
|
||||
pthread_jit_write_protect_np(true);
|
||||
#else
|
||||
pageProtect(ptr, bytes, PAGE_EXECUTE_READ);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setPagesRWX(void* ptr, std::size_t bytes) {
|
||||
|
||||
Reference in New Issue
Block a user