source: rtems/cpukit/score/src/objectallocatebyindex.c @ 20f54e9

4.104.114.84.95
Last change on this file since 20f54e9 was 6af81435, checked in by Joel Sherrill <joel.sherrill@…>, on 11/12/99 at 15:54:48

Corrected so now actually indexes into the allocation block.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
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.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/score/address.h>
18#include <rtems/score/chain.h>
19#include <rtems/score/object.h>
20#if defined(RTEMS_MULTIPROCESSING)
21#include <rtems/score/objectmp.h>
22#endif
23#include <rtems/score/thread.h>
24#include <rtems/score/wkspace.h>
25#include <rtems/score/sysstate.h>
26#include <rtems/score/isr.h>
27
28/*PAGE
29 *
30 *  _Objects_Allocate_by_index
31 *
32 *  DESCRIPTION:
33 *
34 *  This function allocates the object control block
35 *  specified by the index from the inactive chain of
36 *  free object control blocks.
37 */
38
39Objects_Control *_Objects_Allocate_by_index(
40  Objects_Information *information,
41  unsigned32           index,
42  unsigned32           sizeof_control
43)
44{
45  Objects_Control *the_object;
46
47  if ( index && information->maximum >= index ) {
48    the_object = _Objects_Get_local_object( information, index );
49    if ( the_object )
50      return NULL;
51
52    /* XXX
53     *  This whole section of code needs to be addressed.
54     *    +  The 0 should be dealt with more properly so we can autoextend.
55     *    +  The pointer arithmetic is probably too expensive.
56     *    +  etc.
57     */
58   
59    the_object = (Objects_Control *) _Addresses_Add_offset(
60      information->object_blocks[ 0 ],
61      (sizeof_control * (index - 1))
62    );
63    _Chain_Extract( &the_object->Node );
64 
65    return the_object;   
66  }   
67
68  /*
69   *  Autoextend will have to be thought out as it applies
70   *  to user assigned indices.
71   */
72
73  return NULL;
74}
Note: See TracBrowser for help on using the repository browser.