source: rtems/cpukit/score/src/objectgetnext.c @ 1506658c

5
Last change on this file since 1506658c was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Get Pointer to Next Object that is Active
5 * @ingroup ScoreObject
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/objectimpl.h>
22
23/*
24 * _Objects_Get_next
25 *
26 * Like _Objects_Get, but considers the 'id' as a "hint" and
27 * finds next valid one after that point.
28 * Mostly used for monitor and debug traversal of an object.
29 *
30 * Input parameters:
31 *   information - pointer to entry in table for this class
32 *   id          - object id to search for
33 *   location    - address of where to store the location
34 *   next_id     - address to store next id to try
35 *
36 * Output parameters:
37 *   returns     - address of object if local
38 *   location    - one of the following:
39 *                  OBJECTS_ERROR  - invalid object ID
40 *                  OBJECTS_REMOTE - remote object
41 *                  OBJECTS_LOCAL  - local object
42 *   next_id     - will contain a reasonable "next" id to continue traversal
43 *
44 * NOTE:
45 *      assumes can add '1' to an id to get to next index.
46 */
47
48Objects_Control *
49_Objects_Get_next(
50    Objects_Information *information,
51    Objects_Id           id,
52    Objects_Locations   *location_p,
53    Objects_Id          *next_id_p
54)
55{
56    Objects_Control *object;
57    Objects_Id       next_id;
58
59    if ( !information )
60      return NULL;
61
62    if ( !location_p )
63      return NULL;
64
65    if ( !next_id_p )
66      return NULL;
67
68    if (_Objects_Get_index(id) == OBJECTS_ID_INITIAL_INDEX)
69        next_id = information->minimum_id;
70    else
71        next_id = id;
72
73    do {
74        /* walked off end of list? */
75        if (_Objects_Get_index(next_id) > information->maximum)
76        {
77            *location_p = OBJECTS_ERROR;
78            goto final;
79        }
80
81        /* try to grab one */
82        object = _Objects_Get(information, next_id, location_p);
83
84        next_id++;
85
86    } while (*location_p != OBJECTS_LOCAL);
87
88    *next_id_p = next_id;
89    return object;
90
91final:
92    *next_id_p = OBJECTS_ID_FINAL;
93    return 0;
94}
Note: See TracBrowser for help on using the repository browser.