5
Last change
on this file since 0daa8ab was
aaaf9610,
checked in by Sebastian Huber <sebastian.huber@…>, on 08/08/16 at 06:44:51
|
score: Add debug support to red-black trees
This helps to detect double insert and extract errors.
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Watchdog Insert |
---|
5 | * @ingroup ScoreWatchdog |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Copyright (c) 2016 embedded brains GmbH. All rights reserved. |
---|
10 | * |
---|
11 | * embedded brains GmbH |
---|
12 | * Dornierstr. 4 |
---|
13 | * 82178 Puchheim |
---|
14 | * Germany |
---|
15 | * <rtems@embedded-brains.de> |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may be |
---|
18 | * found in the file LICENSE in this distribution or at |
---|
19 | * http://www.rtems.org/license/LICENSE. |
---|
20 | */ |
---|
21 | |
---|
22 | #if HAVE_CONFIG_H |
---|
23 | #include "config.h" |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <rtems/score/watchdogimpl.h> |
---|
27 | |
---|
28 | void _Watchdog_Insert( |
---|
29 | Watchdog_Header *header, |
---|
30 | Watchdog_Control *the_watchdog, |
---|
31 | uint64_t expire |
---|
32 | ) |
---|
33 | { |
---|
34 | RBTree_Node **link; |
---|
35 | RBTree_Node *parent; |
---|
36 | RBTree_Node *old_first; |
---|
37 | RBTree_Node *new_first; |
---|
38 | |
---|
39 | _Assert( _Watchdog_Get_state( the_watchdog ) == WATCHDOG_INACTIVE ); |
---|
40 | |
---|
41 | link = _RBTree_Root_reference( &header->Watchdogs ); |
---|
42 | parent = NULL; |
---|
43 | old_first = header->first; |
---|
44 | new_first = &the_watchdog->Node.RBTree; |
---|
45 | |
---|
46 | the_watchdog->expire = expire; |
---|
47 | |
---|
48 | while ( *link != NULL ) { |
---|
49 | Watchdog_Control *parent_watchdog; |
---|
50 | |
---|
51 | parent = *link; |
---|
52 | parent_watchdog = (Watchdog_Control *) parent; |
---|
53 | |
---|
54 | if ( expire < parent_watchdog->expire ) { |
---|
55 | link = _RBTree_Left_reference( parent ); |
---|
56 | } else { |
---|
57 | link = _RBTree_Right_reference( parent ); |
---|
58 | new_first = old_first; |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | header->first = new_first; |
---|
63 | _RBTree_Initialize_node( &the_watchdog->Node.RBTree ); |
---|
64 | _RBTree_Add_child( &the_watchdog->Node.RBTree, parent, link ); |
---|
65 | _RBTree_Insert_color( &header->Watchdogs, &the_watchdog->Node.RBTree ); |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.