diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-02-05 02:26:17 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-02-05 02:26:17 +0000 |
commit | 118990614c01d4866ba79dc95d91c6151985f85e (patch) | |
tree | f941f8d521358422149915b958a476c635b24248 /lib/libthr | |
parent | 4b1239a63fb448a489f71e12523e389e428f02a6 (diff) | |
download | FreeBSD-src-118990614c01d4866ba79dc95d91c6151985f85e.zip FreeBSD-src-118990614c01d4866ba79dc95d91c6151985f85e.tar.gz |
use syscall thr_set_name to implement pthread_set_name_np.
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_info.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/libthr/thread/thr_info.c b/lib/libthr/thread/thr_info.c index 5d00aa0..7605741 100644 --- a/lib/libthr/thread/thr_info.c +++ b/lib/libthr/thread/thr_info.c @@ -44,18 +44,27 @@ __weak_reference(_pthread_set_name_np, pthread_set_name_np); void _pthread_set_name_np(pthread_t thread, char *name) { -#if 0 struct pthread *curthread = _get_curthread(); + int ret = 0; - if (thread != NULL && thread->magic == THR_MAGIC) { - THR_THREAD_LOCK(curthread, thread); - if (thread->name != NULL) { - free(thread->name); - thread->name = NULL; + if (curthread == thread) { + if (thr_set_name(thread->tid, name)) + ret = errno; + } else { + 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 } |