142654Sbostic /*
2*61309Sbostic  * Copyright (c) 1988, 1993
3*61309Sbostic  *	The Regents of the University of California.  All rights reserved.
442654Sbostic  *
542657Sbostic  * %sccs.include.redist.c%
642654Sbostic  *
7*61309Sbostic  *	@(#)mathimpl.h	8.1 (Berkeley) 06/04/93
842654Sbostic  */
942654Sbostic 
1046997Sbostic #include <sys/cdefs.h>
1142654Sbostic #include <math.h>
1242654Sbostic 
1342654Sbostic #if defined(vax)||defined(tahoe)
1442654Sbostic 
1542654Sbostic /* Deal with different ways to concatenate in cpp */
1642654Sbostic #  ifdef __STDC__
1742654Sbostic #    define	cat3(a,b,c) a ## b ## c
1842654Sbostic #  else
1942654Sbostic #    define	cat3(a,b,c) a/**/b/**/c
2042654Sbostic #  endif
2142654Sbostic 
2242654Sbostic /* Deal with vax/tahoe byte order issues */
2342654Sbostic #  ifdef vax
2442654Sbostic #    define	cat3t(a,b,c) cat3(a,b,c)
2542654Sbostic #  else
2642654Sbostic #    define	cat3t(a,b,c) cat3(a,c,b)
2742654Sbostic #  endif
2842654Sbostic 
2942654Sbostic #  define vccast(name) (*(const double *)(cat3(name,,x)))
3042654Sbostic 
3142654Sbostic    /*
3242654Sbostic     * Define a constant to high precision on a Vax or Tahoe.
3342654Sbostic     *
3442654Sbostic     * Args are the name to define, the decimal floating point value,
3542654Sbostic     * four 16-bit chunks of the float value in hex
3642654Sbostic     * (because the vax and tahoe differ in float format!), the power
3742654Sbostic     * of 2 of the hex-float exponent, and the hex-float mantissa.
3842654Sbostic     * Most of these arguments are not used at compile time; they are
3942654Sbostic     * used in a post-check to make sure the constants were compiled
4042654Sbostic     * correctly.
4142654Sbostic     *
4242654Sbostic     * People who want to use the constant will have to do their own
4342654Sbostic     *     #define foo vccast(foo)
4442654Sbostic     * since CPP cannot do this for them from inside another macro (sigh).
4542654Sbostic     * We define "vccast" if this needs doing.
4642654Sbostic     */
4742654Sbostic #  define vc(name, value, x1,x2,x3,x4, bexp, xval) \
4842654Sbostic 	const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
4942654Sbostic 
5042654Sbostic #  define ic(name, value, bexp, xval) ;
5142654Sbostic 
5242654Sbostic #else	/* vax or tahoe */
5342654Sbostic 
5442654Sbostic    /* Hooray, we have an IEEE machine */
5542654Sbostic #  undef vccast
5642654Sbostic #  define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
5742654Sbostic 
5842654Sbostic #  define ic(name, value, bexp, xval) \
5942654Sbostic 	const static double name = value;
6042654Sbostic 
6142654Sbostic #endif	/* defined(vax)||defined(tahoe) */
6242654Sbostic 
6342654Sbostic 
6442654Sbostic /*
6542654Sbostic  * Functions internal to the math package, yet not static.
6642654Sbostic  */
6757452Sbostic extern double	__exp__E();
6857452Sbostic extern double	__log__L();
6942654Sbostic 
7056951Sbostic struct Double {double a, b;};
7157452Sbostic double __exp__D __P((double, double));
7257452Sbostic struct Double __log__D __P((double));
73