Back to index

glibc  2.9
Functions
rshift.c File Reference
#include <gmp.h>
#include "gmp-impl.h"

Go to the source code of this file.

Functions

mp_limb_t mpn_rshift (mp_ptr wp, mp_srcptr up, mp_size_t usize, unsigned int cnt)

Function Documentation

mp_limb_t mpn_rshift ( mp_ptr  wp,
mp_srcptr  up,
mp_size_t  usize,
unsigned int  cnt 
)

Definition at line 40 of file rshift.c.

{
  register mp_limb_t high_limb, low_limb;
  register unsigned sh_1, sh_2;
  register mp_size_t i;
  mp_limb_t retval;

#ifdef DEBUG
  if (usize == 0 || cnt == 0)
    abort ();
#endif

  sh_1 = cnt;

#if 0
  if (sh_1 == 0)
    {
      if (wp != up)
       {
         /* Copy from low end to high end, to allow specified input/output
            overlapping.  */
         for (i = 0; i < usize; i++)
           wp[i] = up[i];
       }
      return usize;
    }
#endif

  wp -= 1;
  sh_2 = BITS_PER_MP_LIMB - sh_1;
  high_limb = up[0];
  retval = high_limb << sh_2;
  low_limb = high_limb;

  for (i = 1; i < usize; i++)
    {
      high_limb = up[i];
      wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
      low_limb = high_limb;
    }
  wp[i] = low_limb >> sh_1;

  return retval;
}

Here is the call graph for this function: