BSD 4_3_Tahoe release
[unix-history] / usr / src / usr.lib / libm / log1p.c
index a4a50af..b6fdfa5 100644 (file)
@@ -1,19 +1,28 @@
-/* 
+/*
  * Copyright (c) 1985 Regents of the University of California.
  * Copyright (c) 1985 Regents of the University of California.
- * 
- * Use and reproduction of this software are granted  in  accordance  with
- * the terms and conditions specified in  the  Berkeley  Software  License
- * Agreement (in particular, this entails acknowledgement of the programs'
- * source, and inclusion of this notice) with the additional understanding
- * that  all  recipients  should regard themselves as participants  in  an
- * ongoing  research  project and hence should  feel  obligated  to report
- * their  experiences (good or bad) with these elementary function  codes,
- * using "sendbug 4bsd-bugs@BERKELEY", to the authors.
+ * 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
+ * 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.
+ *
+ * All recipients should regard themselves as participants in an ongoing
+ * research project and hence should feel obligated to report their
+ * experiences (good or bad) with these elementary function codes, using
+ * the sendbug(8) program, to the authors.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)log1p.c    1.3 (Berkeley) 8/21/85";
-#endif not lint
+static char sccsid[] = "@(#)log1p.c    5.3 (Berkeley) 6/30/88";
+#endif /* not lint */
 
 /* LOG1P(x) 
  * RETURN THE LOGARITHM OF 1+x
 
 /* LOG1P(x) 
  * RETURN THE LOGARITHM OF 1+x
@@ -74,25 +83,29 @@ static char sccsid[] = "@(#)log1p.c 1.3 (Berkeley) 8/21/85";
  * shown.
  */
 
  * shown.
  */
 
-#ifdef VAX     /* VAX D format */
+#if defined(vax)||defined(tahoe)       /* VAX D format */
 #include <errno.h>
 #include <errno.h>
-
-/* double static */
+#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 */
 /* sqrt2  =  1.4142135623730950622E0     ; Hex  2^  1   *  .B504F333F9DE65 */
 /* ln2hi  =  6.9314718055829871446E-1    , Hex  2^  0   *  .B17217F7D00000 */
 /* ln2lo  =  1.6465949582897081279E-12   , Hex  2^-39   *  .E7BCD5E4F1D9CC */
 /* sqrt2  =  1.4142135623730950622E0     ; Hex  2^  1   *  .B504F333F9DE65 */
-static long     ln2hix[] = { 0x72174031, 0x0000f7d0};
-static long     ln2lox[] = { 0xbcd52ce7, 0xd9cce4f1};
-static long     sqrt2x[] = { 0x04f340b5, 0xde6533f9};
+static long     ln2hix[] = { _0x(7217,4031), _0x(0000,f7d0)};
+static long     ln2lox[] = { _0x(bcd5,2ce7), _0x(d9cc,e4f1)};
+static long     sqrt2x[] = { _0x(04f3,40b5), _0x(de65,33f9)};
 #define    ln2hi    (*(double*)ln2hix)
 #define    ln2lo    (*(double*)ln2lox)
 #define    sqrt2    (*(double*)sqrt2x)
 #define    ln2hi    (*(double*)ln2hix)
 #define    ln2lo    (*(double*)ln2lox)
 #define    sqrt2    (*(double*)sqrt2x)
-#else  /* IEEE double */
-double static
+#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 */
 sqrt2  =  1.4142135623730951455E0     ; /*Hex  2^  0   *  1.6A09E667F3BCD */
 ln2hi  =  6.9314718036912381649E-1    , /*Hex  2^ -1   *  1.62E42FEE00000 */
 ln2lo  =  1.9082149292705877000E-10   , /*Hex  2^-33   *  1.A39EF35793C76 */
 sqrt2  =  1.4142135623730951455E0     ; /*Hex  2^  0   *  1.6A09E667F3BCD */
-#endif
+#endif /* defined(vax)||defined(tahoe) */
 
 double log1p(x)
 double x;
 
 double log1p(x)
 double x;
@@ -102,9 +115,9 @@ double x;
        double logb(),copysign(),scalb(),log__L(),z,s,t,c;
        int k,finite();
 
        double logb(),copysign(),scalb(),log__L(),z,s,t,c;
        int k,finite();
 
-#ifndef VAX
+#if !defined(vax)&&!defined(tahoe)
        if(x!=x) return(x);     /* x is NaN */
        if(x!=x) return(x);     /* x is NaN */
-#endif
+#endif /* !defined(vax)&&!defined(tahoe) */
 
        if(finite(x)) {
           if( x > negone ) {
 
        if(finite(x)) {
           if( x > negone ) {
@@ -128,19 +141,19 @@ double x;
        /* end of if (x > negone) */
 
            else {
        /* end of if (x > negone) */
 
            else {
-#ifdef VAX
+#if defined(vax)||defined(tahoe)
                extern double infnan();
                if ( x == negone )
                    return (infnan(-ERANGE));   /* -INF */
                else
                    return (infnan(EDOM));      /* NaN */
                extern double infnan();
                if ( x == negone )
                    return (infnan(-ERANGE));   /* -INF */
                else
                    return (infnan(EDOM));      /* NaN */
-#else  /* IEEE double */
+#else  /* defined(vax)||defined(tahoe) */
                /* x = -1, return -INF with signal */
                if ( x == negone ) return( negone/zero );
 
                /* negative argument for log, return NaN with signal */
                else return ( zero / zero );
                /* x = -1, return -INF with signal */
                if ( x == negone ) return( negone/zero );
 
                /* negative argument for log, return NaN with signal */
                else return ( zero / zero );
-#endif
+#endif /* defined(vax)||defined(tahoe) */
            }
        }
     /* end of if (finite(x)) */
            }
        }
     /* end of if (finite(x)) */