8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / libc / gen / common / _base_il.c
blob45a1b875daba79b160d198413a97a480e673090e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "base_conversion.h"
31 /* The following should be coded as inline expansion templates. */
34 * Fundamental utilities that multiply two shorts into a unsigned long, add
35 * carry, compute quotient and remainder in underlying base, and return
36 * quo<<16 | rem as a unsigned long.
40 * C compilers tend to generate bad code - forcing full unsigned long by
41 * unsigned long multiplies when what is really wanted is the unsigned long
42 * product of half-long operands. Similarly the quotient and remainder are
43 * all half-long. So these functions should really be implemented by inline
44 * expansion templates.
47 /* p = x * y + c ; return p */
48 unsigned long
49 _umac(_BIG_FLOAT_DIGIT x, _BIG_FLOAT_DIGIT y, unsigned long c)
51 return (x * (unsigned long) y + c);
54 /* p = x + c ; return (p/10000 << 16 | p%10000) */
55 unsigned long
56 _carry_in_b10000(_BIG_FLOAT_DIGIT x, long unsigned c)
58 unsigned long p = x + c ;
60 return ((p / 10000) << 16) | (p % 10000);
63 void
64 _carry_propagate_two(unsigned long carry, _BIG_FLOAT_DIGIT *psignificand)
67 * Propagate carries in a base-2**16 significand.
70 long unsigned p;
71 int j;
73 j = 0;
74 while (carry != 0) {
75 p = _carry_in_b65536(psignificand[j],carry);
76 psignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
77 carry = p >> 16;
81 void
82 _carry_propagate_ten(unsigned long carry, _BIG_FLOAT_DIGIT *psignificand)
85 * Propagate carries in a base-10**4 significand.
88 int j;
89 unsigned long p;
91 j = 0;
92 while (carry != 0) {
93 p = _carry_in_b10000(psignificand[j],carry);
94 psignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
95 carry = p >> 16;