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

5
Last change on this file since d78d529 was c8982e5, checked in by Sebastian Huber <sebastian.huber@…>, on 04/26/16 at 19:20:31

posix: Simplify message queues

The mq_open() function returns a descriptor to a POSIX message queue
object identified by a name. This is similar to sem_open(). In
contrast to the POSIX semaphore the POSIX message queues use a separate
object for the descriptor. This extra object is superfluous, since the
object identifier can be used directly for this purpose, just like for
the semaphores.

Update #2702.
Update #2555.

  • 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  { "Message Queue",           OBJECTS_POSIX_MESSAGE_QUEUES, 0},
52  { "Mutex",                   OBJECTS_POSIX_MUTEXES, 0},
53  { "Semaphore",               OBJECTS_POSIX_SEMAPHORES, 0},
54  { "Condition Variable",      OBJECTS_POSIX_CONDITION_VARIABLES, 0},
55  { "Timer",                   OBJECTS_POSIX_TIMERS, 0},
56  { "Barrier",                 OBJECTS_POSIX_BARRIERS, 0},
57  { "Spinlock",                OBJECTS_POSIX_SPINLOCKS, 0},
58  { "RWLock",                  OBJECTS_POSIX_RWLOCKS, 0},
59  { NULL,                      0, 0}
60};
61#endif
62
63const char *rtems_object_get_api_class_name(
64  int the_api,
65  int the_class
66)
67{
68  const rtems_assoc_t *api_assoc;
69  const rtems_assoc_t *class_assoc;
70
71  if ( the_api == OBJECTS_INTERNAL_API )
72    api_assoc = rtems_object_api_internal_assoc;
73  else if ( the_api == OBJECTS_CLASSIC_API )
74    api_assoc = rtems_object_api_classic_assoc;
75#ifdef RTEMS_POSIX_API
76  else if ( the_api == OBJECTS_POSIX_API )
77    api_assoc = rtems_object_api_posix_assoc;
78#endif
79  else
80    return "BAD API";
81  class_assoc = rtems_assoc_ptr_by_local( api_assoc, the_class );
82  if ( class_assoc )
83    return class_assoc->name;
84  return "BAD CLASS";
85}
Note: See TracBrowser for help on using the repository browser.