source: rtems/cpukit/score/inline/rtems/score/object.inl @ ce19f1fa

4.104.114.95
Last change on this file since ce19f1fa was ce19f1fa, checked in by Joel Sherrill <joel.sherrill@…>, on 01/23/08 at 22:57:43

2008-01-23 Joel Sherrill <joel.sherrill@…>

  • itron/include/rtems/itron/object.h, itron/src/cre_tsk.c, libblock/src/show_bdbuf.c, libmisc/capture/capture-cli.c, libmisc/capture/capture.c, libmisc/monitor/mon-manager.c, libmisc/stackchk/check.c, posix/src/condinit.c, posix/src/keycreate.c, posix/src/mqueuecreatesupp.c, posix/src/mqueuedeletesupp.c, posix/src/mqueuenametoid.c, posix/src/mqueueopen.c, posix/src/mqueueunlink.c, posix/src/mutexinit.c, posix/src/pbarrierinit.c, posix/src/prwlockinit.c, posix/src/pspininit.c, posix/src/pthreadcreate.c, posix/src/pthreadexit.c, posix/src/semaphorecreatesupp.c, posix/src/semaphorenametoid.c, posix/src/timercreate.c, rtems/src/barrierident.c, rtems/src/dpmemident.c, rtems/src/msgqident.c, rtems/src/partident.c, rtems/src/ratemonident.c, rtems/src/regionident.c, rtems/src/semident.c, rtems/src/taskident.c, rtems/src/timerident.c, sapi/src/extensionident.c, score/Makefile.am, score/include/rtems/score/object.h, score/inline/rtems/score/object.inl, score/src/apimutexallocate.c, score/src/objectextendinformation.c, score/src/objectgetnameasstring.c, score/src/objectmp.c, score/src/objectnametoid.c: Convert the Objects_Name type from a simple type to a union of an unsigned 32 bit integer and a pointer. This should help eliminate weird casts between u32 and pointers in various places. The APIs now have to explicitly call _u32 or _string versions of helper routines. This should also simplify things and eliminate the need for ugly casts in some cases.
  • score/src/objectclearname.c, score/src/objectcomparenameraw.c, score/src/objectcomparenamestring.c, score/src/objectcopynameraw.c, score/src/objectcopynamestring.c: Removed.
  • Property mode set to 100644
File size: 9.9 KB
Line 
1/**
2 * @file rtems/score/object.inl
3 */
4
5/*
6 *
7 *  This include file contains the static inline implementation of all
8 *  of the inlined routines in the Object Handler.
9 *
10 *  COPYRIGHT (c) 1989-2007.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#ifndef _RTEMS_SCORE_OBJECT_INL
21#define _RTEMS_SCORE_OBJECT_INL
22
23/**
24 *  This function builds an object's id from the processor node and index
25 *  values specified.
26 *
27 *  @param[in] the_api indicates the API associated with this Id.
28 *  @param[in] the_class indicates the class of object.
29 *             It is specific to @a the_api.
30 *  @param[in] node is the node where this object resides.
31 *  @param[in] index is the instance number of this object.
32 *
33 *  @return This method returns an object Id constructed from the arguments.
34 */
35RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id(
36  Objects_APIs     the_api,
37  uint32_t         the_class,
38  uint32_t         node,
39  uint32_t         index
40)
41{
42  return (( (Objects_Id) the_api )   << OBJECTS_API_START_BIT)   |
43         (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) |
44         (( (Objects_Id) node )      << OBJECTS_NODE_START_BIT)  |
45         (( (Objects_Id) index )     << OBJECTS_INDEX_START_BIT);
46}
47
48/**
49 *  This function returns the API portion of the ID.
50 *
51 *  @param[in] id is the object Id to be processed.
52 *
53 *  @return This method returns an object Id constructed from the arguments.
54 */
55RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API(
56  Objects_Id id
57)
58{
59  return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS);
60}
61
62/**
63 *  This function returns the class portion of the ID.
64 *
65 *  @param[in] id is the object Id to be processed
66 */
67RTEMS_INLINE_ROUTINE uint32_t   _Objects_Get_class(
68  Objects_Id id
69)
70{
71  return (uint32_t  )
72    ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
73}
74 
75/**
76 *  This function returns the node portion of the ID.
77 *
78 *  @param[in] id is the object Id to be processed
79 *
80 *  @return This method returns the node portion of an object ID.
81 */
82RTEMS_INLINE_ROUTINE uint32_t   _Objects_Get_node(
83  Objects_Id id
84)
85{
86  return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
87}
88
89/**
90 *  This function returns the index portion of the ID.
91 *
92 *  @param[in] id is the Id to be processed
93 *
94 *  @return This method returns the class portion of the specified object ID.
95 */
96RTEMS_INLINE_ROUTINE uint32_t   _Objects_Get_index(
97  Objects_Id id
98)
99{
100  return (id >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS;
101}
102
103/**
104 *  This function returns TRUE if the api is valid.
105 *
106 *  @param[in] the_api is the api portion of an object ID.
107 *
108 *  @return This method returns TRUE if the specified api value is valid
109 *          and FALSE otherwise.
110 */
111RTEMS_INLINE_ROUTINE boolean _Objects_Is_api_valid(
112  uint32_t   the_api
113)
114{
115  if ( !the_api || the_api > OBJECTS_APIS_LAST )
116   return FALSE;
117  return TRUE;
118}
119   
120/**
121 *  This function returns TRUE if the class is valid.
122 *
123 *  @param[in] the_class is the class portion of an object ID.
124 *
125 *  @return This method returns TRUE if the specified class value is valid
126 *          and FALSE otherwise.
127 */
128RTEMS_INLINE_ROUTINE boolean _Objects_Is_class_valid(
129  uint32_t   the_class
130)
131{
132  /* XXX how do we determine this now? */
133  return TRUE; /* the_class && the_class <= OBJECTS_CLASSES_LAST; */
134}
135
136/**
137 *  This function returns TRUE if the node is of the local object, and
138 *  FALSE otherwise.
139 *
140 *  @param[in] node is the node number and corresponds to the node number
141 *         portion of an object ID.
142 *
143 *  @return This method returns TRUE if the specified node is the local node
144 *          and FALSE otherwise.
145 */
146RTEMS_INLINE_ROUTINE boolean _Objects_Is_local_node(
147  uint32_t   node
148)
149{
150  return ( node == _Objects_Local_node );
151}
152
153/**
154 *  This function returns TRUE if the id is of a local object, and
155 *  FALSE otherwise.
156 *
157 *  @param[in] id is an object ID
158 *
159 *  @return This method returns TRUE if the specified object Id is local
160 *          and FALSE otherwise.
161 *
162 *  @note On a single processor configuration, this always returns TRUE.
163 */
164RTEMS_INLINE_ROUTINE boolean _Objects_Is_local_id(
165  Objects_Id id
166)
167{
168#if defined(RTEMS_MULTIPROCESSING)
169  return _Objects_Is_local_node( _Objects_Get_node(id) );
170#else
171  return TRUE;
172#endif
173}
174
175/**
176 *  This function returns TRUE if left and right are equal,
177 *  and FALSE otherwise.
178 *
179 *  @param[in] left is the Id on the left hand side of the comparison
180 *  @param[in] right is the Id on the right hand side of the comparison
181 *
182 *  @return This method returns TRUE if the specified object IDs are equal
183 *          and FALSE otherwise.
184 */
185RTEMS_INLINE_ROUTINE boolean _Objects_Are_ids_equal(
186  Objects_Id left,
187  Objects_Id right
188)
189{
190  return ( left == right );
191}
192
193/**
194 *  This function returns a pointer to the local_table object
195 *  referenced by the index.
196 *
197 *  @param[in] information points to an Object Information Table
198 *  @param[in] index is the index of the object the caller wants to access
199 *
200 *  @return This method returns a pointer to a local object or NULL if the
201 *          index is invalid.
202 */
203RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_local_object(
204  Objects_Information *information,
205  uint16_t             index
206)
207{
208  if ( index > information->maximum )
209    return NULL;
210  return information->local_table[ index ];
211}
212
213/**
214 *  This function sets the pointer to the local_table object
215 *  referenced by the index.
216 *
217 *  @param[in] information points to an Object Information Table
218 *  @param[in] index is the index of the object the caller wants to access
219 *  @param[in] the_object is the local object pointer
220 *
221 *  @note This routine is ONLY to be called in places where the
222 *        index portion of the Id is known to be good.  This is
223 *        OK since it is normally called from object create/init
224 *        or delete/destroy operations.
225 */
226
227RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
228  Objects_Information *information,
229  uint16_t             index,
230  Objects_Control     *the_object
231)
232{
233  /*
234   *  This routine is ONLY to be called from places in the code
235   *  where the Id is known to be good.  Therefore, this should NOT
236   *  occur in normal situations.
237   */
238  #if defined(RTEMS_DEBUG)
239    if ( index > information->maximum )
240      return;
241  #endif
242
243  information->local_table[ index ] = the_object;
244}
245
246/**
247 *  This function return the information structure given
248 *  an id of an object.
249 *
250 *  @param[in] id is an object ID
251 *
252 *
253 *  @return This method returns a pointer to the Object Information Table
254 *          for the class of objects which corresponds to this object ID.
255 */
256RTEMS_INLINE_ROUTINE Objects_Information *_Objects_Get_information(
257  Objects_Id  id
258)
259{
260  Objects_APIs  the_api;
261  uint16_t      the_class;
262
263
264  the_class = _Objects_Get_class( id );
265
266  if ( !_Objects_Is_class_valid( the_class ) )
267    return NULL;
268
269  the_api = _Objects_Get_API( id );
270  return _Objects_Information_table[ the_api ][ the_class ];
271}
272
273/**
274 *  This function places the_object control pointer and object name
275 *  in the Local Pointer and Local Name Tables, respectively.
276 *
277 *  @param[in] information points to an Object Information Table
278 *  @param[in] the_object is a pointer to an object
279 *  @param[in] name is the name of the object to make accessible
280 */
281RTEMS_INLINE_ROUTINE void _Objects_Open(
282  Objects_Information *information,
283  Objects_Control     *the_object,
284  Objects_Name         name
285)
286{
287  uint32_t    index;
288
289  index = _Objects_Get_index( the_object->id );
290  _Objects_Set_local_object( information, index, the_object );
291
292  the_object->name = name;
293}
294
295/**
296 *  This function places the_object control pointer and object name
297 *  in the Local Pointer and Local Name Tables, respectively.
298 *
299 *  @param[in] information points to an Object Information Table
300 *  @param[in] the_object is a pointer to an object
301 *  @param[in] name is the name of the object to make accessible
302 */
303RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
304  Objects_Information *information,
305  Objects_Control     *the_object,
306  uint32_t             name
307)
308{
309  uint32_t    index;
310
311  index = _Objects_Get_index( the_object->id );
312  _Objects_Set_local_object( information, index, the_object );
313
314  /* ASSERT: information->is_string == FALSE */
315  the_object->name.name_u32 = name;
316}
317
318/**
319 *  This function places the_object control pointer and object name
320 *  in the Local Pointer and Local Name Tables, respectively.
321 *
322 *  @param[in] information points to an Object Information Table
323 *  @param[in] the_object is a pointer to an object
324 *  @param[in] name is the name of the object to make accessible
325 */
326RTEMS_INLINE_ROUTINE void _Objects_Open_string(
327  Objects_Information *information,
328  Objects_Control     *the_object,
329  const char          *name
330)
331{
332  uint32_t    index;
333
334  index = _Objects_Get_index( the_object->id );
335  _Objects_Set_local_object( information, index, the_object );
336
337  /* information->is_string */
338  the_object->name.name_p = name;
339}
340
341/**
342 *  This function removes the_object control pointer and object name
343 *  in the Local Pointer and Local Name Tables.
344 *
345 *  @param[in] information points to an Object Information Table
346 *  @param[in] the_object is a pointer to an object
347 */
348RTEMS_INLINE_ROUTINE void _Objects_Close(
349  Objects_Information  *information,
350  Objects_Control      *the_object
351)
352{
353  _Objects_Set_local_object(
354    information,
355    _Objects_Get_index( the_object->id ),
356    NULL
357  );
358
359  the_object->name.name_u32 = 0;
360  the_object->name.name_p   = NULL;
361}
362
363/**
364 *  This function removes the_object from the namespace.
365 *
366 *  @param[in] information points to an Object Information Table
367 *  @param[in] the_object is a pointer to an object
368 */
369RTEMS_INLINE_ROUTINE void _Objects_Namespace_remove(
370  Objects_Information  *information,
371  Objects_Control      *the_object
372)
373{
374  /*
375   * Clear out either format.
376   */
377  the_object->name.name_p   = NULL;
378  the_object->name.name_u32 = 0;
379}
380
381#endif
382/* end of include file */
Note: See TracBrowser for help on using the repository browser.