mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-05 16:10:55 +00:00
use syscall thr_set_name to implement pthread_set_name_np.
This commit is contained in:
parent
25c926f1b0
commit
3f7dda33b7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155329
|
@ -44,18 +44,27 @@ __weak_reference(_pthread_set_name_np, pthread_set_name_np);
|
||||||
void
|
void
|
||||||
_pthread_set_name_np(pthread_t thread, char *name)
|
_pthread_set_name_np(pthread_t thread, char *name)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
struct pthread *curthread = _get_curthread();
|
struct pthread *curthread = _get_curthread();
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (thread != NULL && thread->magic == THR_MAGIC) {
|
if (curthread == thread) {
|
||||||
THR_THREAD_LOCK(curthread, thread);
|
if (thr_set_name(thread->tid, name))
|
||||||
if (thread->name != NULL) {
|
ret = errno;
|
||||||
free(thread->name);
|
} else {
|
||||||
thread->name = NULL;
|
if (_thr_ref_add(curthread, thread, 0) == 0) {
|
||||||
|
THR_LOCK(thread);
|
||||||
|
if (thread->state != PS_DEAD) {
|
||||||
|
if (thr_set_name(thread->tid, name))
|
||||||
|
ret = errno;
|
||||||
|
}
|
||||||
|
THR_UNLOCK(thread);
|
||||||
|
_thr_ref_delete(curthread, thread);
|
||||||
|
} else {
|
||||||
|
ret = ESRCH;
|
||||||
}
|
}
|
||||||
if (name != NULL)
|
|
||||||
thread->name = strdup(name);
|
|
||||||
THR_THREAD_UNLOCK(curthread, thread);
|
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
/* XXX should return error code. */
|
||||||
|
return (ret);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue