BSD 4_3_Reno release
[unix-history] / usr / src / lib / libm / common_source / pow.c
index 626a7cf..d89348b 100644 (file)
@@ -3,16 +3,18 @@
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement:  ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
  * from this software without specific prior written permission.
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * from this software without specific prior written permission.
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * All recipients should regard themselves as participants in an ongoing
  * research project and hence should feel obligated to report their
  *
  * All recipients should regard themselves as participants in an ongoing
  * research project and hence should feel obligated to report their
@@ -21,7 +23,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pow.c      5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)pow.c      5.6 (Berkeley) 6/1/90";
 #endif /* not lint */
 
 /* POW(X,Y)  
 #endif /* not lint */
 
 /* POW(X,Y)  
@@ -92,42 +94,34 @@ static char sccsid[] = "@(#)pow.c   5.3 (Berkeley) %G%";
  * shown.
  */
 
  * shown.
  */
 
-#if defined(vax)||defined(tahoe)       /* VAX D format */
 #include <errno.h>
 #include <errno.h>
-extern double infnan();
-#ifdef vax
-#define _0x(A,B)       0x/**/A/**/B
-#else  /* vax */
-#define _0x(A,B)       0x/**/B/**/A
-#endif /* vax */
-/* static double */
-/* ln2hi  =  6.9314718055829871446E-1    , Hex  2^  0   *  .B17217F7D00000 */
-/* ln2lo  =  1.6465949582897081279E-12   , Hex  2^-39   *  .E7BCD5E4F1D9CC */
-/* invln2 =  1.4426950408889634148E0     , Hex  2^  1   *  .B8AA3B295C17F1 */
-/* sqrt2  =  1.4142135623730950622E0     ; Hex  2^  1   *  .B504F333F9DE65 */
-static long     ln2hix[] = { _0x(7217,4031), _0x(0000,f7d0)};
-static long     ln2lox[] = { _0x(bcd5,2ce7), _0x(d9cc,e4f1)};
-static long    invln2x[] = { _0x(aa3b,40b8), _0x(17f1,295c)};
-static long     sqrt2x[] = { _0x(04f3,40b5), _0x(de65,33f9)};
-#define    ln2hi    (*(double*)ln2hix)
-#define    ln2lo    (*(double*)ln2lox)
-#define   invln2    (*(double*)invln2x)
-#define    sqrt2    (*(double*)sqrt2x)
-#else  /* defined(vax)||defined(tahoe) */
-static double
-ln2hi  =  6.9314718036912381649E-1    , /*Hex  2^ -1   *  1.62E42FEE00000 */
-ln2lo  =  1.9082149292705877000E-10   , /*Hex  2^-33   *  1.A39EF35793C76 */
-invln2 =  1.4426950408889633870E0     , /*Hex  2^  0   *  1.71547652B82FE */
-sqrt2  =  1.4142135623730951455E0     ; /*Hex  2^  0   *  1.6A09E667F3BCD */
-#endif /* defined(vax)||defined(tahoe) */
-
-static double zero=0.0, half=1.0/2.0, one=1.0, two=2.0, negone= -1.0;
+#include "mathimpl.h"
+
+vc(ln2hi,  6.9314718055829871446E-1  ,7217,4031,0000,f7d0,   0, .B17217F7D00000)
+vc(ln2lo,  1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+vc(invln2, 1.4426950408889634148E0   ,aa3b,40b8,17f1,295c,   1, .B8AA3B295C17F1)
+vc(sqrt2,  1.4142135623730950622E0   ,04f3,40b5,de65,33f9,   1, .B504F333F9DE65)
+
+ic(ln2hi,  6.9314718036912381649E-1,   -1, 1.62E42FEE00000)
+ic(ln2lo,  1.9082149292705877000E-10, -33, 1.A39EF35793C76)
+ic(invln2, 1.4426950408889633870E0,     0, 1.71547652B82FE)
+ic(sqrt2,  1.4142135623730951455E0,     0, 1.6A09E667F3BCD)
+
+#ifdef vccast
+#define        ln2hi   vccast(ln2hi)
+#define        ln2lo   vccast(ln2lo)
+#define        invln2  vccast(invln2)
+#define        sqrt2   vccast(sqrt2)
+#endif
+
+const static double zero=0.0, half=1.0/2.0, one=1.0, two=2.0, negone= -1.0;
+
+static double pow_p();
 
 double pow(x,y)        
 double x,y;
 {
 
 double pow(x,y)        
 double x,y;
 {
-       double drem(),pow_p(),copysign(),t;
-       int finite();
+       double t;
 
        if     (y==zero)      return(one);
        else if(y==one
 
        if     (y==zero)      return(one);
        else if(y==one
@@ -167,11 +161,11 @@ double x,y;
        }
 }
 
        }
 }
 
+#ifndef mc68881
 /* pow_p(x,y) return x**y for x with sign=1 and finite y */
 static double pow_p(x,y)       
 double x,y;
 {
 /* pow_p(x,y) return x**y for x with sign=1 and finite y */
 static double pow_p(x,y)       
 double x,y;
 {
-        double logb(),scalb(),copysign(),log__L(),exp__E();
         double c,s,t,z,tx,ty;
 #ifdef tahoe
        double tahoe_tmp;
         double c,s,t,z,tx,ty;
 #ifdef tahoe
        double tahoe_tmp;
@@ -244,3 +238,4 @@ double x,y;
                        return(scalb(one, 5000)); 
 
 }
                        return(scalb(one, 5000)); 
 
 }
+#endif /* mc68881 */