pthread: add pthread_{getname_np,setname_npp}
- These two functions imported for Linux/BSD compability. Signed-off-by: Han Pengfei <pengphei@qq.com> Change-Id: I3e9cada26f1ed043bfaed83e8185dcfff3bd71e2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5746 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
8e17b43da6
commit
44cceee67e
@ -19,6 +19,9 @@ extern "C" {
|
||||
|
||||
extern int pthread_getattr_np(pthread_t thread, pthread_attr_t* attr);
|
||||
|
||||
extern int pthread_getname_np(pthread_t thread, char* buffer, size_t length);
|
||||
extern int pthread_setname_np(pthread_t thread, const char* name);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -94,6 +94,9 @@ status_t __pthread_init_creation_attributes(
|
||||
void __pthread_set_default_priority(int32 priority);
|
||||
status_t __pthread_mutex_lock(pthread_mutex_t* mutex, bigtime_t timeout);
|
||||
|
||||
int __pthread_getname_np(pthread_t thread, char* buffer, size_t length);
|
||||
int __pthread_setname_np(pthread_t thread, const char* name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -315,3 +315,31 @@ get_pthread_thread_id(pthread_t thread)
|
||||
{
|
||||
return thread->id;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__pthread_getname_np(pthread_t thread, char* buffer, size_t length)
|
||||
{
|
||||
thread_info info;
|
||||
status_t status = _kern_get_thread_info(thread->id, &info);
|
||||
if (status == B_BAD_THREAD_ID)
|
||||
return ESRCH;
|
||||
if (strlcpy(buffer, info.name, length) >= length)
|
||||
return ERANGE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__pthread_setname_np(pthread_t thread, const char* name)
|
||||
{
|
||||
status_t status = _kern_rename_thread(thread->id, name);
|
||||
if (status == B_BAD_THREAD_ID)
|
||||
return ESRCH;
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_DEFINE_WEAK_ALIAS(__pthread_getname_np, pthread_getname_np);
|
||||
B_DEFINE_WEAK_ALIAS(__pthread_setname_np, pthread_setname_np);
|
||||
|
@ -880,9 +880,11 @@ void __pthread_cleanup_pop_handler() {}
|
||||
void __pthread_cleanup_push_handler() {}
|
||||
void __pthread_destroy_thread() {}
|
||||
void __pthread_getattr_np() {}
|
||||
void __pthread_getname_np() {}
|
||||
void __pthread_init_creation_attributes() {}
|
||||
void __pthread_key_call_destructors() {}
|
||||
void __pthread_set_default_priority() {}
|
||||
void __pthread_setname_np() {}
|
||||
void __pthread_sigmask() {}
|
||||
void __pthread_sigmask_beos() {}
|
||||
void __random_r() {}
|
||||
@ -2226,6 +2228,7 @@ void pthread_equal() {}
|
||||
void pthread_exit() {}
|
||||
void pthread_getattr_np() {}
|
||||
void pthread_getconcurrency() {}
|
||||
void pthread_getname_np() {}
|
||||
void pthread_getschedparam() {}
|
||||
void pthread_getspecific() {}
|
||||
void pthread_join() {}
|
||||
@ -2271,6 +2274,7 @@ void pthread_self() {}
|
||||
void pthread_setcancelstate() {}
|
||||
void pthread_setcanceltype() {}
|
||||
void pthread_setconcurrency() {}
|
||||
void pthread_setname_np() {}
|
||||
void pthread_setschedparam() {}
|
||||
void pthread_setspecific() {}
|
||||
void pthread_spin_destroy() {}
|
||||
|
@ -726,10 +726,12 @@ void __pthread_cleanup_pop_handler() {}
|
||||
void __pthread_cleanup_push_handler() {}
|
||||
void __pthread_destroy_thread() {}
|
||||
void __pthread_getattr_np() {}
|
||||
void __pthread_getname_np() {}
|
||||
void __pthread_init_creation_attributes() {}
|
||||
void __pthread_key_call_destructors() {}
|
||||
void __pthread_mutex_lock__FP14_pthread_mutexUlx() {}
|
||||
void __pthread_set_default_priority() {}
|
||||
void __pthread_setname_np() {}
|
||||
void __pthread_sigmask() {}
|
||||
void __pthread_sigmask_beos() {}
|
||||
void __pure_virtual() {}
|
||||
@ -2205,6 +2207,7 @@ void pthread_equal() {}
|
||||
void pthread_exit() {}
|
||||
void pthread_getattr_np() {}
|
||||
void pthread_getconcurrency() {}
|
||||
void pthread_getname_np() {}
|
||||
void pthread_getschedparam() {}
|
||||
void pthread_getspecific() {}
|
||||
void pthread_join() {}
|
||||
@ -2250,6 +2253,7 @@ void pthread_self() {}
|
||||
void pthread_setcancelstate() {}
|
||||
void pthread_setcanceltype() {}
|
||||
void pthread_setconcurrency() {}
|
||||
void pthread_setname_np() {}
|
||||
void pthread_setschedparam() {}
|
||||
void pthread_setspecific() {}
|
||||
void pthread_spin_destroy() {}
|
||||
|
Loading…
Reference in New Issue
Block a user