Skip to content

Commit b2e2ecc

Browse files
committed
[kenel] add static name for rt_object
1 parent 19106eb commit b2e2ecc

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

include/rtdef.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,11 @@ typedef struct rt_slist_node rt_slist_t; /**< Type for single lis
398398
*/
399399
struct rt_object
400400
{
401-
char name[RT_NAME_MAX]; /**< name of kernel object */
401+
#if RT_NAME_MAX == 0
402+
char *name; /**< static name of kernel object */
403+
#else
404+
char name[RT_NAME_MAX]; /**< dynamic name of kernel object */
405+
#endif
402406
rt_uint8_t type; /**< type of kernel object */
403407
rt_uint8_t flag; /**< flag of kernel object */
404408

@@ -630,7 +634,11 @@ struct rt_cpu
630634
struct rt_thread
631635
{
632636
/* rt object */
633-
char name[RT_NAME_MAX]; /**< the name of thread */
637+
#if RT_NAME_MAX == 0
638+
char *name; /**< static name of kernel object */
639+
#else
640+
char name[RT_NAME_MAX]; /**< dynamic name of kernel object */
641+
#endif
634642
rt_uint8_t type; /**< type of object */
635643
rt_uint8_t flags; /**< thread's flags */
636644

src/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ menu "RT-Thread Kernel"
22

33
config RT_NAME_MAX
44
int "The maximal size of kernel object name"
5-
range 2 32
5+
range 0 64
66
default 8
77
help
88
Each kernel object, such as thread, timer, semaphore etc, has a name,

src/idle.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,21 @@ static void rt_thread_system_entry(void *parameter)
306306
void rt_thread_idle_init(void)
307307
{
308308
rt_ubase_t i;
309+
#if RT_NAME_MAX > 0
309310
char idle_thread_name[RT_NAME_MAX];
311+
#endif /* RT_NAME_MAX > 0 */
310312

311313
for (i = 0; i < _CPUS_NR; i++)
312314
{
313-
rt_sprintf(idle_thread_name, "tidle%d", i);
315+
#if RT_NAME_MAX > 0
316+
rt_snprintf(idle_thread_name, RT_NAME_MAX, "tidle%d", i);
317+
#endif /* RT_NAME_MAX > 0 */
314318
rt_thread_init(&idle_thread[i],
319+
#if RT_NAME_MAX > 0
315320
idle_thread_name,
321+
#else
322+
"tidle",
323+
#endif /* RT_NAME_MAX > 0 */
316324
idle_thread_entry,
317325
RT_NULL,
318326
&idle_thread_stack[i][0],

0 commit comments

Comments
 (0)