summaryrefslogtreecommitdiffstats
path: root/lib/msun
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2013-06-05 05:33:01 +0000
committerdas <das@FreeBSD.org>2013-06-05 05:33:01 +0000
commit16f58a23858b9b290bd20b39bf643e8b0869e184 (patch)
treef22b4fedcc606eb0b7ccbd4ae8136df87d126c3a /lib/msun
parentf228730cd01207092a30e3c540b85818990759fa (diff)
downloadFreeBSD-src-16f58a23858b9b290bd20b39bf643e8b0869e184.zip
FreeBSD-src-16f58a23858b9b290bd20b39bf643e8b0869e184.tar.gz
Style fixes.
Submitted by: bde
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/Makefile13
-rw-r--r--lib/msun/src/catrig.c42
-rw-r--r--lib/msun/src/catrigf.c55
-rw-r--r--lib/msun/src/e_log2.c2
4 files changed, 58 insertions, 54 deletions
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index fab09f9..43e4b0b 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -21,6 +21,10 @@ ARCH_SUBDIR= ${MACHINE_CPUARCH}
.include "${ARCH_SUBDIR}/Makefile.inc"
.PATH: ${.CURDIR}/${ARCH_SUBDIR}
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+.PATH: ${.CURDIR}/x86
+CFLAGS+= -I${.CURDIR}/x86
+.endif
# long double format
.if ${LDBL_PREC} == 64
@@ -35,10 +39,6 @@ CFLAGS+= -I${.CURDIR}/ld128
.PATH: ${.CURDIR}/src
.PATH: ${.CURDIR}/man
-.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
-.PATH: ${.CURDIR}/x86
-.endif
-
LIB= m
SHLIBDIR?= /lib
SHLIB_MAJOR= 5
@@ -187,8 +187,9 @@ MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3
MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3
MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 lgammaf.3 \
lgamma.3 tgamma.3 lgamma.3 tgammaf.3
-MLINKS+=log.3 log10.3 log.3 log10f.3 log.3 log10l.3 log.3 \
- log1p.3 log.3 log1pf.3 log.3 log1pl.3 log.3 logf.3 log.3 logl.3 \
+MLINKS+=log.3 log10.3 log.3 log10f.3 log.3 log10l.3 \
+ log.3 log1p.3 log.3 log1pf.3 log.3 log1pl.3 \
+ log.3 logf.3 log.3 logl.3 \
log.3 log2.3 log.3 log2f.3 log.3 log2l.3
MLINKS+=lrint.3 llrint.3 lrint.3 llrintf.3 lrint.3 llrintl.3 \
lrint.3 lrintf.3 lrint.3 lrintl.3
diff --git a/lib/msun/src/catrig.c b/lib/msun/src/catrig.c
index f69a337..200977c 100644
--- a/lib/msun/src/catrig.c
+++ b/lib/msun/src/catrig.c
@@ -151,13 +151,13 @@ f(double a, double b, double hypot_a_b)
*/
static inline void
do_hard_work(double x, double y, double *rx, int *B_is_usable, double *B,
- double *sqrt_A2my2, double *new_y)
+ double *sqrt_A2my2, double *new_y)
{
double R, S, A; /* A, B, R, and S are as in Hull et al. */
double Am1, Amy; /* A-1, A-y. */
- R = hypot(x, y + 1); /* |z+I| */
- S = hypot(x, y - 1); /* |z-I| */
+ R = hypot(x, y + 1); /* |z+I| */
+ S = hypot(x, y - 1); /* |z-I| */
/* A = (|z+I| + |z-I|) / 2 */
A = (R + S) / 2;
@@ -174,7 +174,7 @@ do_hard_work(double x, double y, double *rx, int *B_is_usable, double *B,
* Am1 = fp + fm, where fp = f(x, 1+y), and fm = f(x, 1-y).
* rx = log1p(Am1 + sqrt(Am1*(A+1)))
*/
- if (y == 1 && x < DBL_EPSILON*DBL_EPSILON / 128) {
+ if (y == 1 && x < DBL_EPSILON * DBL_EPSILON / 128) {
/*
* fp is of order x^2, and fm = x/2.
* A = 1 (inexactly).
@@ -193,7 +193,7 @@ do_hard_work(double x, double y, double *rx, int *B_is_usable, double *B,
* A = 1 (inexactly).
*/
*rx = x / sqrt((1 - y) * (1 + y));
- } else /* if (y > 1) */ {
+ } else { /* if (y > 1) */
/*
* A-1 = y-1 (inexactly).
*/
@@ -251,9 +251,9 @@ do_hard_work(double x, double y, double *rx, int *B_is_usable, double *B,
* scaling should avoid any underflow problems.
*/
*sqrt_A2my2 = x * (4 / DBL_EPSILON / DBL_EPSILON) * y /
- sqrt((y + 1) * (y - 1));
+ sqrt((y + 1) * (y - 1));
*new_y = y * (4 / DBL_EPSILON / DBL_EPSILON);
- } else /* if (y < 1) */ {
+ } else { /* if (y < 1) */
/*
* fm = 1-y >= DBL_EPSILON, fp is of order x^2, and
* A = 1 (inexactly).
@@ -298,7 +298,6 @@ casinh(double complex z)
* C99 leaves it optional whether to raise invalid if one of
* the arguments is not NaN, so we opt not to raise it.
*/
- /* Bruce Evans tells me this is the way to do this: */
return (cpack(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
}
@@ -337,6 +336,7 @@ double complex
casin(double complex z)
{
double complex w = casinh(cpack(cimag(z), creal(z)));
+
return (cpack(cimag(w), creal(w)));
}
@@ -402,17 +402,17 @@ cacos(double complex z)
/* All remaining cases are inexact. */
raise_inexact();
- if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON/4)
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
return (cpack(pio2_hi - (x - pio2_lo), -y));
do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x);
if (B_is_usable) {
- if (sx==0)
+ if (sx == 0)
rx = acos(B);
else
rx = acos(-B);
} else {
- if (sx==0)
+ if (sx == 0)
rx = atan2(sqrt_A2mx2, new_x);
else
rx = atan2(sqrt_A2mx2, -new_x);
@@ -488,10 +488,6 @@ clog_for_large_values(double complex z)
}
/*
- *=============================================================================
- */
-
-/*
* =================
* | catanh, catan |
* =================
@@ -511,6 +507,7 @@ sum_squares(double x, double y)
/* Avoid underflow when y is small. */
if (y < SQRT_MIN)
return (x * x);
+
return (x * x + y * y);
}
@@ -578,7 +575,7 @@ catanh(double complex z)
/* This helps handle many cases. */
if (y == 0 && ax <= 1)
- return (cpack(atanh(x), y));
+ return (cpack(atanh(x), y));
/* To ensure the same accuracy as atan(), and to filter out z = 0. */
if (x == 0)
@@ -589,10 +586,9 @@ catanh(double complex z)
if (isinf(x))
return (cpack(copysign(0, x), y + y));
/* catanh(NaN + I*+-Inf) = sign(NaN)0 + I*+-PI/2 */
- if (isinf(y)) {
+ if (isinf(y))
return (cpack(copysign(0, x),
- copysign(pio2_hi + pio2_lo, y)));
- }
+ copysign(pio2_hi + pio2_lo, y)));
/*
* All other cases involving NaN return NaN + I*NaN.
* C99 leaves it optional whether to raise invalid if one of
@@ -601,10 +597,9 @@ catanh(double complex z)
return (cpack(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
}
- if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
return (cpack(real_part_reciprocal(x, y),
- copysign(pio2_hi + pio2_lo, y)));
- }
+ copysign(pio2_hi + pio2_lo, y)));
if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) {
/*
@@ -617,7 +612,7 @@ catanh(double complex z)
}
if (ax == 1 && ay < DBL_EPSILON)
- rx = (log(ay) - m_ln2) / -2;
+ rx = (m_ln2 - log(ay)) / 2;
else
rx = log1p(4 * ax / sum_squares(ax - 1, ay)) / 4;
@@ -639,5 +634,6 @@ double complex
catan(double complex z)
{
double complex w = catanh(cpack(cimag(z), creal(z)));
+
return (cpack(cimag(w), creal(w)));
}
diff --git a/lib/msun/src/catrigf.c b/lib/msun/src/catrigf.c
index cf0caef..08ebef7 100644
--- a/lib/msun/src/catrigf.c
+++ b/lib/msun/src/catrigf.c
@@ -31,7 +31,11 @@
* Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335,
* http://dl.acm.org/citation.cfm?id=275324.
*
- * The code for catrig.c contains complete comments.
+ * See catrig.c for complete comments.
+ *
+ * XXX comments were removed automatically, and even short ones on the right
+ * of statements were removed (all of them), contrary to normal style. Only
+ * a few comments on the right of declarations remain.
*/
#include <sys/cdefs.h>
@@ -82,7 +86,7 @@ f(float a, float b, float hypot_a_b)
static inline void
do_hard_work(float x, float y, float *rx, int *B_is_usable, float *B,
- float *sqrt_A2my2, float *new_y)
+ float *sqrt_A2my2, float *new_y)
{
float R, S, A;
float Am1, Amy;
@@ -101,7 +105,7 @@ do_hard_work(float x, float y, float *rx, int *B_is_usable, float *B,
Am1 = f(x, 1 + y, R) + f(x, 1 - y, S);
*rx = log1pf(Am1 + sqrtf(Am1 * (A + 1)));
} else if (y < 1) {
- *rx = x / sqrtf((1 - y)*(1 + y));
+ *rx = x / sqrtf((1 - y) * (1 + y));
} else {
*rx = log1pf((y - 1) + sqrtf((y - 1) * (y + 1)));
}
@@ -130,7 +134,7 @@ do_hard_work(float x, float y, float *rx, int *B_is_usable, float *B,
*sqrt_A2my2 = sqrtf(Amy * (A + y));
} else if (y > 1) {
*sqrt_A2my2 = x * (4 / FLT_EPSILON / FLT_EPSILON) * y /
- sqrtf((y + 1) * (y - 1));
+ sqrtf((y + 1) * (y - 1));
*new_y = y * (4 / FLT_EPSILON / FLT_EPSILON);
} else {
*sqrt_A2my2 = sqrtf((1 - y) * (1 + y));
@@ -166,7 +170,7 @@ casinhf(float complex z)
else
w = clog_for_large_values(-z) + m_ln2;
return (cpackf(copysignf(crealf(w), x),
- copysignf(cimagf(w), y)));
+ copysignf(cimagf(w), y)));
}
if (x == 0 && y == 0)
@@ -189,6 +193,7 @@ float complex
casinf(float complex z)
{
float complex w = casinhf(cpackf(cimagf(z), crealf(z)));
+
return (cpackf(cimagf(w), crealf(w)));
}
@@ -212,7 +217,8 @@ cacosf(float complex z)
return (cpackf(y + y, -INFINITY));
if (isinf(y))
return (cpackf(x + x, -y));
- if (x == 0) return (cpackf(pio2_hi + pio2_lo, y + y));
+ if (x == 0)
+ return (cpackf(pio2_hi + pio2_lo, y + y));
return (cpackf(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
}
@@ -235,17 +241,17 @@ cacosf(float complex z)
do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x);
if (B_is_usable) {
- if (sx==0)
+ if (sx == 0)
rx = acosf(B);
else
rx = acosf(-B);
} else {
- if (sx==0)
+ if (sx == 0)
rx = atan2f(sqrt_A2mx2, new_x);
else
rx = atan2f(sqrt_A2mx2, -new_x);
}
- if (sy==0)
+ if (sy == 0)
ry = -ry;
return (cpackf(rx, ry));
}
@@ -284,10 +290,9 @@ clog_for_large_values(float complex z)
ay = t;
}
- if (ax > FLT_MAX / 2) {
+ if (ax > FLT_MAX / 2)
return (cpackf(logf(hypotf(x / m_e, y / m_e)) + 1,
- atan2f(y, x)));
- }
+ atan2f(y, x)));
if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN)
return (cpackf(logf(hypotf(x, y)), atan2f(y, x)));
@@ -300,8 +305,9 @@ sum_squares(float x, float y)
{
if (y < SQRT_MIN)
- return (x*x);
- return (x*x + y*y);
+ return (x * x);
+
+ return (x * x + y * y);
}
static inline float
@@ -318,9 +324,9 @@ real_part_reciprocal(float x, float y)
#define BIAS (FLT_MAX_EXP - 1)
#define CUTOFF (FLT_MANT_DIG / 2 + 1)
if (ix - iy >= CUTOFF << 23 || isinf(x))
- return (1/x);
+ return (1 / x);
if (iy - ix >= CUTOFF << 23)
- return (x/y/y);
+ return (x / y / y);
if (ix <= (BIAS + FLT_MAX_EXP / 2 - CUTOFF) << 23)
return (x / (x * x + y * y));
SET_FLOAT_WORD(scale, 0x7f800000 - ix);
@@ -340,25 +346,23 @@ catanhf(float complex z)
ay = fabsf(y);
if (y == 0 && ax <= 1)
- return (cpackf(atanhf(x), y));
+ return (cpackf(atanhf(x), y));
if (x == 0)
return (cpackf(x, atanf(y)));
if (isnan(x) || isnan(y)) {
if (isinf(x))
- return (cpackf(copysignf(0, x), y+y));
- if (isinf(y)) {
+ return (cpackf(copysignf(0, x), y + y));
+ if (isinf(y))
return (cpackf(copysignf(0, x),
- copysignf(pio2_hi + pio2_lo, y)));
- }
+ copysignf(pio2_hi + pio2_lo, y)));
return (cpackf(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
}
- if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
return (cpackf(real_part_reciprocal(x, y),
- copysignf(pio2_hi + pio2_lo, y)));
- }
+ copysignf(pio2_hi + pio2_lo, y)));
if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) {
raise_inexact();
@@ -366,7 +370,7 @@ catanhf(float complex z)
}
if (ax == 1 && ay < FLT_EPSILON)
- rx = (logf(ay) - m_ln2) / -2;
+ rx = (m_ln2 - logf(ay)) / 2;
else
rx = log1pf(4 * ax / sum_squares(ax - 1, ay)) / 4;
@@ -384,5 +388,6 @@ float complex
catanf(float complex z)
{
float complex w = catanhf(cpackf(cimagf(z), crealf(z)));
+
return (cpackf(cimagf(w), crealf(w)));
}
diff --git a/lib/msun/src/e_log2.c b/lib/msun/src/e_log2.c
index d737f04..4766cdb 100644
--- a/lib/msun/src/e_log2.c
+++ b/lib/msun/src/e_log2.c
@@ -24,6 +24,8 @@ __FBSDID("$FreeBSD$");
* in not-quite-routine extra precision.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
#include "k_log.h"
OpenPOWER on IntegriCloud