source: rtems/cpukit/rtems/src/rtemsobjectgetapiclassname.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Get Class Name
5 *  @ingroup ClassicClassInfo
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
24#include <rtems/assoc.h>
25
26static const rtems_assoc_t rtems_object_api_internal_assoc[] = {
27  { "Thread",                  OBJECTS_INTERNAL_THREADS, 0},
28  { "Mutex",                   OBJECTS_INTERNAL_MUTEXES, 0},
29  { NULL,                      0, 0}
30};
31
32static const rtems_assoc_t rtems_object_api_classic_assoc[] = {
33  { "Task",                    OBJECTS_RTEMS_TASKS, 0},
34  { "Timer",                   OBJECTS_RTEMS_TIMERS, 0},
35  { "Semaphore",               OBJECTS_RTEMS_SEMAPHORES, 0},
36  { "Message Queue",           OBJECTS_RTEMS_MESSAGE_QUEUES, 0},
37  { "Partition",               OBJECTS_RTEMS_PARTITIONS, 0},
38  { "Region",                  OBJECTS_RTEMS_REGIONS, 0},
39  { "Port",                    OBJECTS_RTEMS_PORTS, 0},
40  { "Period",                  OBJECTS_RTEMS_PERIODS, 0},
41  { "Extension",               OBJECTS_RTEMS_EXTENSIONS, 0},
42  { "Barrier",                 OBJECTS_RTEMS_BARRIERS, 0},
43  { NULL,                      0, 0}
44};
45
46#ifdef RTEMS_POSIX_API
47static const rtems_assoc_t rtems_object_api_posix_assoc[] = {
48  { "Thread",                  OBJECTS_POSIX_THREADS, 0},
49  { "Key",                     OBJECTS_POSIX_KEYS, 0},
50  { "Interrupt",               OBJECTS_POSIX_INTERRUPTS, 0},
51  { "Queued fd",               OBJECTS_POSIX_MESSAGE_QUEUE_FDS, 0},
52  { "Message Queue",           OBJECTS_POSIX_MESSAGE_QUEUES, 0},
53  { "Mutex",                   OBJECTS_POSIX_MUTEXES, 0},
54  { "Semaphore",               OBJECTS_POSIX_SEMAPHORES, 0},
55  { "Condition Variable",      OBJECTS_POSIX_CONDITION_VARIABLES, 0},
56  { "Timer",                   OBJECTS_POSIX_TIMERS, 0},
57  { "Barrier",                 OBJECTS_POSIX_BARRIERS, 0},
58  { "Spinlock",                OBJECTS_POSIX_SPINLOCKS, 0},
59  { "RWLock",                  OBJECTS_POSIX_RWLOCKS, 0},
60  { NULL,                      0, 0}
61};
62#endif
63
64const char *rtems_object_get_api_class_name(
65  int the_api,
66  int the_class
67)
68{
69  const rtems_assoc_t *api_assoc;
70  const rtems_assoc_t *class_assoc;
71
72  if ( the_api == OBJECTS_INTERNAL_API )
73    api_assoc = rtems_object_api_internal_assoc;
74  else if ( the_api == OBJECTS_CLASSIC_API )
75    api_assoc = rtems_object_api_classic_assoc;
76#ifdef RTEMS_POSIX_API
77  else if ( the_api == OBJECTS_POSIX_API )
78    api_assoc = rtems_object_api_posix_assoc;
79#endif
80  else
81    return "BAD API";
82  class_assoc = rtems_assoc_ptr_by_local( api_assoc, the_class );
83  if ( class_assoc )
84    return class_assoc->name;
85  return "BAD CLASS";
86}
Note: See TracBrowser for help on using the repository browser.