@@ -86,9 +86,12 @@ static inline opal_list_item_t *opal_fifo_push_atomic (opal_fifo_t *fifo,
8686                                                       opal_list_item_t  * item )
8787{
8888    opal_counted_pointer_t  tail ;
89+     const  opal_list_item_t  *  const  ghost  =  & fifo -> opal_fifo_ghost ;
8990
9091    item -> opal_list_next  =  & fifo -> opal_fifo_ghost ;
9192
93+     opal_atomic_wmb  ();
94+ 
9295    do  {
9396        tail .value  =  fifo -> opal_fifo_tail .value ;
9497
@@ -99,7 +102,7 @@ static inline opal_list_item_t *opal_fifo_push_atomic (opal_fifo_t *fifo,
99102
100103    opal_atomic_wmb  ();
101104
102-     if  (& fifo -> opal_fifo_ghost  ==  tail .data .item ) {
105+     if  (ghost  ==  tail .data .item ) {
103106        /* update the head */ 
104107        opal_counted_pointer_t  head  =  {.value  =  fifo -> opal_fifo_head .value };
105108        opal_update_counted_pointer  (& fifo -> opal_fifo_head , head , item );
@@ -116,24 +119,23 @@ static inline opal_list_item_t *opal_fifo_push_atomic (opal_fifo_t *fifo,
116119 */ 
117120static  inline  opal_list_item_t  * opal_fifo_pop_atomic  (opal_fifo_t  * fifo )
118121{
119-     opal_list_item_t  * item , * next ;
122+     opal_list_item_t  * item , * next ,  * ghost   =   & fifo -> opal_fifo_ghost ;
120123    opal_counted_pointer_t  head , tail ;
121124
122125    do  {
123-         head . value   =   fifo -> opal_fifo_head . value ;
126+         opal_read_counted_pointer  ( & fifo -> opal_fifo_head ,  & head ) ;
124127        tail .value  =  fifo -> opal_fifo_tail .value ;
125128        opal_atomic_rmb  ();
126129
127130        item  =  (opal_list_item_t  * ) head .data .item ;
128131        next  =  (opal_list_item_t  * ) item -> opal_list_next ;
129132
130-         if  (& fifo -> opal_fifo_ghost  ==  tail .data .item  &&  & fifo -> opal_fifo_ghost  ==  item ) {
133+         if  (ghost  ==  tail .data .item  &&  ghost  ==  item ) {
131134            return  NULL ;
132135        }
133136
134137        /* the head or next pointer are in an inconsistent state. keep looping. */ 
135-         if  (tail .data .item  !=  item  &&  & fifo -> opal_fifo_ghost  !=  tail .data .item  && 
136-             & fifo -> opal_fifo_ghost  ==  next ) {
138+         if  (tail .data .item  !=  item  &&  ghost  !=  tail .data .item  &&  ghost  ==  next ) {
137139            continue ;
138140        }
139141
@@ -146,14 +148,14 @@ static inline opal_list_item_t *opal_fifo_pop_atomic (opal_fifo_t *fifo)
146148    opal_atomic_wmb  ();
147149
148150    /* check for tail and head consistency */ 
149-     if  (& fifo -> opal_fifo_ghost  ==  next ) {
151+     if  (ghost  ==  next ) {
150152        /* the head was just set to &fifo->opal_fifo_ghost. try to update the tail as well */ 
151-         if  (!opal_update_counted_pointer  (& fifo -> opal_fifo_tail , tail , & fifo -> opal_fifo_ghost )) {
153+         if  (!opal_update_counted_pointer  (& fifo -> opal_fifo_tail , tail , ghost )) {
152154            /* tail was changed by a push operation. wait for the item's next pointer to be se then 
153155             * update the head */ 
154156
155157            /* wait for next pointer to be updated by push */ 
156-             while  (& fifo -> opal_fifo_ghost  ==  item -> opal_list_next ) {
158+             while  (ghost  ==  item -> opal_list_next ) {
157159                opal_atomic_rmb  ();
158160            }
159161
@@ -166,7 +168,7 @@ static inline opal_list_item_t *opal_fifo_pop_atomic (opal_fifo_t *fifo)
166168            head .value  =  fifo -> opal_fifo_head .value ;
167169            next  =  (opal_list_item_t  * ) item -> opal_list_next ;
168170
169-             assert  (& fifo -> opal_fifo_ghost  ==  head .data .item );
171+             assert  (ghost  ==  head .data .item );
170172
171173            fifo -> opal_fifo_head .data .item  =  next ;
172174            opal_atomic_wmb  ();
0 commit comments