summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadsetnamenp.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/src/pthreadsetnamenp.c')
-rw-r--r--cpukit/posix/src/pthreadsetnamenp.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/cpukit/posix/src/pthreadsetnamenp.c b/cpukit/posix/src/pthreadsetnamenp.c
new file mode 100644
index 0000000000..cb0e47ce94
--- /dev/null
+++ b/cpukit/posix/src/pthreadsetnamenp.c
@@ -0,0 +1,38 @@
+/*
+ * 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 <rtems/score/threadimpl.h>
+#include <rtems/posix/posixapi.h>
+
+int pthread_setname_np( pthread_t thread, const char *name )
+{
+ Thread_Control *the_thread;
+ ISR_lock_Context lock_context;
+ Status_Control status;
+
+ _Objects_Allocator_lock();
+ the_thread = _Thread_Get( thread, &lock_context );
+
+ if ( the_thread == NULL ) {
+ _Objects_Allocator_unlock();
+ return ESRCH;
+ }
+
+ _ISR_lock_ISR_enable( &lock_context );
+ status = _Thread_Set_name( the_thread, name );
+ _Objects_Allocator_unlock();
+ return _POSIX_Get_error( status );
+}