Back to index

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

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 40 of file lshift.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 high end to low end, to allow specified input/output
            overlapping.  */
         for (i = usize - 1; i >= 0; i--)
           wp[i] = up[i];
       }
      return 0;
    }
#endif

  wp += 1;
  sh_2 = BITS_PER_MP_LIMB - sh_1;
  i = usize - 1;
  low_limb = up[i];
  retval = low_limb >> sh_2;
  high_limb = low_limb;
  while (--i >= 0)
    {
      low_limb = up[i];
      wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
      high_limb = low_limb;
    }
  wp[i] = high_limb << sh_1;

  return retval;
}

Here is the call graph for this function: