Changeset ae88aa7 in rtems for cpukit/sapi
- Timestamp:
- 03/10/14 07:15:37 (10 years ago)
- Branches:
- 4.11, 5, master
- Children:
- d50acdbb
- Parents:
- b1196e3
- git-author:
- Sebastian Huber <sebastian.huber@…> (03/10/14 07:15:37)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (03/11/14 09:58:09)
- Location:
- cpukit/sapi
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/sapi/include/rtems/chain.h
rb1196e3 rae88aa7 6 6 7 7 /* 8 * Copyright (c) 2010 embedded brains GmbH.8 * Copyright (c) 2010-2014 embedded brains GmbH. 9 9 * 10 10 * COPYRIGHT (c) 1989-2008. … … 20 20 21 21 #include <rtems/score/chainimpl.h> 22 #include <rtems/score/isrlock.h>23 22 #include <rtems/rtems/event.h> 24 23 … … 38 37 typedef Chain_Node rtems_chain_node; 39 38 40 typedef struct { 41 Chain_Control Chain; 42 ISR_lock_Control Lock; 43 } rtems_chain_control; 39 typedef Chain_Control rtems_chain_control; 44 40 45 41 /** … … 47 43 */ 48 44 #define RTEMS_CHAIN_INITIALIZER_EMPTY( name ) \ 49 { CHAIN_INITIALIZER_EMPTY( name.Chain ), ISR_LOCK_INITIALIZER }45 CHAIN_INITIALIZER_EMPTY( name ) 50 46 51 47 /** … … 55 51 */ 56 52 #define RTEMS_CHAIN_INITIALIZER_ONE_NODE( node ) \ 57 { CHAIN_INITIALIZER_ONE_NODE( node ), ISR_LOCK_INITIALIZER }53 CHAIN_INITIALIZER_ONE_NODE( node ) 58 54 59 55 /** … … 63 59 */ 64 60 #define RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ 65 CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( &( chain )->Chain )61 CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) 66 62 67 63 /** … … 155 151 ) 156 152 { 157 _ISR_lock_Initialize( &the_chain->Lock );158 153 _Chain_Initialize( 159 &the_chain->Chain,154 the_chain, 160 155 starting_address, 161 156 number_nodes, … … 175 170 ) 176 171 { 177 _ISR_lock_Initialize( &the_chain->Lock ); 178 _Chain_Initialize_empty( &the_chain->Chain ); 172 _Chain_Initialize_empty( the_chain ); 179 173 } 180 174 … … 242 236 ) 243 237 { 244 return _Chain_Head( &the_chain->Chain );238 return _Chain_Head( the_chain ); 245 239 } 246 240 … … 258 252 ) 259 253 { 260 return _Chain_Immutable_head( &the_chain->Chain );254 return _Chain_Immutable_head( the_chain ); 261 255 } 262 256 … … 274 268 ) 275 269 { 276 return _Chain_Tail( &the_chain->Chain );270 return _Chain_Tail( the_chain ); 277 271 } 278 272 … … 290 284 ) 291 285 { 292 return _Chain_Immutable_tail( &the_chain->Chain );286 return _Chain_Immutable_tail( the_chain ); 293 287 } 294 288 … … 307 301 ) 308 302 { 309 return _Chain_First( &the_chain->Chain );303 return _Chain_First( the_chain ); 310 304 } 311 305 … … 324 318 ) 325 319 { 326 return _Chain_Immutable_first( &the_chain->Chain );320 return _Chain_Immutable_first( the_chain ); 327 321 } 328 322 … … 341 335 ) 342 336 { 343 return _Chain_Last( &the_chain->Chain );337 return _Chain_Last( the_chain ); 344 338 } 345 339 … … 358 352 ) 359 353 { 360 return _Chain_Immutable_last( &the_chain->Chain );354 return _Chain_Immutable_last( the_chain ); 361 355 } 362 356 … … 460 454 ) 461 455 { 462 return _Chain_Is_empty( &the_chain->Chain );456 return _Chain_Is_empty( the_chain ); 463 457 } 464 458 … … 515 509 ) 516 510 { 517 return _Chain_Has_only_one_node( &the_chain->Chain );511 return _Chain_Has_only_one_node( the_chain ); 518 512 } 519 513 … … 535 529 ) 536 530 { 537 return _Chain_Is_head( &the_chain->Chain, the_node );531 return _Chain_Is_head( the_chain, the_node ); 538 532 } 539 533 … … 555 549 ) 556 550 { 557 return _Chain_Is_tail( &the_chain->Chain, the_node ); 558 } 559 560 #if !defined( RTEMS_SMP ) 551 return _Chain_Is_tail( the_chain, the_node ); 552 } 553 561 554 /** 562 555 * @brief Extract the specified node from a chain. … … 568 561 * @arg the_node specifies the node to extract 569 562 */ 563 #if defined( RTEMS_SMP ) 564 void rtems_chain_extract( 565 rtems_chain_node *the_node 566 ); 567 #else 570 568 RTEMS_INLINE_ROUTINE void rtems_chain_extract( 571 569 rtems_chain_node *the_node … … 573 571 { 574 572 _Chain_Extract( the_node ); 575 }576 #endif577 578 #if defined( RTEMS_SMP )579 /**580 * @brief Extract the specified node from a chain.581 *582 * @param[in,out] chain The chain containing the node.583 * @param[in,out] node The node to extract.584 */585 void rtems_chain_explicit_extract(586 rtems_chain_control *chain,587 rtems_chain_node *node588 );589 #else590 RTEMS_INLINE_ROUTINE void rtems_chain_explicit_extract(591 rtems_chain_control *chain,592 rtems_chain_node *node593 )594 {595 ( void ) chain;596 rtems_chain_extract( node );597 573 } 598 574 #endif … … 634 610 ) 635 611 { 636 return _Chain_Get( &the_chain->Chain );612 return _Chain_Get( the_chain ); 637 613 } 638 614 #endif … … 645 621 ) 646 622 { 647 return _Chain_Get_unprotected( &the_chain->Chain ); 648 } 649 650 #if !defined( RTEMS_SMP ) 623 return _Chain_Get_unprotected( the_chain ); 624 } 625 651 626 /** 652 627 * @brief Insert a node on a chain … … 658 633 * of the extract operation. 659 634 */ 635 #if defined( RTEMS_SMP ) 636 void rtems_chain_insert( 637 rtems_chain_node *after_node, 638 rtems_chain_node *the_node 639 ); 640 #else 660 641 RTEMS_INLINE_ROUTINE void rtems_chain_insert( 661 642 rtems_chain_node *after_node, … … 664 645 { 665 646 _Chain_Insert( after_node, the_node ); 666 }667 #endif668 669 /**670 * @brief Insert a node on a chain671 *672 * @param[in,out] chain The chain containing the after node.673 * @param[in,out] after_node Insert the node after this node.674 * @param[in,out] node The node to insert.675 */676 #if defined( RTEMS_SMP )677 void rtems_chain_explicit_insert(678 rtems_chain_control *chain,679 rtems_chain_node *after_node,680 rtems_chain_node *node681 );682 #else683 RTEMS_INLINE_ROUTINE void rtems_chain_explicit_insert(684 rtems_chain_control *chain,685 rtems_chain_node *after_node,686 rtems_chain_node *node687 )688 {689 ( void ) chain;690 rtems_chain_insert( after_node, node );691 647 } 692 648 #endif … … 722 678 ) 723 679 { 724 _Chain_Append( &the_chain->Chain, the_node );680 _Chain_Append( the_chain, the_node ); 725 681 } 726 682 #endif … … 739 695 ) 740 696 { 741 _Chain_Append_unprotected( &the_chain->Chain, the_node );697 _Chain_Append_unprotected( the_chain, the_node ); 742 698 } 743 699 … … 764 720 ) 765 721 { 766 _Chain_Prepend( &the_chain->Chain, the_node );722 _Chain_Prepend( the_chain, the_node ); 767 723 } 768 724 #endif … … 784 740 ) 785 741 { 786 _Chain_Prepend_unprotected( &the_chain->Chain, the_node );742 _Chain_Prepend_unprotected( the_chain, the_node ); 787 743 } 788 744 … … 806 762 ) 807 763 { 808 return _Chain_Append_with_empty_check( &chain->Chain, node );764 return _Chain_Append_with_empty_check( chain, node ); 809 765 } 810 766 #endif … … 829 785 ) 830 786 { 831 return _Chain_Prepend_with_empty_check( &chain->Chain, node );787 return _Chain_Prepend_with_empty_check( chain, node ); 832 788 } 833 789 #endif … … 856 812 ) 857 813 { 858 return _Chain_Get_with_empty_check( &chain->Chain, node );814 return _Chain_Get_with_empty_check( chain, node ); 859 815 } 860 816 #endif … … 874 830 ) 875 831 { 876 return _Chain_Node_count_unprotected( &chain->Chain );832 return _Chain_Node_count_unprotected( chain ); 877 833 } 878 834 -
cpukit/sapi/src/chainsmp.c
rb1196e3 rae88aa7 1 1 /* 2 * Copyright (c) 2013 embedded brains GmbH. All rights reserved.2 * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. 3 3 * 4 4 * embedded brains GmbH … … 21 21 #if defined( RTEMS_SMP ) 22 22 23 void rtems_chain_explicit_extract( 24 rtems_chain_control *chain, 25 rtems_chain_node *node 26 ) 23 #include <rtems/score/smplock.h> 24 25 static SMP_lock_Control chain_lock = SMP_LOCK_INITIALIZER; 26 27 static void chain_acquire( ISR_Level *level ) 28 { 29 _SMP_lock_ISR_disable_and_acquire( &chain_lock, *level ); 30 } 31 32 static void chain_release( ISR_Level *level ) 33 { 34 _SMP_lock_Release_and_ISR_enable( &chain_lock, *level ); 35 } 36 37 void rtems_chain_extract( rtems_chain_node *node ) 27 38 { 28 39 ISR_Level level; 29 40 30 _ISR_lock_ISR_disable_and_acquire( &chain->Lock,level );41 chain_acquire( &level ); 31 42 _Chain_Extract_unprotected( node ); 32 _ISR_lock_Release_and_ISR_enable( &chain->Lock,level );43 chain_release( &level ); 33 44 } 34 45 … … 38 49 ISR_Level level; 39 50 40 _ISR_lock_ISR_disable_and_acquire( &chain->Lock,level );41 node = _Chain_Get_unprotected( &chain->Chain );42 _ISR_lock_Release_and_ISR_enable( &chain->Lock,level );51 chain_acquire( &level ); 52 node = _Chain_Get_unprotected( chain ); 53 chain_release( &level ); 43 54 44 55 return node; 45 56 } 46 57 47 void rtems_chain_explicit_insert( 48 rtems_chain_control *chain, 49 rtems_chain_node *after_node, 50 rtems_chain_node *node 51 ) 58 void rtems_chain_insert( rtems_chain_node *after_node, rtems_chain_node *node ) 52 59 { 53 60 ISR_Level level; 54 61 55 _ISR_lock_ISR_disable_and_acquire( &chain->Lock,level );62 chain_acquire( &level ); 56 63 _Chain_Insert_unprotected( after_node, node ); 57 _ISR_lock_Release_and_ISR_enable( &chain->Lock,level );64 chain_release( &level ); 58 65 } 59 66 … … 65 72 ISR_Level level; 66 73 67 _ISR_lock_ISR_disable_and_acquire( &chain->Lock,level );68 _Chain_Append_unprotected( &chain->Chain, node );69 _ISR_lock_Release_and_ISR_enable( &chain->Lock,level );74 chain_acquire( &level ); 75 _Chain_Append_unprotected( chain, node ); 76 chain_release( &level ); 70 77 } 71 78 … … 77 84 ISR_Level level; 78 85 79 _ISR_lock_ISR_disable_and_acquire( &chain->Lock,level );80 _Chain_Prepend_unprotected( &chain->Chain, node );81 _ISR_lock_Release_and_ISR_enable( &chain->Lock,level );86 chain_acquire( &level ); 87 _Chain_Prepend_unprotected( chain, node ); 88 chain_release( &level ); 82 89 } 83 90 … … 90 97 ISR_Level level; 91 98 92 _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); 93 was_empty = _Chain_Append_with_empty_check_unprotected( 94 &chain->Chain, 95 node 96 ); 97 _ISR_lock_Release_and_ISR_enable( &chain->Lock, level ); 99 chain_acquire( &level ); 100 was_empty = _Chain_Append_with_empty_check_unprotected( chain, node ); 101 chain_release( &level ); 98 102 99 103 return was_empty; … … 108 112 ISR_Level level; 109 113 110 _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); 111 was_empty = _Chain_Prepend_with_empty_check_unprotected( 112 &chain->Chain, 113 node 114 ); 115 _ISR_lock_Release_and_ISR_enable( &chain->Lock, level ); 114 chain_acquire( &level ); 115 was_empty = _Chain_Prepend_with_empty_check_unprotected( chain, node ); 116 chain_release( &level ); 116 117 117 118 return was_empty; … … 126 127 ISR_Level level; 127 128 128 _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); 129 is_empty_now = _Chain_Get_with_empty_check_unprotected( 130 &chain->Chain, 131 node 132 ); 133 _ISR_lock_Release_and_ISR_enable( &chain->Lock, level ); 129 chain_acquire( &level ); 130 is_empty_now = _Chain_Get_with_empty_check_unprotected( chain, node ); 131 chain_release( &level ); 134 132 135 133 return is_empty_now;
Note: See TracChangeset
for help on using the changeset viewer.