未验证 提交 00b2c5ee 编写于 作者: O openharmony_ci 提交者: Gitee

!206 修改接口名为pthread_gettid_np

Merge pull request !206 from caifuzhou/addAPI
...@@ -20,16 +20,16 @@ void* pthread_test(void* arg) ...@@ -20,16 +20,16 @@ void* pthread_test(void* arg)
int main(int argc, char const *argv[]) int main(int argc, char const *argv[])
{ {
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
TEST(gettid() == pthread_gettid(pthread_self()),"pthread_gettid() is failed\n"); TEST(gettid() == pthread_gettid_np(pthread_self()),"pthread_gettid_np() is failed\n");
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
pid_t tid; pid_t tid;
pthread_t t; pthread_t t;
pthread_create(&t,NULL,pthread_test,&tid); pthread_create(&t,NULL,pthread_test,&tid);
pid_t recv_result = pthread_gettid(t); pid_t recv_result = pthread_gettid_np(t);
TEST(0 == pthread_join(t,NULL),"pthread_join is failed\n"); TEST(0 == pthread_join(t,NULL),"pthread_join is failed\n");
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
TEST(tid == recv_result,"the tid of pthread or tid of pthread_gettid is wrong\n"); TEST(tid == recv_result,"the tid of pthread or tid of pthread_gettid_np() is wrong\n");
return 0; return 0;
} }
\ No newline at end of file
...@@ -23,7 +23,7 @@ functional_list = [ ...@@ -23,7 +23,7 @@ functional_list = [
"pthread_cancel-points", "pthread_cancel-points",
"pthread_cancel", "pthread_cancel",
"pthread_cond", "pthread_cond",
"pthread_gettid", "pthread_gettid_np",
"pthread_mutex", "pthread_mutex",
"pthread_mutex_pi", "pthread_mutex_pi",
"pthread_robust", "pthread_robust",
......
...@@ -89,7 +89,7 @@ int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void ...@@ -89,7 +89,7 @@ int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void
int pthread_detach(pthread_t); int pthread_detach(pthread_t);
_Noreturn void pthread_exit(void *); _Noreturn void pthread_exit(void *);
int pthread_join(pthread_t, void **); int pthread_join(pthread_t, void **);
pid_t pthread_gettid(pthread_t); pid_t pthread_gettid_np(pthread_t);
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__((const)) __attribute__((const))
......
...@@ -407,15 +407,16 @@ struct pthread* __pthread_list_find(pthread_t thread_id, const char* info) ...@@ -407,15 +407,16 @@ struct pthread* __pthread_list_find(pthread_t thread_id, const char* info)
while (t != self) { while (t != self) {
if (t == thread) return thread; if (t == thread) return thread;
t = t->next ; t = t->next ;
} }
log_print("invalid pthread_t %p passed to %s\n", thread, info);
return NULL; return NULL;
} }
pid_t __pthread_gettid(pthread_t t) pid_t __pthread_gettid_np(pthread_t t)
{ {
__tl_lock(); __tl_lock();
struct pthread* thread = __pthread_list_find(t, "pthread_gettid"); struct pthread* thread = __pthread_list_find(t, "pthread_gettid_np");
__tl_unlock(); __tl_unlock();
return thread ? thread->tid : -1; return thread ? thread->tid : -1;
} }
weak_alias(__pthread_gettid, pthread_gettid); weak_alias(__pthread_gettid_np, pthread_gettid_np);
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册