source: rtems/cpukit/itron/inline/rtems/itron/semaphore.inl @ f5c9b89

Last change on this file since f5c9b89 was f5c9b89, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 30, 2006 at 10:21:07 PM

2006-10-30 Joel Sherrill <joel@…>

PR 841/rtems

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