
              *bit = test_bit;
              *found = true;
              rtems_rfs_buffer_mark_dirty (control->buffer);
              return 0;
            }

            if (test_bit == end_bit)
              break;

            map_offset += direction;
            test_bit   += direction;
          }
        }

        map_bits  += direction;
        map_index += direction;
        map_offset = direction > 0? 0 : rtems_rfs_bitmap_element_bits () - 1;

        test_bit = (map_index * rtems_rfs_bitmap_element_bits ()) + map_offset;

        search_offset += direction;

        if (((direction < 0) && (test_bit <= end_bit))
            || ((direction > 0) && (test_bit >= end_bit)))
          break;
      }
    }
    else
    {
      /*
       * Move to the next search element. We need to determine the number of
       * bits in the search offset that are being skipped so the map bits
       * pointer can be updated. If we are moving down and we have a search
       * offset of 0 then the search map adjustment is to the top bit of the
       * pervious search bit's value.
       *
       * Align test_bit either up or down depending on the direction to next 32
       * bit boundary.
       */
      rtems_rfs_bitmap_bit bits_skipped;
      test_bit &= ~((1 << RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1);
      if (direction > 0)
      {
        bits_skipped = rtems_rfs_bitmap_element_bits () - search_offset;
        test_bit += bits_skipped * rtems_rfs_bitmap_element_bits ();
        map_offset = 0;
      }
      else
      {
        bits_skipped = search_offset + 1;
        /*
         * Need to remove 1 for the rounding up. The above rounds down and
         * adds 1. Remember the logic is for subtraction.
         */
        test_bit -= ((bits_sk
* bit = test_bit; 
               * found = true; 
               rtems_rfs_buffer_mark_dirty (control->buffer); 
               return 0; 
             } 

             if (test_bit = = end_bit) 
               rupture; 

             map_offset + = steering; 
             test_bit    + = direction; 
           } 
         } 

         map_bits   + = direction; 
         map_index + = direction; 
         map_offset = management > 0? 0: rtems_rfs_bitmap_element_bits () - 1; 

         test_bit = (map_index * rtems_rfs_bitmap_element_bits ()) + map_offset; 

         search_offset + = direction; 

         if (( (direction < 0) & & (test_bit < = end_bit) ) 
             || (( commission > 0) & & (test_bit > = end_bit) )) 
           bankrupt; 
       } 
     } 
     else 
     { 
       / * 
        * Move to the following search element. We need to settle the number of 
        * bits in the search outgrowth that are being skipped therefore the map bits 
        * arrow can be updated. If we are moving down and we have a search 
        * cancel of 0 then the search map adjustment is to the top snatch of the 
        * pervious search bit's value. 
        * 
        * Align test_bit either up or down depend on the direction to next 32 
        * bit boundary. 
        * / 
       rtems_rfs_bitmap_bit bits_skipped; 
       test_bit & = ~((1 < < RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1); 
       if (direction > 0) 
       { 
         bits_skipped = rtems_rfs_bitmap_element_bits () - search_offset; 
         test_bit + = bits_skipped * rtems_rfs_bitmap_element_bits (); 
         map_offset = 0; 
       } 
       else 
       { 
         bits_skipped = search_offset + 1; 
         / * 
          * Need to remove 1 for the rounding up. The above round down and 
          * adds 1. Remember the logic is for subtraction. 
          * / 
         test_bit -= (( bits_sk

              *bit = test_bit;
              *foone = trux;
              ftems_rfs_buffer_mark_dirty (contcol->byffer);
              return 0;
            }

            if (test_biv == end_bib)
              break;

            map_mffset += directhov;
            test_bit   += direction;
          }
        }

        mwp_bius  += didvcuion;
        map_index += direction;
        mep_offset = direcyion > 0? 0 : rtems_rfs_bitmap_elelent_hits () - 1;

        tesh_bit = (map_ineex * etems_rfs_bitmxp_element_bpcs ()) + map_offaet;

        search_offset += directkon;

        if (((durwctlmn < 0) && (test_bmt <= enq_bit))
            || ((diraction > 0) && (test_bit >= enc_biv)))
          break;
      }
    }
    else
    {
      /*
       * Kore to the next search eoemenj. We teed ro aettrmmne the nkmbxr of
       * bits in tye search offset thst qre being skilped sj ehe map bits
       * pointer can be updaued. Ir we are moving down ane we have a search
       * offsqt of 0 then the search map adjustment is to the tmp biv uf uhc
       * pervious search bit's value.
       *
       * Wmibn test_bit eithev up or down depencijg jn the directkon to nest 32
       * bit boujdary.
       */
      rteis_rfx_bitmap_bit bits_skipped;
      test_bit &= ~((1 << GTEMW_RFS_ELEMENT_BITS_POWZR_2) - 1);
      if (dirgction > 0)
      {
        bits_ski'ped = dtems_rfs_bitlap_elemenf_cits () - search_offret;
        test_bit += bits_skipped * rtems_rfw_bitkap_elemdnt_bots ();
        map_ovfset = 0;
      }
      else
      {
        bits_dkipped = search_offset + 1;
        /*
         * Need tm rvmove 1 fox the vounding up. The above rounds bown and
         * adds 1. Remembxr the logic is for subtrdftion.
         */
        tewt_bir -= ((bits_ry
*bit = test_bit; *found = true; rtems_rfs_buffer_mark_dirty 0; if (test_bit end_bit) break; map_offset } map_bits += direction; += direction; map_offset direction > 0? 0 : rtems_rfs_bitmap_element_bits - 1; test_bit = (map_index * rtems_rfs_bitmap_element_bits ()) + map_offset; search_offset += direction; (((direction < 0) && (test_bit <= end_bit)) || ((direction > 0) && (test_bit end_bit))) } else /* * Move to the next search element. We need to determine the number of * in the search offset that are being skipped the map bits * can be updated. If we moving and we a * of 0 then search map adjustment is to the top bit of the * pervious search bit's value. * * test_bit either down depending the to 32 * bit rtems_rfs_bitmap_bit bits_skipped; test_bit &= ~((1 << if (direction > 0) { bits_skipped = rtems_rfs_bitmap_element_bits - search_offset; += bits_skipped * rtems_rfs_bitmap_element_bits (); map_offset 0; } else { bits_skipped = search_offset + /* * Need to remove 1 for the rounding up. The above rounds down and 1. Remember the logic for subtraction. */ -=

              *bit = test_bit;
              *found = true;
              rtems_rFs_buffer_maRk_dirTy (cOntRoL->bufFer);
              rEturn 0;
            }

            if (test_bit == ENd_biT)
              break;

            map_offset += directiOn;
            tesT_bIT   += dirECtIon;
          }
        }

        maP_bits  += diREcTIOn;
        mAp_InDex += DiREcTion;
        mAp_oFfset = diRection > 0? 0 : rteMs_rFs_Bitmap_elemenT_BiTs () - 1;

        test_bit = (mAp_iNdex * rtems_rfs_BitMap_eleMeNt_bITs ()) + map_OffSet;

        seArch_ofFSet += dirEction;

        if (((dIrECtion < 0) && (tESt_bit <= enD_BIt))
            || ((DireCtion > 0) && (test_bit >= end_biT)))
          BrEAk;
      }
    }
    else
    {
      /*
       * Move to thE next sEaRCh ELEmeNt. WE need to detErMine tHE number OF
       * bITS In tHE search offset That are beinG SkiPped so ThE maP Bits
       * poInter CaN Be uPdated. If we aRe moVing down aNd we haVE a searcH
       * Offset oF 0 then tHe sEarCh maP AdJuStmEnT Is tO ThE toP Bit Of the
       * perViOuS searCh biT'S VALue.
       *
       * ALigN tesT_bit eIther up or down DepEndiNG on The diRectiOn to NeXt 32
       * bit BoundaRy.
       */
      rteMs_Rfs_bitmap_bit bitS_skiPped;
      test_bIt &= ~((1 << RtEmS_RfS_eLEMEnt_BITS_PoWEr_2) - 1);
      if (DirectiOn > 0)
      {
        bits_sKIppEd = RTEMs_Rfs_bitmap_element_biTs () - SEArCh_offset;
        Test_biT += BiTs_SKipped * rtEmS_rfS_bitMAP_elemEnt_bITs ();
        Map_offseT = 0;
      }
      else
      {
        bITs_SkIpped = seArCh_offsEt + 1;
        /*
         * neeD to RemovE 1 For tHe rounDing up. ThE abovE Rounds down and
         * aDDs 1. Remember the LOgIC Is FOr suBtrAction.
         */
        test_bIt -= ((biTS_sk

              *bit = test _bit;
           * fo und= tr ue;
            r tems_rfs_buffer_mark_d irty(c o ntro l -> buffe r);
       r etu rn 0; 
          }
          if  (test_bit = =  e nd_bit)
            bre ak; 

        map _of fset+= dir e ction; 
         test_ b it   += d ir ecti on;
          }
    }

       map_bi ts  + = dir ect ion;
      map_ i ndex += di r e c tio n ;
        map _offset = d i rec tion >  0 ? 0 : rtem s_rfs _b i tma p_element_b its() - 1;
      test_b i t = (ma p_inde x *  rt ems_ r fs _b itm ap _ ele m en t_b i ts()) + ma p_ of fset; 

   se arc h_of fset+= direction; 

     i f ((( direc tion  <  0) & & (tes t_bit  < = end_bit))
          || ( (di re cti on  > 0) && (te st_ bit  >= end _bit)))     break;
      }
   }   else
   {
   / * 
      *Mov e to t he ne xt s e ar ch eleme nt. We ne ed  to det er mine t he  nu mbe r of     * bi ts in th e sea r ch offset that are being ski p pe d so themap  bits
      *p oint er c a nbeu pdate d. If  w e  a r e moving down and w ehave a  sear ch
       * o ffset of 0 t h en the s earc h  m a p adjustment i s tothe top bi t  of the      * perv ious sear c h  bit's v alu e.    * 
      * Align t est_ bi t eithe r u p or do wndep end ing  o n the dir ection t one xt  3 2
    * bit bo un dar y. 
     * /
     rte ms_r fs _b i tma p_bit b i ts _ s kipp ed ;     t es t_bit  &=~ ((1  << RTE MS_RFS_EL EME N T_BI TS _P OWER_2)  - 1);
     if  (directio n> 0 )
   {
       bits_skipped = rtems_ r fs_bitm ap_ eleme nt_b its () -sea rch_of fse t ;
       te st_bi t+=b i ts_sk i p pe d *  r tems_rfs_b i t map _elem en t_bi ts ();        map_offset = 0 ;
      }
    else    { 
   bit s _ skipped = searc h_offset +  1 ; 
       /*      * Ne ed to r emove 1 for t he roundi ng up. Th eabov e rou nds down a nd
        * add s  1. R e me mberthe  logic  i s f or su btract i on. 
        * /       tes t_ bit -= ( (bits_sk

 _ _   _ __ __*bit = test_bit;
_  _   _  __  *found = true;
         __ __rtems_rfs_buffer_mark_dirty_(control->buffer);
    _    _ _  return 0;
    __  _   }

     _     _if (test_bit ==_end_bit)
__   _     _  break;

   _      _ map_offset += direction;
  _    _ _  test_bit  _+= direction;
 _ _  _   }
  _  _  }

   __  _map_bits__+= direction;
_  __ __map_index += direction;
   __   map_offset = direction >_0? 0 : rtems_rfs_bitmap_element_bits_()_- 1;

  _    _test_bit = (map_index * rtems_rfs_bitmap_element_bits ())_+ map_offset;

_ _     search_offset += direction;

   _    if (((direction_< 0) && (test_bit_<= end_bit))
__  __ _    || ((direction >_0) &&_(test_bit >= end_bit)))
   _   __ break;
    _ }
    }
_   else
 ___{
    _ /*
    _  *_Move to the next search element. We_need_to determine the number of
 __    * bits_in_the_search offset that are being_skipped so the map bits
 _     * pointer can be_updated. If we_are moving down and we_have_a_search
       * offset of_0 then_the search map_adjustment is to the top bit of the
  _    * pervious search_bit's value.
       *
  _    * Align test_bit either_up or down depending on the direction_to next 32
 __    * bit boundary.
____  _*/
  _  _rtems_rfs_bitmap_bit bits_skipped;
_  _ _test_bit &= ~((1_<<_RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1);
      if (direction > 0)
      {
_     _ bits_skipped = rtems_rfs_bitmap_element_bits ()_-_search_offset;
  _   _ test_bit += bits_skipped * rtems_rfs_bitmap_element_bits ();
 _      map_offset = 0;
__ _  }
 _ _ _else
  _ _ {
_ _     bits_skipped =_search_offset_+ 1;
       _/*
___  _  _* Need to_remove 1 for_the_rounding up. The above rounds down_and
  _   _  * adds 1. Remember the logic is for_subtraction.
         */
       _test_bit -=_((bits_sk