Skip to content

Commit 4245475

Browse files
committed
Detect if we have valid pthread_jit_write_protect_np
1 parent 67deee7 commit 4245475

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

qemu/configure

+28-1
Original file line numberDiff line numberDiff line change
@@ -2139,13 +2139,40 @@ fi
21392139
if [ "$darwin" = "yes" ] ; then
21402140
cat > $TMPC << EOF
21412141
#include <pthread.h>
2142-
int main() { pthread_jit_write_protect_np(0); return 0; }
2142+
int main() { pthread_jit_write_protect_np(0); return 0;}
21432143
EOF
21442144
if ! compile_prog ""; then
21452145
have_pthread_jit_protect='no'
21462146
else
21472147
have_pthread_jit_protect='yes'
21482148
fi
2149+
2150+
if test "$have_pthread_jit_protect" = "yes" ; then
2151+
cat > $TMPC << EOF
2152+
#include "stdint.h"
2153+
int main() {
2154+
uint64_t commpage_sprr = (*(uint64_t*)0xFFFFFC10C);
2155+
2156+
// In Apple Hypervisor, this value is not accessbile and
2157+
// pthread_jit_write_protect_np essentially is a no-op
2158+
if (!commpage_sprr) {
2159+
return 1;
2160+
} else {
2161+
return 0;
2162+
}
2163+
}
2164+
EOF
2165+
if ! compile_prog ""; then
2166+
have_pthread_jit_protect='no'
2167+
else
2168+
$TMPE
2169+
if [ $? -eq 0 ]; then
2170+
have_pthread_jit_protect='yes'
2171+
else
2172+
have_pthread_jit_protect='no'
2173+
fi
2174+
fi
2175+
fi
21492176
fi
21502177

21512178
##########################################

0 commit comments

Comments
 (0)