/*1* Copyright (c) 1988, 19932* The Regents of the University of California. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*28* @(#)mathimpl.h 8.1 (Berkeley) 6/4/9329*/3031#include <sys/cdefs.h>32#include <math.h>3334#if defined(vax)||defined(tahoe)3536/* Deal with different ways to concatenate in cpp */37# ifdef __STDC__38# define cat3(a,b,c) a ## b ## c39# else40# define cat3(a,b,c) a/**/b/**/c41# endif4243/* Deal with vax/tahoe byte order issues */44# ifdef vax45# define cat3t(a,b,c) cat3(a,b,c)46# else47# define cat3t(a,b,c) cat3(a,c,b)48# endif4950# define vccast(name) (*(const double *)(cat3(name,,x)))5152/*53* Define a constant to high precision on a Vax or Tahoe.54*55* Args are the name to define, the decimal floating point value,56* four 16-bit chunks of the float value in hex57* (because the vax and tahoe differ in float format!), the power58* of 2 of the hex-float exponent, and the hex-float mantissa.59* Most of these arguments are not used at compile time; they are60* used in a post-check to make sure the constants were compiled61* correctly.62*63* People who want to use the constant will have to do their own64* #define foo vccast(foo)65* since CPP cannot do this for them from inside another macro (sigh).66* We define "vccast" if this needs doing.67*/68# define vc(name, value, x1,x2,x3,x4, bexp, xval) \69const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};7071# define ic(name, value, bexp, xval) ;7273#else /* vax or tahoe */7475/* Hooray, we have an IEEE machine */76# undef vccast77# define vc(name, value, x1,x2,x3,x4, bexp, xval) ;7879# define ic(name, value, bexp, xval) \80const static double name = value;8182#endif /* defined(vax)||defined(tahoe) */838485/*86* Functions internal to the math package, yet not static.87*/88extern double __exp__E();89extern double __log__L();9091struct Double {double a, b;};92double __exp__D __P((double, double));93struct Double __log__D __P((double));9495/*96* All externs exported after this point97*/98#if defined(_BLD_ast) && defined(__EXPORT__)99#define extern __EXPORT__100#endif101102extern double copysign(double, double);103104105