From 3b37591a7b044ad128ffc28a6e6524c85b225ee9 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 1 Sep 2020 00:28:01 +0200 Subject: [PATCH 1/2] =?UTF-8?q?rthreads:=20Fix=20documentation=20(void=20f?= =?UTF-8?q?unction=20doesn=E2=80=99t=20return)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rthreads/rthreads.h | 2 -- rthreads/rthreads.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/include/rthreads/rthreads.h b/include/rthreads/rthreads.h index e4460a17..5887c4c3 100644 --- a/include/rthreads/rthreads.h +++ b/include/rthreads/rthreads.h @@ -90,8 +90,6 @@ int sthread_detach(sthread_t *thread); * @thread to terminate. If that thread has already terminated, then * it will return immediately. The thread specified by @thread must * be joinable. - * - * Returns: 0 on success, otherwise it returns a non-zero error number. */ void sthread_join(sthread_t *thread); diff --git a/rthreads/rthreads.c b/rthreads/rthreads.c index dd061b61..3c4099b1 100644 --- a/rthreads/rthreads.c +++ b/rthreads/rthreads.c @@ -285,8 +285,6 @@ int sthread_detach(sthread_t *thread) * @thread to terminate. If that thread has already terminated, then * it will return immediately. The thread specified by @thread must * be joinable. - * - * Returns: 0 on success, otherwise it returns a non-zero error number. */ void sthread_join(sthread_t *thread) { From daa6ad129d2ea31f9bb28ee88d10cb11d2150140 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 31 Aug 2020 23:33:15 +0200 Subject: [PATCH 2/2] rthreads: Add the ability to name threads --- include/rthreads/rthreads.h | 10 ++++++++++ rthreads/rthreads.c | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/rthreads/rthreads.h b/include/rthreads/rthreads.h index 5887c4c3..3b1ec7c8 100644 --- a/include/rthreads/rthreads.h +++ b/include/rthreads/rthreads.h @@ -101,6 +101,16 @@ void sthread_join(sthread_t *thread); */ bool sthread_isself(sthread_t *thread); +/** + * sthread_set_name: + * @thread : pointer to thread object + * @name : name to define for the thread (at most + * 15 bytes) + * + * Set the thread name, useful for debugging. + */ +void sthread_setname(sthread_t *thread, const char *name); + /** * slock_new: * diff --git a/rthreads/rthreads.c b/rthreads/rthreads.c index 3c4099b1..8bbf4b4d 100644 --- a/rthreads/rthreads.c +++ b/rthreads/rthreads.c @@ -318,6 +318,24 @@ bool sthread_isself(sthread_t *thread) #endif } +/** + * sthread_set_name: + * @thread : pointer to thread object + * @name : name to define for the thread (at most + * 15 bytes) + * + * Set the thread name, useful for debugging. + */ +void sthread_setname(sthread_t *thread, const char *name) +{ + if (!thread) + return; + // TODO: implement that for Windows too. +#ifndef USE_WIN32_THREADS + pthread_setname_np(thread->id, name); +#endif +} + /** * slock_new: *