source: rtems/cpukit/rtems/src/rtemsobjectgetapiclassname.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: 3.3 KB
Line 
1/*
2 *  RTEMS Object Helper -- Obtain Name of API
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/object.h>
20#include <rtems/rtems/object.h>
21
22#include <rtems/assoc.h>
23
24rtems_assoc_t rtems_object_api_internal_assoc[] = {
25  { "Thread",                  OBJECTS_INTERNAL_THREADS},
26  { "Mutex",                   OBJECTS_INTERNAL_MUTEXES},
27};
28
29rtems_assoc_t rtems_object_api_classic_assoc[] = {
30  { "Task",                    OBJECTS_RTEMS_TASKS},
31  { "Timer",                   OBJECTS_RTEMS_TIMERS},
32  { "Semaphore",               OBJECTS_RTEMS_SEMAPHORES},
33  { "Message Queue",           OBJECTS_RTEMS_MESSAGE_QUEUES},
34  { "Partition",               OBJECTS_RTEMS_PARTITIONS},
35  { "Region",                  OBJECTS_RTEMS_REGIONS},
36  { "Port",                    OBJECTS_RTEMS_PORTS},
37  { "Period",                  OBJECTS_RTEMS_PERIODS},
38  { "Extension",               OBJECTS_RTEMS_EXTENSIONS},
39  { "Barrier",                 OBJECTS_RTEMS_BARRIERS},
40};
41
42#ifdef RTEMS_POSIX_API
43rtems_assoc_t rtems_object_api_posix_assoc[] = {
44  { "Thread",                  OBJECTS_POSIX_THREADS},
45  { "Key",                     OBJECTS_POSIX_KEYS},
46  { "Interrupt",               OBJECTS_POSIX_INTERRUPTS},
47  { "Queued fd",               OBJECTS_POSIX_MESSAGE_QUEUE_FDS},
48  { "Message Queue",           OBJECTS_POSIX_MESSAGE_QUEUES},
49  { "Mutex",                   OBJECTS_POSIX_MUTEXES},
50  { "Semaphore",               OBJECTS_POSIX_SEMAPHORES},
51  { "Condition Variable",      OBJECTS_POSIX_CONDITION_VARIABLES},
52  { "Timer",                   OBJECTS_POSIX_TIMERS},
53  { "Barrier",                 OBJECTS_POSIX_BARRIERS},
54  { "Spinlock",                OBJECTS_POSIX_SPINLOCKS},
55  { "RWLock",                  OBJECTS_POSIX_RWLOCKS},
56};
57#endif
58
59#ifdef RTEMS_ITRON_API
60rtems_assoc_t rtems_object_api_itron_assoc[] = {
61  { "Task",                    OBJECTS_ITRON_TASKS},
62  { "Event Flag",              OBJECTS_ITRON_EVENTFLAGS},
63  { "Mailbox",                 OBJECTS_ITRON_MAILBOXES},
64  { "Message Buffer",          OBJECTS_ITRON_MESSAGE_BUFFERS},
65  { "Port",                    OBJECTS_ITRON_PORTS},
66  { "Semaphore",               OBJECTS_ITRON_SEMAPHORES},
67  { "Variable Memory Pool",    OBJECTS_ITRON_VARIABLE_MEMORY_POOLS},
68  { "Fixed Memory Pool",       OBJECTS_ITRON_FIXED_MEMORY_POOLS},
69};
70#endif
71
72const char *rtems_object_get_api_class_name(
73  uint32_t the_api,
74  uint32_t the_class
75)
76{
77  const rtems_assoc_t *api_assoc;
78  const rtems_assoc_t *class_assoc;
79 
80  if ( the_api == OBJECTS_INTERNAL_API )
81    api_assoc = rtems_object_api_internal_assoc;
82  else if ( the_api == OBJECTS_CLASSIC_API )
83    api_assoc = rtems_object_api_classic_assoc;
84#ifdef RTEMS_POSIX_API
85  else if ( the_api == OBJECTS_POSIX_API )
86    api_assoc = rtems_object_api_posix_assoc;
87#endif
88#ifdef RTEMS_ITRON_API
89  else if ( the_api == OBJECTS_ITRON_API )
90    api_assoc = rtems_object_api_itron_assoc;
91#endif
92  else
93    return "BAD API";
94  class_assoc = rtems_assoc_ptr_by_local( api_assoc, the_class );
95  if ( class_assoc )
96    return class_assoc->name;
97  return "BAD CLASS";
98}
Note: See TracBrowser for help on using the repository browser.