/* $NetBSD: gmisc.c,v 1.3 2006/03/11 18:38:14 kleink Exp $ */

/****************************************************************

The author of this software is David M. Gay.

Copyright (C) 1998 by Lucent Technologies
All Rights Reserved

Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.

LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

****************************************************************/

/* Please send bug reports to David M. Gay (dmg at acm dot org,
 * with " at " changed at "@" and " dot " changed to ".").  */
#include  <LibConfig.h>

#include "gdtoaimp.h"

 void
rshift(Bigint *b, int k)
{
  ULong *x, *x1, *xe, y;
  int n;

  x = x1 = b->x;
  n = (unsigned int)k >> kshift;
  if (n < b->wds) {
    xe = x + b->wds;
    x += n;
    if (k &= kmask) {
      n = ULbits - k;
      y = *x++ >> k;
      while(x < xe) {
        *x1++ = (y | (*x << n)) & ALL_ON;
        y = *x++ >> k;
        }
      if ((*x1 = y) !=0)
        x1++;
      }
    else
      while(x < xe)
        *x1++ = *x++;
    }
  if ((b->wds = (int)(x1 - b->x)) == 0)
    b->x[0] = 0;
  }

 int
trailz(CONST Bigint *b)
{
  ULong L;
  CONST ULong *x, *xe;
  int n = 0;

  x = b->x;
  xe = x + b->wds;
  for(n = 0; x < xe && !*x; x++)
    n += ULbits;
  if (x < xe) {
    L = *x;
    n += lo0bits(&L);
    }
  return n;
  }
