Detect if we have valid pthread_jit_write_protect_np

This commit is contained in:
lazymio 2024-02-13 16:21:53 +08:00
parent 67deee7771
commit 4245475514
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873

29
qemu/configure vendored
View File

@ -2139,13 +2139,40 @@ fi
if [ "$darwin" = "yes" ] ; then
cat > $TMPC << EOF
#include <pthread.h>
int main() { pthread_jit_write_protect_np(0); return 0; }
int main() { pthread_jit_write_protect_np(0); return 0;}
EOF
if ! compile_prog ""; then
have_pthread_jit_protect='no'
else
have_pthread_jit_protect='yes'
fi
if test "$have_pthread_jit_protect" = "yes" ; then
cat > $TMPC << EOF
#include "stdint.h"
int main() {
uint64_t commpage_sprr = (*(uint64_t*)0xFFFFFC10C);
// In Apple Hypervisor, this value is not accessbile and
// pthread_jit_write_protect_np essentially is a no-op
if (!commpage_sprr) {
return 1;
} else {
return 0;
}
}
EOF
if ! compile_prog ""; then
have_pthread_jit_protect='no'
else
$TMPE
if [ $? -eq 0 ]; then
have_pthread_jit_protect='yes'
else
have_pthread_jit_protect='no'
fi
fi
fi
fi
##########################################