static cma__t_int_tcb * find_tcb (ptid_t ptid) { cma__t_known_object queue_header; cma__t_queue *queue_ptr; int thread = ptid_get_tid (ptid); if (thread == cached_thread) return &cached_tcb; read_memory ((CORE_ADDR) P_cma__g_known_threads, (char *) &queue_header, sizeof queue_header); for (queue_ptr = queue_header.queue.flink; queue_ptr != (cma__t_queue *) P_cma__g_known_threads; queue_ptr = cached_tcb.threads.flink) { cma__t_int_tcb *tcb_ptr; tcb_ptr = cma__base (queue_ptr, threads, cma__t_int_tcb); read_memory ((CORE_ADDR) tcb_ptr, (char *) &cached_tcb, sizeof cached_tcb); if (cached_tcb.header.type == cma__c_obj_tcb) if (cma_thread_get_unique (&cached_tcb.prolog.client_thread) == thread) { cached_thread = thread; return &cached_tcb; } } error (_("Can't find TCB %d"), thread); return NULL; }
void* GThread::current() { pthread_t self = pthread_self(); #if defined(pthread_getunique_np) return (void*) pthread_getunique_np( & self ); #elif defined(cma_thread_get_unique) return (void*) cma_thread_get_unique( & self ); #else return (void*) self; #endif }
static ptid_t find_active_thread (void) { static cma__t_int_tcb tcb; CORE_ADDR tcb_ptr; read_memory ((CORE_ADDR) P_cma__g_current_thread, (char *) &tcb_ptr, sizeof tcb_ptr); read_memory (tcb_ptr, (char *) &tcb, sizeof tcb); return (ptid_build (PIDGET (main_ptid), 0, cma_thread_get_unique (&tcb.prolog.client_thread))); }