* @brief Retrieves the private data structure of a specified thread * * This function locates and validates the thread-private data structure associated with the given thread ID. * It uses a spinlock to synchronize access to the global thread table, ensuring data consistency in multithreaded environments. * A magic number validation is performed before returning to guarantee structural integ
| 40 | * - Internal interface typically used by other POSIX thread library functions |
| 41 | */ |
| 42 | _pthread_data_t *_pthread_get_data(pthread_t thread) |
| 43 | { |
| 44 | _pthread_data_t *ptd; |
| 45 | |
| 46 | if (thread >= PTHREAD_NUM_MAX) return NULL; |
| 47 | |
| 48 | rt_hw_spin_lock(&pth_lock); |
| 49 | ptd = pth_table[thread]; |
| 50 | rt_hw_spin_unlock(&pth_lock); |
| 51 | |
| 52 | if (ptd && ptd->magic == PTHREAD_MAGIC) return ptd; |
| 53 | |
| 54 | return NULL; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @brief Get the index position of a thread data in the global thread table |
no test coverage detected