Module Name:    src
Committed By:   martin
Date:           Fri Nov 22 13:37:24 UTC 2013

Modified Files:
        src/lib/libm: Makefile
        src/lib/libm/src: e_sqrtl.c

Log Message:
Try to fix the build (again): move e_sqrtl.c to common soure, but
move the include of fenv.h into the #ifdef __HAVE_LONG_DOUBLE block
and also provide a -DHAVE_FENV_H from the makefile for archs that have
it - leaving out exception settings on architectures that do not provide
it.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/lib/libm/Makefile
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/src/e_sqrtl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.151 src/lib/libm/Makefile:1.152
--- src/lib/libm/Makefile:1.151	Thu Nov 21 11:21:54 2013
+++ src/lib/libm/Makefile	Fri Nov 22 13:37:24 2013
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.151 2013/11/21 11:21:54 martin Exp $
+#  $NetBSD: Makefile,v 1.152 2013/11/22 13:37:24 martin Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -53,6 +53,7 @@ ARCH_SRCS = s_copysign.S s_copysignf.S l
 .elif (${MACHINE_CPU} == "arm")
 .PATH: ${.CURDIR}/arch/arm
 COMMON_SRCS+= fenv.c
+COPTS.e_sqrtl.c += -DHAVE_FENV_H
 .if (${MKSOFTFLOAT} == "no")
 ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
 .else
@@ -63,11 +64,13 @@ ${i} ${i:.o=.po} ${i:.o=.pico} ${i:.o=.g
 .elif (${MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
 COMMON_SRCS+= fenv.c
+COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${MACHINE_ARCH} == "sparc64")
 .PATH: ${.CURDIR}/arch/sparc64
 COMMON_SRCS+= fenv.c s_nexttowardf.c \
-	s_nearbyint.c s_rintl.c e_sqrtl.c
+	s_nearbyint.c s_rintl.c
+COPTS.e_sqrtl.c += -DHAVE_FENV_H
 .ifndef _COMPAT_M32_MK_
 COMMON_SRCS+= s_nexttoward.c
 .endif
@@ -80,8 +83,9 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .PATH:	${.CURDIR}/arch/i387
 
 COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.c \
-	s_nearbyint.c s_rintl.c e_sqrtl.c
+	s_nearbyint.c s_rintl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
+COPTS.e_sqrtl.c += -DHAVE_FENV_H
 
 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
 	    e_logf.S e_log10.S e_log10f.S e_log2.S e_log2f.S e_remainder.S \
@@ -156,7 +160,7 @@ COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c
 	e_j1.c e_j1f.c e_jn.c e_jnf.c e_lgamma_r.c e_lgammaf_r.c e_log.c \
 	e_log2.c e_log10.c e_log10f.c e_log2f.c e_logf.c e_pow.c e_powf.c \
 	e_rem_pio2.c e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c \
-	e_scalbf.c e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c \
+	e_scalbf.c e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c e_sqrtl.c \
 	k_cos.c k_cosf.c k_rem_pio2.c k_rem_pio2f.c k_sin.c k_sinf.c \
 	k_standard.c k_tan.c k_tanf.c \
 	ldbl_dummy.c \

Index: src/lib/libm/src/e_sqrtl.c
diff -u src/lib/libm/src/e_sqrtl.c:1.2 src/lib/libm/src/e_sqrtl.c:1.3
--- src/lib/libm/src/e_sqrtl.c:1.2	Wed Nov 20 21:12:30 2013
+++ src/lib/libm/src/e_sqrtl.c	Fri Nov 22 13:37:24 2013
@@ -28,10 +28,9 @@
 #if 0
 __FBSDID("$FreeBSD: head/lib/msun/src/e_sqrtl.c 176720 2008-03-02 01:47:58Z das $");
 #endif
-__RCSID("$NetBSD: e_sqrtl.c,v 1.2 2013/11/20 21:12:30 martin Exp $");
+__RCSID("$NetBSD: e_sqrtl.c,v 1.3 2013/11/22 13:37:24 martin Exp $");
 
 #include <machine/ieee.h>
-#include <fenv.h>
 #include <float.h>
 
 #include "math.h"
@@ -39,6 +38,10 @@ __RCSID("$NetBSD: e_sqrtl.c,v 1.2 2013/1
 
 #ifdef __HAVE_LONG_DOUBLE
 
+#ifdef HAVE_FENV_H
+#include <fenv.h>
+#endif
+
 #ifdef LDBL_IMPLICIT_NBIT
 #define	LDBL_NBIT	0
 #endif
@@ -84,7 +87,9 @@ __ieee754_sqrtl(long double x)
 	union ieee_ext_u ux = { .extu_ld = x, };
 	int k, r;
 	long double lo, xn;
+#ifdef HAVE_FENV_H
 	fenv_t env;
+#endif
 
 	/* If x = NaN, then sqrt(x) = NaN. */
 	/* If x = Inf, then sqrt(x) = Inf. */
@@ -100,7 +105,9 @@ __ieee754_sqrtl(long double x)
 	if (ux.extu_sign)
 		return ((x - x) / (x - x));
 
+#ifdef HAVE_FENV_H
 	feholdexcept(&env);
+#endif
 
 	if (ux.extu_exp == 0) {
 		/* Adjust subnormal numbers. */
@@ -143,7 +150,9 @@ __ieee754_sqrtl(long double x)
 
 	if (!fetestexcept(FE_INEXACT)) { /* Quotient is exact. */
 		if (xn == ux.extu_ld) {
+#ifdef HAVE_FENV_H
 			fesetenv(&env);
+#endif
 			return (ux.extu_ld);
 		}
 		/* Round correctly for inputs like x = y**2 - ulp. */
@@ -157,7 +166,9 @@ __ieee754_sqrtl(long double x)
 		xn = inc(xn);		/* xn  = xn + ulp. */
 	}
 	ux.extu_ld = ux.extu_ld + xn;		/* Chopped sum. */
+#ifdef HAVE_FENV_H
 	feupdateenv(&env);	/* Restore env and raise inexact */
+#endif
 	ux.extu_exp--;
 	return (ux.extu_ld);
 }

Reply via email to