Merge from vendor branch GDB:
[dragonfly.git] / lib / msun / src / w_scalb.c
1 /* @(#)w_scalb.c 5.1 93/09/24 */
2 /*
3  * ====================================================
4  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5  *
6  * Developed at SunPro, a Sun Microsystems, Inc. business.
7  * Permission to use, copy, modify, and distribute this
8  * software is freely granted, provided that this notice
9  * is preserved.
10  * ====================================================
11  *
12  * $FreeBSD: src/lib/msun/src/w_scalb.c,v 1.5 1999/08/28 00:07:08 peter Exp $
13  * $DragonFly: src/lib/msun/src/Attic/w_scalb.c,v 1.3 2004/12/29 15:22:57 asmodai Exp $
14  */
15
16 /*
17  * wrapper scalb(double x, double fn) is provide for
18  * passing various standard test suite. One
19  * should use scalbn() instead.
20  */
21
22 #include "math.h"
23 #include "math_private.h"
24
25 #include <errno.h>
26
27 #ifdef _SCALB_INT
28         double scalb(double x, int fn)          /* wrapper scalb */
29 #else
30         double scalb(double x, double fn)       /* wrapper scalb */
31 #endif
32 {
33 #ifdef _IEEE_LIBM
34         return __ieee754_scalb(x,fn);
35 #else
36         double z;
37         z = __ieee754_scalb(x,fn);
38         if(_LIB_VERSION == _IEEE_) return z;
39         if(!(finite(z)||isnan(z))&&finite(x)) {
40             return __kernel_standard(x,(double)fn,32); /* scalb overflow */
41         }
42         if(z==0.0&&z!=x) {
43             return __kernel_standard(x,(double)fn,33); /* scalb underflow */
44         }
45 #ifndef _SCALB_INT
46         if(!finite(fn)) errno = ERANGE;
47 #endif
48         return z;
49 #endif
50 }