libc: add _get_tp() private function
(cherry picked from commit 06d8a116bd6b6f70b8aedc6a6a2c4085c53f63ac)