142654Sbostic /*
242654Sbostic  * Copyright (c) 1988 The Regents of the University of California.
342654Sbostic  * All rights reserved.
442654Sbostic  *
5*42657Sbostic  * %sccs.include.redist.c%
642654Sbostic  *
742654Sbostic  * All recipients should regard themselves as participants in an ongoing
842654Sbostic  * research project and hence should feel obligated to report their
942654Sbostic  * experiences (good or bad) with these elementary function codes, using
1042654Sbostic  * the sendbug(8) program, to the authors.
1142654Sbostic  *
12*42657Sbostic  *	@(#)mathimpl.h	5.2 (Berkeley) 06/01/90
1342654Sbostic  */
1442654Sbostic 
1542654Sbostic #include <math.h>
1642654Sbostic 
1742654Sbostic #ifdef __STDC__
1842654Sbostic #define const const
1942654Sbostic #else
2042654Sbostic #define const /**/
2142654Sbostic #endif
2242654Sbostic 
2342654Sbostic #if defined(vax)||defined(tahoe)
2442654Sbostic 
2542654Sbostic /* Deal with different ways to concatenate in cpp */
2642654Sbostic #  ifdef __STDC__
2742654Sbostic #    define	cat3(a,b,c) a ## b ## c
2842654Sbostic #  else
2942654Sbostic #    define	cat3(a,b,c) a/**/b/**/c
3042654Sbostic #  endif
3142654Sbostic 
3242654Sbostic /* Deal with vax/tahoe byte order issues */
3342654Sbostic #  ifdef vax
3442654Sbostic #    define	cat3t(a,b,c) cat3(a,b,c)
3542654Sbostic #  else
3642654Sbostic #    define	cat3t(a,b,c) cat3(a,c,b)
3742654Sbostic #  endif
3842654Sbostic 
3942654Sbostic #  define vccast(name) (*(const double *)(cat3(name,,x)))
4042654Sbostic 
4142654Sbostic    /*
4242654Sbostic     * Define a constant to high precision on a Vax or Tahoe.
4342654Sbostic     *
4442654Sbostic     * Args are the name to define, the decimal floating point value,
4542654Sbostic     * four 16-bit chunks of the float value in hex
4642654Sbostic     * (because the vax and tahoe differ in float format!), the power
4742654Sbostic     * of 2 of the hex-float exponent, and the hex-float mantissa.
4842654Sbostic     * Most of these arguments are not used at compile time; they are
4942654Sbostic     * used in a post-check to make sure the constants were compiled
5042654Sbostic     * correctly.
5142654Sbostic     *
5242654Sbostic     * People who want to use the constant will have to do their own
5342654Sbostic     *     #define foo vccast(foo)
5442654Sbostic     * since CPP cannot do this for them from inside another macro (sigh).
5542654Sbostic     * We define "vccast" if this needs doing.
5642654Sbostic     */
5742654Sbostic #  define vc(name, value, x1,x2,x3,x4, bexp, xval) \
5842654Sbostic 	const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
5942654Sbostic 
6042654Sbostic #  define ic(name, value, bexp, xval) ;
6142654Sbostic 
6242654Sbostic #else	/* vax or tahoe */
6342654Sbostic 
6442654Sbostic    /* Hooray, we have an IEEE machine */
6542654Sbostic #  undef vccast
6642654Sbostic #  define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
6742654Sbostic 
6842654Sbostic #  define ic(name, value, bexp, xval) \
6942654Sbostic 	const static double name = value;
7042654Sbostic 
7142654Sbostic #endif	/* defined(vax)||defined(tahoe) */
7242654Sbostic 
7342654Sbostic 
7442654Sbostic /*
7542654Sbostic  * Functions internal to the math package, yet not static.
7642654Sbostic  */
7742654Sbostic extern double	exp__E();
7842654Sbostic extern double	log__L();
7942654Sbostic 
80