summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-12 13:46:55 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-13 08:10:28 +0100
commitda6ad56a68676d68782ddcbd443a57337c84ee06 (patch)
tree65340ed747fc5f73fc8fc601f25f0fa2846704cd /cpukit
parent7ced9d9bb2fd51cfef2ce33d22e779adfed604c2 (diff)
downloadrtems-da6ad56a68676d68782ddcbd443a57337c84ee06.tar.bz2
score: Add _Thread_Set_name()
Add configuration option CONFIGURE_MAXIMUM_THREAD_NAME_SIZE. Update #2858.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/sapi/include/confdefs.h18
-rw-r--r--cpukit/score/include/rtems/score/status.h2
-rw-r--r--cpukit/score/include/rtems/score/thread.h8
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h5
-rw-r--r--cpukit/score/src/threadname.c20
5 files changed, 53 insertions, 0 deletions
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 3a718ba452..12eec53c0f 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -3199,6 +3199,10 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
CONFIGURE_HEAP_HANDLER_OVERHEAD \
)
+#ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE
+ #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE 16
+#endif
+
#ifdef CONFIGURE_INIT
typedef union {
Scheduler_Node Base;
@@ -3232,6 +3236,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node );
#endif
+ const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE;
+
typedef struct {
Thread_Control Control;
#if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
@@ -3242,6 +3248,9 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#ifdef RTEMS_POSIX_API
POSIX_API_Control API_POSIX;
#endif
+ #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
+ char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ];
+ #endif
#if !defined(RTEMS_SCHEDSIM) \
&& defined(RTEMS_NEWLIB) \
&& !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)
@@ -3270,6 +3279,15 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
),
offsetof( Configuration_Thread_control, Newlib )
}
+ #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
+ , {
+ offsetof(
+ Configuration_Thread_control,
+ Control.Join_queue.Queue.name
+ ),
+ offsetof( Configuration_Thread_control, name )
+ }
+ #endif
#ifdef RTEMS_POSIX_API
, {
offsetof(
diff --git a/cpukit/score/include/rtems/score/status.h b/cpukit/score/include/rtems/score/status.h
index 6b6f3c51d6..2695a03f1a 100644
--- a/cpukit/score/include/rtems/score/status.h
+++ b/cpukit/score/include/rtems/score/status.h
@@ -115,6 +115,8 @@ typedef enum {
STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EINVAL ),
STATUS_RESOURCE_IN_USE =
STATUS_BUILD( STATUS_CLASSIC_RESOURCE_IN_USE, EBUSY ),
+ STATUS_RESULT_TOO_LARGE =
+ STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, ERANGE ),
STATUS_SUCCESSFUL =
STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, 0 ),
STATUS_TIMEOUT =
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 13765fc940..c114c91832 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -907,6 +907,14 @@ extern const size_t _Thread_Control_add_on_count;
*/
extern const size_t _Thread_Control_size;
+/**
+ * @brief Maximum size of a thread name in characters (including the
+ * terminating '\0' character).
+ *
+ * This value is provided via <rtems/confdefs.h>.
+ */
+extern const size_t _Thread_Maximum_name_size;
+
/**@}*/
#ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index cb9e8e6539..8ddf74e160 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -1951,6 +1951,11 @@ RTEMS_INLINE_ROUTINE void _Thread_Remove_timer_and_unblock(
#endif
}
+Status_Control _Thread_Set_name(
+ Thread_Control *the_thread,
+ const char *name
+);
+
size_t _Thread_Get_name(
const Thread_Control *the_thread,
char *buffer,
diff --git a/cpukit/score/src/threadname.c b/cpukit/score/src/threadname.c
index 6e4ffa4044..a4ee3ab5bd 100644
--- a/cpukit/score/src/threadname.c
+++ b/cpukit/score/src/threadname.c
@@ -14,6 +14,26 @@
#include <string.h>
+Status_Control _Thread_Set_name(
+ Thread_Control *the_thread,
+ const char *name
+)
+{
+ size_t length;
+
+ length = strlcpy(
+ the_thread->Join_queue.Queue.name,
+ name,
+ _Thread_Maximum_name_size
+ );
+
+ if ( length >= _Thread_Maximum_name_size ) {
+ return STATUS_RESULT_TOO_LARGE;
+ }
+
+ return STATUS_SUCCESSFUL;
+}
+
size_t _Thread_Get_name(
const Thread_Control *the_thread,
char *buffer,