* @brief Returns the thread ID of the calling thread. * * The `pthread_self` function returns the thread ID of the calling thread. The thread ID is unique to the * thread within a process and can be used to identify the calling thread in the context of multithreading. * * The value returned by `pthread_self` can be compared with the thread IDs of other threads to determine * if two threads a
| 663 | * @see pthread_create, pthread_equal, pthread_join |
| 664 | */ |
| 665 | pthread_t pthread_self (void) |
| 666 | { |
| 667 | rt_thread_t tid; |
| 668 | _pthread_data_t *ptd; |
| 669 | |
| 670 | tid = rt_thread_self(); |
| 671 | if (tid == NULL) return PTHREAD_NUM_MAX; |
| 672 | |
| 673 | /* get pthread data from pthread_data of thread */ |
| 674 | ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; |
| 675 | RT_ASSERT(ptd != RT_NULL); |
| 676 | |
| 677 | return _pthread_data_get_pth(ptd); |
| 678 | } |
| 679 | RTM_EXPORT(pthread_self); |
| 680 | |
| 681 | /** |
no test coverage detected