source: rtems/cpukit/itron/inline/rtems/itron/semaphore.inl @ 8b3416f

4.104.115
Last change on this file since 8b3416f was 22d66ab, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 16:04:00

Convert to "bool".

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/**
2 * @file rtems/itron/semaphore.inl
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#ifndef _RTEMS_ITRON_SEMAPHORE_H
17# error "Never use <rtems/itron/semaphore.inl> directly; include <rtems/itron/semaphore.h> instead."
18#endif
19
20#ifndef _RTEMS_ITRON_SEMAPHORE_INL
21#define _RTEMS_ITRON_SEMAPHORE_INL
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/*
28 *  _ITRON_Semaphore_Allocate
29 *
30 *  DESCRIPTION:
31 *
32 *  This routine allocates the semaphore associated with the specified
33 *  semaphore ID from the pool of inactive semaphores.
34 *
35 *  Input parameters:
36 *    semid   - id of semaphore to allocate
37 *    status  - pointer to status variable
38 *
39 *  Output parameters:
40 *    returns - pointer to the semaphore control block
41 *    *status - status
42 */
43
44RTEMS_INLINE_ROUTINE ITRON_Semaphore_Control *_ITRON_Semaphore_Allocate(
45  ID   semid
46)
47{
48  return (ITRON_Semaphore_Control *)_ITRON_Objects_Allocate_by_index(
49    &_ITRON_Semaphore_Information,
50    semid,
51    sizeof(ITRON_Semaphore_Control)
52  );
53}
54
55/*
56 *  _ITRON_Semaphore_Clarify_allocation_id_error
57 *
58 *  This function is invoked when an object allocation ID error
59 *  occurs to determine the specific ITRON error code to return.
60 */
61
62#define _ITRON_Semaphore_Clarify_allocation_id_error( _id ) \
63  _ITRON_Objects_Clarify_allocation_id_error( \
64      &_ITRON_Semaphore_Information, (_id) )
65
66/*
67 *  _ITRON_Semaphore_Clarify_get_id_error
68 *
69 *  This function is invoked when an object get ID error
70 *  occurs to determine the specific ITRON error code to return.
71 */
72
73#define _ITRON_Semaphore_Clarify_get_id_error( _id ) \
74 _ITRON_Objects_Clarify_get_id_error( &_ITRON_Semaphore_Information, (_id) )
75
76/*
77 *  _ITRON_Semaphore_Free
78 *
79 *  DESCRIPTION:
80 *
81 *  This routine frees a semaphore control block to the
82 *  inactive chain of free semaphore control blocks.
83 *
84 *  Input parameters:
85 *    the_semaphore - pointer to semaphore control block
86 *
87 *  Output parameters: NONE
88 */
89
90RTEMS_INLINE_ROUTINE void _ITRON_Semaphore_Free (
91  ITRON_Semaphore_Control *the_semaphore
92)
93{
94  _ITRON_Objects_Free( &_ITRON_Semaphore_Information, &the_semaphore->Object );
95}
96
97/*PAGE
98 *
99 *  _ITRON_Semaphore_Get
100 *
101 *  DESCRIPTION:
102 *
103 *  This function maps semaphore IDs to semaphore control blocks.
104 *  If ID corresponds to a local semaphore, then it returns
105 *  the_semaphore control pointer which maps to ID and location
106 *  is set to OBJECTS_LOCAL.  if the semaphore ID is global and
107 *  resides on a remote node, then location is set to OBJECTS_REMOTE,
108 *  and the_semaphore is undefined.  Otherwise, location is set
109 *  to OBJECTS_ERROR and the_semaphore is undefined.
110 *
111 *  Input parameters:
112 *    id            - ITRON semaphore ID.
113 *    the_location  - pointer to a location variable
114 *
115 *  Output parameters:
116 *    *the_location  - location of the object
117 */
118
119RTEMS_INLINE_ROUTINE ITRON_Semaphore_Control *_ITRON_Semaphore_Get (
120  ID                 id,
121  Objects_Locations *location
122)
123{
124  return (ITRON_Semaphore_Control *)
125    _ITRON_Objects_Get( &_ITRON_Semaphore_Information, id, location );
126}
127
128/*PAGE
129 *
130 *  _ITRON_Semaphore_Is_null
131 *
132 *  This function returns TRUE if the_semaphore is NULL and FALSE otherwise.
133 *
134 *  Input parameters:
135 *    the_semaphore - pointer to semaphore control block
136 *
137 *  Output parameters:
138 *    TRUE  - if the_semaphore is NULL
139 *    FALSE - otherwise
140 */
141
142RTEMS_INLINE_ROUTINE bool _ITRON_Semaphore_Is_null (
143  ITRON_Semaphore_Control *the_semaphore
144)
145{
146  return ( the_semaphore == NULL );
147}
148
149/*
150 *  _ITRON_Semaphore_Translate_core_semaphore_return_code
151 *
152 *  This function returns a ITRON status code based on the semaphore
153 *  status code specified.
154 *
155 *  Input parameters:
156 *    the_semaphore_status - semaphore status code to translate
157 *
158 *  Output parameters:
159 *    ITRON status code - translated ITRON status code
160 *
161 */
162
163RTEMS_INLINE_ROUTINE ER  _ITRON_Semaphore_Translate_core_semaphore_return_code (
164  uint32_t   the_semaphore_status
165)
166{
167/* XXX need to be able to return "E_RLWAI" */
168  switch ( the_semaphore_status ) {
169    case  CORE_SEMAPHORE_STATUS_SUCCESSFUL:
170      return E_OK;
171    case CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT:
172      return E_TMOUT;
173    case CORE_SEMAPHORE_WAS_DELETED:
174      return E_DLT;
175    case CORE_SEMAPHORE_TIMEOUT:
176      return E_TMOUT;
177    case CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED:
178      return E_QOVR;
179    case THREAD_STATUS_PROXY_BLOCKING:
180      return THREAD_STATUS_PROXY_BLOCKING;
181  }
182  return E_OK;   /* unreached - only to remove warnings */
183}
184
185#ifdef __cplusplus
186}
187#endif
188
189#endif
190/* end of include file */
191
Note: See TracBrowser for help on using the repository browser.