1*84d9c625SLionel Sambuc /* @(#)w_sqrt.c 5.1 93/09/24 */
2*84d9c625SLionel Sambuc /*
3*84d9c625SLionel Sambuc * ====================================================
4*84d9c625SLionel Sambuc * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5*84d9c625SLionel Sambuc *
6*84d9c625SLionel Sambuc * Developed at SunPro, a Sun Microsystems, Inc. business.
7*84d9c625SLionel Sambuc * Permission to use, copy, modify, and distribute this
8*84d9c625SLionel Sambuc * software is freely granted, provided that this notice
9*84d9c625SLionel Sambuc * is preserved.
10*84d9c625SLionel Sambuc * ====================================================
11*84d9c625SLionel Sambuc */
12*84d9c625SLionel Sambuc
13*84d9c625SLionel Sambuc #include <sys/cdefs.h>
14*84d9c625SLionel Sambuc __RCSID("$NetBSD: w_sqrtl.c,v 1.2 2013/11/20 11:39:00 joerg Exp $");
15*84d9c625SLionel Sambuc
16*84d9c625SLionel Sambuc /*
17*84d9c625SLionel Sambuc * wrapper sqrtl(x)
18*84d9c625SLionel Sambuc */
19*84d9c625SLionel Sambuc
20*84d9c625SLionel Sambuc #include "namespace.h"
21*84d9c625SLionel Sambuc #include "math.h"
22*84d9c625SLionel Sambuc #include "math_private.h"
23*84d9c625SLionel Sambuc
24*84d9c625SLionel Sambuc #ifdef __HAVE_LONG_DOUBLE
25*84d9c625SLionel Sambuc
__weak_alias(sqrtl,_sqrtl)26*84d9c625SLionel Sambuc __weak_alias(sqrtl, _sqrtl)
27*84d9c625SLionel Sambuc
28*84d9c625SLionel Sambuc long double
29*84d9c625SLionel Sambuc sqrtl(long double x) /* wrapper sqrtl */
30*84d9c625SLionel Sambuc {
31*84d9c625SLionel Sambuc #ifdef _IEEE_LIBM
32*84d9c625SLionel Sambuc return __ieee754_sqrtl(x);
33*84d9c625SLionel Sambuc #else
34*84d9c625SLionel Sambuc long double z;
35*84d9c625SLionel Sambuc z = __ieee754_sqrtl(x);
36*84d9c625SLionel Sambuc if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
37*84d9c625SLionel Sambuc if(x<0.0) {
38*84d9c625SLionel Sambuc return __kernel_standard(x,x,226); /* sqrtl(negative) */
39*84d9c625SLionel Sambuc } else
40*84d9c625SLionel Sambuc return z;
41*84d9c625SLionel Sambuc #endif
42*84d9c625SLionel Sambuc }
43*84d9c625SLionel Sambuc
44*84d9c625SLionel Sambuc #endif /* __HAVE_LONG_DOUBLE */
45