* Copyright 2015 Xamarin, Inc (http://www.xamarin.com)
*/
+#include <config.h>
+
+/* enable pthread extensions */
+#ifdef TARGET_MACH
+#define _DARWIN_C_SOURCE
+#endif
+
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-semaphore.h>
#include <mono/utils/mono-threads.h>
void
mono_threads_platform_free (MonoThreadInfo *info)
{
-#ifdef TARGET_OSX
+#ifdef TARGET_MACH
mach_port_deallocate (current_task (), info->native_handle);
#endif
void
mono_threads_platform_register (MonoThreadInfo *info)
{
-#ifdef TARGET_OSX
+#ifdef TARGET_MACH
+ char thread_name [64];
+
info->native_handle = mach_thread_self ();
+ snprintf (thread_name, 64, "tid_%x", (int)info->native_handle);
+ pthread_setname_np (thread_name);
#endif
//See the above for what's wrong here.
#include <config.h>
+/* enable pthread extensions */
+#ifdef TARGET_MACH
+#define _DARWIN_C_SOURCE
+#endif
+
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-semaphore.h>
#include <mono/utils/mono-threads.h>
MOSTLY_ASYNC_SAFE_PRINTF ("\t0x?08\t- blocking with pending suspend (GOOD)\n");
FOREACH_THREAD_SAFE (info) {
+#ifdef TARGET_MACH
+ char thread_name [256] = { 0 };
+ pthread_getname_np (mono_thread_info_get_tid (info), thread_name, 255);
+
+ MOSTLY_ASYNC_SAFE_PRINTF ("--thread %p id %p [%p] (%s) state %x %s\n", info, (void *) mono_thread_info_get_tid (info), (void*)(size_t)info->native_handle, thread_name, info->thread_state, info == cur ? "GC INITIATOR" : "" );
+#else
MOSTLY_ASYNC_SAFE_PRINTF ("--thread %p id %p [%p] state %x %s\n", info, (void *) mono_thread_info_get_tid (info), (void*)(size_t)info->native_handle, info->thread_state, info == cur ? "GC INITIATOR" : "" );
+#endif
+
} END_FOREACH_THREAD_SAFE
}