5
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Get Pointer to Next Object that is Active |
---|
5 | * @ingroup RTEMSScoreObject |
---|
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 | Objects_Control *_Objects_Get_next( |
---|
24 | Objects_Id id, |
---|
25 | const Objects_Information *information, |
---|
26 | Objects_Id *next_id_p |
---|
27 | ) |
---|
28 | { |
---|
29 | Objects_Control *the_object; |
---|
30 | Objects_Id next_id; |
---|
31 | Objects_Maximum maximum; |
---|
32 | |
---|
33 | if ( !information ) |
---|
34 | return NULL; |
---|
35 | |
---|
36 | if ( !next_id_p ) |
---|
37 | return NULL; |
---|
38 | |
---|
39 | if (_Objects_Get_index(id) == OBJECTS_ID_INITIAL_INDEX) |
---|
40 | next_id = _Objects_Get_minimum_id( information->maximum_id ); |
---|
41 | else |
---|
42 | next_id = id; |
---|
43 | |
---|
44 | _Objects_Allocator_lock(); |
---|
45 | maximum = _Objects_Get_maximum_index( information ); |
---|
46 | |
---|
47 | do { |
---|
48 | /* walked off end of list? */ |
---|
49 | if (_Objects_Get_index( next_id ) > maximum) { |
---|
50 | _Objects_Allocator_unlock(); |
---|
51 | *next_id_p = OBJECTS_ID_FINAL; |
---|
52 | return NULL; |
---|
53 | } |
---|
54 | |
---|
55 | /* try to grab one */ |
---|
56 | the_object = _Objects_Get_no_protection( next_id, information ); |
---|
57 | |
---|
58 | next_id++; |
---|
59 | } while ( the_object == NULL ); |
---|
60 | |
---|
61 | *next_id_p = next_id; |
---|
62 | return the_object; |
---|
63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.