diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-12 09:26:08 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-13 08:10:28 +0100 |
commit | 7c49927911badda7907703568cadbcb2f1b7ef9d (patch) | |
tree | f2104a2e9d85422cedc9afef3c16f96394ba3130 /cpukit/posix/src/pthreadgetnamenp.c | |
parent | score: Add _Thread_Set_name() (diff) | |
download | rtems-7c49927911badda7907703568cadbcb2f1b7ef9d.tar.bz2 |
posix: Add pthread_getname_np(), ...
Add pthread_getname_np() and pthread_setname_np().
Update #2858.
Diffstat (limited to 'cpukit/posix/src/pthreadgetnamenp.c')
-rw-r--r-- | cpukit/posix/src/pthreadgetnamenp.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cpukit/posix/src/pthreadgetnamenp.c b/cpukit/posix/src/pthreadgetnamenp.c new file mode 100644 index 0000000000..e753823976 --- /dev/null +++ b/cpukit/posix/src/pthreadgetnamenp.c @@ -0,0 +1,44 @@ +/* + * 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 + +#define _GNU_SOURCE +#include <pthread.h> +#include <errno.h> +#include <string.h> + +#include <rtems/score/threadimpl.h> + +int pthread_getname_np( pthread_t thread, char *name, size_t len ) +{ + Thread_Control *the_thread; + ISR_lock_Context lock_context; + size_t actual_len; + + _Objects_Allocator_lock(); + the_thread = _Thread_Get( thread, &lock_context ); + + if ( the_thread == NULL ) { + _Objects_Allocator_unlock(); + strlcpy(name, "", len); + return ESRCH; + } + + _ISR_lock_ISR_enable( &lock_context ); + actual_len = _Thread_Get_name( the_thread, name, len ); + _Objects_Allocator_unlock(); + + if ( actual_len >= len ) { + return ERANGE; + } + + return 0; +} |