Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/m9x/scalblnf.c
+++ new/usr/src/lib/libm/common/m9x/scalblnf.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 +
25 26 /*
26 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 28 * Use is subject to license terms.
28 29 */
29 30
30 31 #pragma weak __scalblnf = scalblnf
31 32
32 33 #include "libm.h"
33 -#include <float.h> /* FLT_MAX, FLT_MIN */
34 +#include <float.h> /* FLT_MAX, FLT_MIN */
34 35
35 36 static const float twom25f = 2.98023223876953125e-8F;
37 +
36 38 #if defined(__x86)
37 39 static const float two23f = 8388608.0F;
38 40 #else
39 41 /*
40 42 * v: a non-zero subnormal |x|; returns [-22, 0]
41 43 */
42 44 static int
43 -ilogbf_biased(unsigned v) {
45 +ilogbf_biased(unsigned v)
46 +{
44 47 int r = -22;
45 48
46 49 if (v & 0xffff0000)
47 50 r += 16, v >>= 16;
51 +
48 52 if (v & 0xff00)
49 53 r += 8, v >>= 8;
54 +
50 55 if (v & 0xf0)
51 56 r += 4, v >>= 4;
57 +
52 58 v <<= 1;
53 59 return (r + ((0xffffaa50 >> v) & 0x3));
54 60 }
55 -#endif /* defined(__x86) */
61 +#endif /* defined(__x86) */
56 62
57 63 float
58 -scalblnf(float x, long n) {
59 - int *px = (int *) &x, ix, k;
64 +scalblnf(float x, long n)
65 +{
66 + int *px = (int *)&x, ix, k;
60 67
61 68 ix = *px & ~0x80000000;
62 69 k = ix >> 23;
70 +
63 71 if (k == 0xff)
64 72 #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
65 73 return (ix > 0x7f800000 ? x * x : x);
66 74 #else
67 75 return (x + x);
68 76 #endif
77 +
69 78 if (ix == 0 || n == 0)
70 79 return (x);
80 +
71 81 if (k == 0) {
72 82 #if defined(__x86)
73 83 x *= two23f;
74 84 k = ((*px & ~0x80000000) >> 23) - 23;
75 85 #else
76 86 k = ilogbf_biased(ix);
77 87 *px = (*px & 0x80000000) | (ix << (-k + 1));
78 88 #endif
79 89 }
80 - k += (int) n;
90 +
91 + k += (int)n;
92 +
81 93 if (n > 5000 || k > 0xfe)
82 94 return (FLT_MAX * copysignf(FLT_MAX, x));
95 +
83 96 if (n < -5000 || k <= -25)
84 97 return (FLT_MIN * copysignf(FLT_MIN, x));
98 +
85 99 if (k > 0) {
86 100 *px = (*px & ~0x7f800000) | (k << 23);
87 101 return (x);
88 102 }
103 +
89 104 k += 25;
90 105 *px = (*px & ~0x7f800000) | (k << 23);
91 106 return (x * twom25f);
92 107 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX