source: rtems/cpukit/posix/src/pthreadgetnamenp.c @ 77fbbd6

5
Last change on this file since 77fbbd6 was 7c499279, checked in by Sebastian Huber <sebastian.huber@…>, on 01/12/17 at 08:26:08

posix: Add pthread_getname_np(), ...

Add pthread_getname_np() and pthread_setname_np().

Update #2858.

  • Property mode set to 100644
File size: 938 bytes
Line 
1/*
2 * Copyright (c) 2017 embedded brains GmbH.
3 *
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.rtems.org/license/LICENSE.
7 */
8
9#if HAVE_CONFIG_H
10#include "config.h"
11#endif
12
13#define _GNU_SOURCE
14#include <pthread.h>
15#include <errno.h>
16#include <string.h>
17
18#include <rtems/score/threadimpl.h>
19
20int pthread_getname_np( pthread_t thread, char *name, size_t len )
21{
22  Thread_Control   *the_thread;
23  ISR_lock_Context  lock_context;
24  size_t            actual_len;
25
26  _Objects_Allocator_lock();
27  the_thread = _Thread_Get( thread, &lock_context );
28
29  if ( the_thread == NULL ) {
30    _Objects_Allocator_unlock();
31    strlcpy(name, "", len);
32    return ESRCH;
33  }
34
35  _ISR_lock_ISR_enable( &lock_context );
36  actual_len = _Thread_Get_name( the_thread, name, len );
37  _Objects_Allocator_unlock();
38
39  if ( actual_len >= len ) {
40    return ERANGE;
41  }
42
43  return 0;
44}
Note: See TracBrowser for help on using the repository browser.