source: rtems/cpukit/score/src/objectallocate.c @ 2d7ae960

4.115
Last change on this file since 2d7ae960 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 */
12
13#if HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <rtems/system.h>
18#include <rtems/score/address.h>
19#include <rtems/score/chain.h>
20#include <rtems/score/object.h>
21#if defined(RTEMS_MULTIPROCESSING)
22#include <rtems/score/objectmp.h>
23#endif
24#include <rtems/score/thread.h>
25#include <rtems/score/wkspace.h>
26#include <rtems/score/sysstate.h>
27#include <rtems/score/isr.h>
28
29/* #define RTEMS_DEBUG_OBJECT_ALLOCATION */
30
31#if defined(RTEMS_DEBUG_OBJECT_ALLOCATION)
32#include <rtems/bspIo.h>
33#endif
34
35/*
36 *  _Objects_Allocate
37 *
38 *  DESCRIPTION:
39 *
40 *  This function allocates a object control block from
41 *  the inactive chain of free object control blocks.
42 */
43
44Objects_Control *_Objects_Allocate(
45  Objects_Information *information
46)
47{
48  Objects_Control *the_object;
49
50  /*
51   *  If the application is using the optional manager stubs and
52   *  still attempts to create the object, the information block
53   *  should be all zeroed out because it is in the BSS.  So let's
54   *  check that code for this manager is even present.
55   */
56  if ( information->size == 0 )
57    return NULL;
58
59  /*
60   *  OK.  The manager should be initialized and configured to have objects.
61   *  With any luck, it is safe to attempt to allocate an object.
62   */
63  the_object = (Objects_Control *) _Chain_Get( &information->Inactive );
64
65  if ( information->auto_extend ) {
66    /*
67     *  If the list is empty then we are out of objects and need to
68     *  extend information base.
69     */
70
71    if ( !the_object ) {
72      _Objects_Extend_information( information );
73      the_object =  (Objects_Control *) _Chain_Get( &information->Inactive );
74    }
75
76    if ( the_object ) {
77      uint32_t   block;
78
79      block = (uint32_t) _Objects_Get_index( the_object->id ) -
80              _Objects_Get_index( information->minimum_id );
81      block /= information->allocation_size;
82
83      information->inactive_per_block[ block ]--;
84      information->inactive--;
85    }
86  }
87
88#if defined(RTEMS_DEBUG_OBJECT_ALLOCATION)
89  if ( !the_object ) {
90    printk(
91      "OBJECT ALLOCATION FAILURE! API/Class %d/%d\n",
92      information->the_api,
93      information->the_class
94    );
95  }
96#endif
97
98  return the_object;
99}
Note: See TracBrowser for help on using the repository browser.