diff --git a/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/darling/emulation/tsd.h b/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/darling/emulation/tsd.h new file mode 120000 index 000000000..c8d01cfe0 --- /dev/null +++ b/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/darling/emulation/tsd.h @@ -0,0 +1 @@ +../../../../../../../../../../src/external/xnu/darling/src/libsystem_kernel/emulation/linux/tsd.h \ No newline at end of file diff --git a/src/external/libpthread b/src/external/libpthread index 1cdf76eab..f07f265bf 160000 --- a/src/external/libpthread +++ b/src/external/libpthread @@ -1 +1 @@ -Subproject commit 1cdf76eab5b283fc282dbe605eb632da6e3a6e68 +Subproject commit f07f265bfbcf071c1adfc808de971e053ea5edc5 diff --git a/src/external/xnu b/src/external/xnu index b2bd57725..99020685f 160000 --- a/src/external/xnu +++ b/src/external/xnu @@ -1 +1 @@ -Subproject commit b2bd57725b78e715b6cf396d451ca29a68e77748 +Subproject commit 99020685f14fd3f7a9466fc692f16ecf440f3f39 diff --git a/src/xtrace/tls.cpp b/src/xtrace/tls.cpp index 980a9ea00..1ccfd97c9 100644 --- a/src/xtrace/tls.cpp +++ b/src/xtrace/tls.cpp @@ -27,16 +27,16 @@ struct tls_table { }; // since we still need to handle some calls after pthread_terminate is called and libpthread unwinds its TLS right before calling pthread_terminate, -// we have to use a slightly hackier technique: using one of the system's reserved but unused TLS keys. -// key 200 seems like a good fit; it's in the reserved region but it's not currently listed in `pthread/tsd_private.h` as being in-use by anything. +// we have to use a slightly hackier technique: using one of the system's reserved but unused TLS keys; we use one from the range we currently reserve +// for Darling. -#define __PTK_XTRACE_TLS 200 +#include // TODO: also perform TLS cleanup for other threads when doing a fork extern "C" void xtrace_tls_thread_cleanup(void) { - tls_table_t table = (tls_table_t)_pthread_getspecific_direct(__PTK_XTRACE_TLS); + tls_table_t table = (tls_table_t)_pthread_getspecific_direct(__PTK_DARLING_XTRACE_TLS); if (!table) { xtrace_tls_debug("no table to cleanup for this thread"); return; @@ -58,7 +58,7 @@ extern "C" void* xtrace_tls(void* key, size_t size, bool* created, xtrace_tls_destructor_f destructor) { xtrace_tls_debug("looking up tls variable for key %p", key); - tls_table_t table = (tls_table_t)_pthread_getspecific_direct(__PTK_XTRACE_TLS); + tls_table_t table = (tls_table_t)_pthread_getspecific_direct(__PTK_DARLING_XTRACE_TLS); xtrace_tls_debug("got %p as table pointer from pthread", table); @@ -70,7 +70,7 @@ void* xtrace_tls(void* key, size_t size, bool* created, xtrace_tls_destructor_f xtrace_abort("xtrace: failed TLS table memory allocation"); } table->size = 0; - _pthread_setspecific_direct(__PTK_XTRACE_TLS, table); + _pthread_setspecific_direct(__PTK_DARLING_XTRACE_TLS, table); } // check if the key is already present