source: rtems/cpukit/score/src/objectsetname.c @ 74d0cb44

4.104.114.95
Last change on this file since 74d0cb44 was 74d0cb44, checked in by Joel Sherrill <joel.sherrill@…>, on 01/31/08 at 16:15:34

2008-01-31 Joel Sherrill <joel.sherrill@…>

  • posix/src/cond.c, posix/src/key.c, posix/src/mqueuenametoid.c, posix/src/mutex.c, posix/src/pbarrier.c, posix/src/prwlock.c, posix/src/pspin.c, posix/src/pthread.c, posix/src/ptimer.c, posix/src/semaphorenametoid.c: Add option for all POSIX objects whether named or unnamed to have a string name. If the API does not directly support having a name, then the user must explicitly assign it using rtems_object_set_name().
  • rtems/src/rtemsobjectgetapiclassname.c: Improved testability.
  • score/include/rtems/score/object.h, score/src/objectgetnameasstring.c, score/src/objectnametoidstring.c, score/src/objectsetname.c: Modifications required to pass testing of recently modified object name operations. Also eliminated multiprocessing related code that was not reachable.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/score/object.h>
18#include <rtems/score/thread.h>
19#include <rtems/score/wkspace.h>
20#include <stdlib.h>
21#include <stdio.h>
22#include <ctype.h>
23#include <inttypes.h>
24#include <string.h>
25
26
27/*
28 *  This method sets the name of an object based upon a C string.
29 */
30
31boolean _Objects_Set_name(
32  Objects_Information *information,
33  Objects_Control     *the_object,
34  const char          *name
35)
36{
37  size_t                 length;
38  const char            *s;
39
40  s      = name;
41  length = strnlen( name, information->name_length ) + 1;
42
43  if ( information->is_string ) {
44    char *d;
45
46    d = _Workspace_Allocate( length );
47    if ( !d )
48      return FALSE;
49
50    if ( the_object->name.name_p ) {
51      _Workspace_Free( (void *)the_object->name.name_p );
52      the_object->name.name_p = NULL;
53    }
54
55    strncpy( d, name, length );
56    the_object->name.name_p = d;
57  } else {
58    the_object->name.name_u32 =  _Objects_Build_name(
59      ((0<length) ? s[ 0 ] : ' '),
60      ((1<length) ? s[ 1 ] : ' '),
61      ((2<length) ? s[ 2 ] : ' '),
62      ((3<length) ? s[ 3 ] : ' ')
63    );
64
65  }
66
67  return TRUE;
68}
Note: See TracBrowser for help on using the repository browser.