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