Lines Matching refs:ptd

44     _pthread_data_t *ptd;  in _pthread_get_data()  local
49 ptd = pth_table[thread]; in _pthread_get_data()
52 if (ptd && ptd->magic == PTHREAD_MAGIC) return ptd; in _pthread_get_data()
75 pthread_t _pthread_data_get_pth(_pthread_data_t *ptd) in _pthread_data_get_pth() argument
82 if (pth_table[index] == ptd) break; in _pthread_data_get_pth()
112 _pthread_data_t *ptd = NULL; in _pthread_data_create() local
114 ptd = (_pthread_data_t*)rt_malloc(sizeof(_pthread_data_t)); in _pthread_data_create()
115 if (!ptd) return PTHREAD_NUM_MAX; in _pthread_data_create()
117 memset(ptd, 0x0, sizeof(_pthread_data_t)); in _pthread_data_create()
118 ptd->canceled = 0; in _pthread_data_create()
119 ptd->cancelstate = PTHREAD_CANCEL_DISABLE; in _pthread_data_create()
120 ptd->canceltype = PTHREAD_CANCEL_DEFERRED; in _pthread_data_create()
121 ptd->magic = PTHREAD_MAGIC; in _pthread_data_create()
128 pth_table[index] = ptd; in _pthread_data_create()
137 ptd->magic = 0x0; in _pthread_data_create()
138 rt_free(ptd); in _pthread_data_create()
162 static inline void _destroy_item(int index, _pthread_data_t *ptd) in _destroy_item() argument
169 data = ptd->tls[index]; in _destroy_item()
205 void _pthread_data_destroy(_pthread_data_t *ptd) in _pthread_data_destroy() argument
209 if (ptd) in _pthread_data_destroy()
214 if (ptd->tls != RT_NULL) in _pthread_data_destroy()
233 _destroy_item(index, ptd); in _pthread_data_destroy()
244 _destroy_item(index, ptd); in _pthread_data_destroy()
248 rt_free(ptd->tls); in _pthread_data_destroy()
249 ptd->tls = RT_NULL; in _pthread_data_destroy()
252 pth = _pthread_data_get_pth(ptd); in _pthread_data_destroy()
259 if (ptd->joinable_sem != RT_NULL) in _pthread_data_destroy()
261 rt_sem_delete(ptd->joinable_sem); in _pthread_data_destroy()
262 ptd->joinable_sem = RT_NULL; in _pthread_data_destroy()
266 ptd->magic = 0x0; in _pthread_data_destroy()
269 rt_free(ptd); in _pthread_data_destroy()
331 _pthread_data_t *ptd; in pthread_entry_stub() local
333 ptd = (_pthread_data_t *)parameter; in pthread_entry_stub()
336 value = ptd->thread_entry(ptd->thread_parameter); in pthread_entry_stub()
339 if (ptd->attr.detachstate == PTHREAD_CREATE_JOINABLE) in pthread_entry_stub()
342 ptd->return_value = value; in pthread_entry_stub()
343 rt_sem_release(ptd->joinable_sem); in pthread_entry_stub()
348 _pthread_data_destroy(ptd); in pthread_entry_stub()
398 _pthread_data_t *ptd; in pthread_create() local
411 ptd = _pthread_get_data(pth_id); in pthread_create()
413 RT_ASSERT(ptd != RT_NULL); in pthread_create()
417 ptd->attr = *attr; in pthread_create()
422 pthread_attr_init(&ptd->attr); in pthread_create()
425 if (ptd->attr.stacksize == 0) in pthread_create()
434 ptd->tid = (rt_thread_t) rt_malloc(sizeof(struct rt_thread)); in pthread_create()
435 if (ptd->tid == RT_NULL) in pthread_create()
440 memset(ptd->tid, 0, sizeof(struct rt_thread)); in pthread_create()
442 if (ptd->attr.detachstate == PTHREAD_CREATE_JOINABLE) in pthread_create()
444 ptd->joinable_sem = rt_sem_create(name, 0, RT_IPC_FLAG_FIFO); in pthread_create()
445 if (ptd->joinable_sem == RT_NULL) in pthread_create()
453 ptd->joinable_sem = RT_NULL; in pthread_create()
457 ptd->thread_entry = start; in pthread_create()
458 ptd->thread_parameter = parameter; in pthread_create()
461 if (ptd->attr.stackaddr == 0) in pthread_create()
463 stack = (void *)rt_malloc(ptd->attr.stacksize); in pthread_create()
467 stack = (void *)(ptd->attr.stackaddr); in pthread_create()
477 if (rt_thread_init(ptd->tid, name, pthread_entry_stub, ptd, in pthread_create()
478 stack, ptd->attr.stacksize, in pthread_create()
479 ptd->attr.schedparam.sched_priority, 20) != RT_EOK) in pthread_create()
489 ptd->tid->cleanup = _pthread_cleanup; in pthread_create()
490 ptd->tid->pthread_data = (void *)ptd; in pthread_create()
493 if (rt_thread_startup(ptd->tid) == RT_EOK) in pthread_create()
497 rt_thread_detach(ptd->tid); in pthread_create()
503 _pthread_data_destroy(ptd); in pthread_create()
536 _pthread_data_t *ptd = _pthread_get_data(thread); in pthread_detach() local
537 if (ptd == RT_NULL) in pthread_detach()
544 if (ptd->attr.detachstate == PTHREAD_CREATE_DETACHED) in pthread_detach()
553 if ((RT_SCHED_CTX(ptd->tid).stat & RT_THREAD_STAT_MASK) == RT_THREAD_CLOSE) in pthread_detach()
556 _pthread_data_destroy(ptd); in pthread_detach()
562 ptd->attr.detachstate = PTHREAD_CREATE_DETACHED; in pthread_detach()
565 if (ptd->joinable_sem) in pthread_detach()
567 rt_sem_delete(ptd->joinable_sem); in pthread_detach()
568 ptd->joinable_sem = RT_NULL; in pthread_detach()
606 _pthread_data_t *ptd; in pthread_join() local
609 ptd = _pthread_get_data(thread); in pthread_join()
611 if (ptd == RT_NULL) in pthread_join()
616 if (ptd->tid == rt_thread_self()) in pthread_join()
622 if (ptd->attr.detachstate == PTHREAD_CREATE_DETACHED) in pthread_join()
627 result = rt_sem_take(ptd->joinable_sem, RT_WAITING_FOREVER); in pthread_join()
632 *value_ptr = ptd->return_value; in pthread_join()
635 _pthread_data_destroy(ptd); in pthread_join()
668 _pthread_data_t *ptd; in pthread_self() local
674 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; in pthread_self()
675 RT_ASSERT(ptd != RT_NULL); in pthread_self()
677 return _pthread_data_get_pth(ptd); in pthread_self()
824 _pthread_data_t *ptd; in pthread_getschedparam() local
826 ptd = _pthread_get_data(thread); in pthread_getschedparam()
827 pthread_attr_getschedpolicy(&ptd->attr, policy); in pthread_getschedparam()
828 pthread_attr_getschedparam(&ptd->attr, param); in pthread_getschedparam()
877 _pthread_data_t *ptd; in pthread_setschedparam() local
879 ptd = _pthread_get_data(thread); in pthread_setschedparam()
880 pthread_attr_setschedpolicy(&ptd->attr, policy); in pthread_setschedparam()
881 pthread_attr_setschedparam(&ptd->attr, param); in pthread_setschedparam()
918 _pthread_data_t *ptd; in pthread_setschedprio() local
921 ptd = _pthread_get_data(thread); in pthread_setschedprio()
923 pthread_attr_setschedparam(&ptd->attr, &param); in pthread_setschedprio()
949 _pthread_data_t *ptd; in pthread_exit() local
959 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; in pthread_exit()
963 ptd->cancelstate = PTHREAD_CANCEL_DISABLE; in pthread_exit()
965 ptd->return_value = value; in pthread_exit()
972 while (ptd->cleanup != RT_NULL) in pthread_exit()
974 cleanup = ptd->cleanup; in pthread_exit()
975 ptd->cleanup = cleanup->next; in pthread_exit()
983 tid = ptd->tid; in pthread_exit()
986 if (ptd->attr.detachstate == PTHREAD_CREATE_JOINABLE) in pthread_exit()
989 rt_sem_release(ptd->joinable_sem); in pthread_exit()
994 _pthread_data_destroy(ptd); in pthread_exit()
1096 _pthread_data_t *ptd; in pthread_kill() local
1099 ptd = _pthread_get_data(thread); in pthread_kill()
1100 if (ptd) in pthread_kill()
1102 ret = rt_thread_kill(ptd->tid, sig); in pthread_kill()
1177 _pthread_data_t *ptd; in pthread_cleanup_pop() local
1183 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; in pthread_cleanup_pop()
1184 RT_ASSERT(ptd != RT_NULL); in pthread_cleanup_pop()
1189 cleanup = ptd->cleanup; in pthread_cleanup_pop()
1191 ptd->cleanup = cleanup->next; in pthread_cleanup_pop()
1233 _pthread_data_t *ptd; in pthread_cleanup_push() local
1239 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; in pthread_cleanup_push()
1240 RT_ASSERT(ptd != RT_NULL); in pthread_cleanup_push()
1249 cleanup->next = ptd->cleanup; in pthread_cleanup_push()
1250 ptd->cleanup = cleanup; in pthread_cleanup_push()
1313 _pthread_data_t *ptd; in pthread_setcancelstate() local
1318 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; in pthread_setcancelstate()
1319 RT_ASSERT(ptd != RT_NULL); in pthread_setcancelstate()
1324 *oldstate = ptd->cancelstate; in pthread_setcancelstate()
1325 ptd->cancelstate = state; in pthread_setcancelstate()
1364 _pthread_data_t *ptd; in pthread_setcanceltype() local
1369 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; in pthread_setcanceltype()
1370 RT_ASSERT(ptd != RT_NULL); in pthread_setcanceltype()
1376 *oldtype = ptd->canceltype; in pthread_setcanceltype()
1377 ptd->canceltype = type; in pthread_setcanceltype()
1403 _pthread_data_t *ptd; in pthread_testcancel() local
1408 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; in pthread_testcancel()
1409 RT_ASSERT(ptd != RT_NULL); in pthread_testcancel()
1411 if (ptd->cancelstate == PTHREAD_CANCEL_ENABLE) in pthread_testcancel()
1412 cancel = ptd->canceled; in pthread_testcancel()
1444 _pthread_data_t *ptd; in pthread_cancel() local
1449 ptd = _pthread_get_data(thread); in pthread_cancel()
1450 if (ptd == RT_NULL) in pthread_cancel()
1454 tid = ptd->tid; in pthread_cancel()
1457 if (ptd->tid == rt_thread_self()) in pthread_cancel()
1461 if (ptd->cancelstate == PTHREAD_CANCEL_ENABLE) in pthread_cancel()
1463 ptd->canceled = 1; in pthread_cancel()
1464 if (ptd->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS) in pthread_cancel()
1470 while (ptd->cleanup != RT_NULL) in pthread_cancel()
1472 cleanup = ptd->cleanup; in pthread_cancel()
1473 ptd->cleanup = cleanup->next; in pthread_cancel()
1481 if (ptd->attr.detachstate == PTHREAD_CREATE_JOINABLE) in pthread_cancel()
1484 rt_sem_release(ptd->joinable_sem); in pthread_cancel()
1489 _pthread_data_destroy(ptd); in pthread_cancel()