From 7ced9d9bb2fd51cfef2ce33d22e779adfed604c2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 12 Jan 2017 09:25:56 +0100 Subject: score: Add and use _Thread_Get_name() Update #2858. --- cpukit/score/Makefile.am | 1 + cpukit/score/include/rtems/score/threadimpl.h | 8 +++++- cpukit/score/src/threadname.c | 37 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 cpukit/score/src/threadname.c (limited to 'cpukit/score') diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 9b376c3f06..953f1eb195 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -299,6 +299,7 @@ libscore_a_SOURCES += src/threadentryadaptorpointer.c libscore_a_SOURCES += src/threadgetcputimeused.c libscore_a_SOURCES += src/threadglobalconstruction.c libscore_a_SOURCES += src/threaditerate.c +libscore_a_SOURCES += src/threadname.c libscore_a_SOURCES += src/threadscheduler.c libscore_a_SOURCES += src/threadtimeout.c libscore_a_SOURCES += src/threadwaitgetid.c diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index f131bbd506..cb9e8e6539 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -11,7 +11,7 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2014, 2016 embedded brains GmbH. + * Copyright (c) 2014, 2017 embedded brains GmbH. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -1951,6 +1951,12 @@ RTEMS_INLINE_ROUTINE void _Thread_Remove_timer_and_unblock( #endif } +size_t _Thread_Get_name( + const Thread_Control *the_thread, + char *buffer, + size_t buffer_size +); + /** @}*/ #ifdef __cplusplus diff --git a/cpukit/score/src/threadname.c b/cpukit/score/src/threadname.c new file mode 100644 index 0000000000..6e4ffa4044 --- /dev/null +++ b/cpukit/score/src/threadname.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +size_t _Thread_Get_name( + const Thread_Control *the_thread, + char *buffer, + size_t buffer_size +) +{ + const char *name; + + name = the_thread->Join_queue.Queue.name; + + if ( name != NULL && name[ 0 ] != '\0' ) { + return strlcpy( buffer, name, buffer_size ); + } else { + return _Objects_Name_to_string( + the_thread->Object.name, + false, + buffer, + buffer_size + ); + } +} -- cgit v1.2.3