1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Set Name of Object |
---|
5 | * @ingroup ClassicClassInfo Object Class Information |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2008. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifdef HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/rtems/object.h> |
---|
22 | #include <rtems/score/objectimpl.h> |
---|
23 | #include <rtems/score/thread.h> |
---|
24 | |
---|
25 | /* |
---|
26 | * This method will set the object name based upon the user string. |
---|
27 | * If the object class uses 32-bit names, then only the first 4 bytes |
---|
28 | * of the string will be used. |
---|
29 | */ |
---|
30 | rtems_status_code rtems_object_set_name( |
---|
31 | rtems_id id, |
---|
32 | const char *name |
---|
33 | ) |
---|
34 | { |
---|
35 | Objects_Information *information; |
---|
36 | Objects_Locations location; |
---|
37 | Objects_Control *the_object; |
---|
38 | Objects_Id tmpId; |
---|
39 | |
---|
40 | if ( !name ) |
---|
41 | return RTEMS_INVALID_ADDRESS; |
---|
42 | |
---|
43 | tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id; |
---|
44 | |
---|
45 | information = _Objects_Get_information_id( tmpId ); |
---|
46 | if ( !information ) |
---|
47 | return RTEMS_INVALID_ID; |
---|
48 | |
---|
49 | the_object = _Objects_Get( information, tmpId, &location ); |
---|
50 | switch ( location ) { |
---|
51 | |
---|
52 | case OBJECTS_LOCAL: |
---|
53 | _Objects_Set_name( information, the_object, name ); |
---|
54 | _Objects_Put( the_object ); |
---|
55 | return RTEMS_SUCCESSFUL; |
---|
56 | |
---|
57 | #if defined(RTEMS_MULTIPROCESSING) |
---|
58 | case OBJECTS_REMOTE: |
---|
59 | #endif |
---|
60 | case OBJECTS_ERROR: |
---|
61 | break; |
---|
62 | } |
---|
63 | |
---|
64 | return RTEMS_INVALID_ID; |
---|
65 | } |
---|