delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/08/31/12:50:23

From: Kbwms AT aol DOT com
Message-ID: <123.2528bff9.2c8380a0@aol.com>
Date: Sun, 31 Aug 2003 12:47:28 EDT
Subject: Re: <math.h> and <libm/math.h>
To: djgpp-workers AT delorie DOT com
MIME-Version: 1.0
X-Mailer: 8.0 for Windows sub 6015
Reply-To: djgpp-workers AT delorie DOT com

--part1_123.2528bff9.2c8380a0_boundary
Content-Type: multipart/alternative;
	boundary="part1_123.2528bff9.2c8380a0_alt_boundary"


--part1_123.2528bff9.2c8380a0_alt_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

In a message dated 8/30/2003 7:51:26 PM Eastern Standard Time, 
rich AT phekda DOT freeserve DOT co DOT uk writes:

> Eli Zaretskii wrote:
> >
> >>Date: Sat, 30 Aug 2003 15:35:59 +0100
> >>From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
> >>
> >>I think we can assume standard C for DJGPP.
> >
> >Yes.
> >
> >>Why don't we move everything from <libm/math.h> into <math.h> and make
> >><libm/math.h> just include <math.h>?
> >
> >That's what I suggested the other day.
> 
> Sorry. I thought that you had suggested it the other way round. But you are
> quite right - I just misremembered.
> 
> 

Attached is a version of math.h that combines the two files.  This version 
compiles all the source in ../src/libm/math without error when I put this 
version of math.h in the same directory and issue the following command:

       gcc -c -I. *.c

No need for -D_USE_LIBM_MATH_H either.

Also, under the same conditions, I compiled all my long double stuff (74 C 
files) all the *.cpp source in the test-generator directory 
(../tests/cygnus/tgen) and all C files in its parent directory, ../tests/cygnus.  Then, I ran the 
test program, mtest.exe, in the latter directory to verify the results.

It needs some work to verify that the restrictive #if defines do the right 
things.  I am woefully ignorant in those areas.

Enjoy.


KB Williams

--part1_123.2528bff9.2c8380a0_alt_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><FONT  SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"=
Georgia" LANG=3D"0">In a message dated 8/30/2003 7:51:26 PM Eastern Standard=
 Time, rich AT phekda DOT freeserve DOT co DOT uk writes:<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"></FONT><FONT  COLOR=3D"#000000"=
 style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"A=
rial" LANG=3D"0">Eli Zaretskii wrote:<BR>
&gt;<BR>
&gt;&gt;Date: Sat, 30 Aug 2003 15:35:59 +0100<BR>
&gt;&gt;From: Richard Dawe &lt;rich AT phekda DOT freeserve DOT co DOT uk&gt;<BR>
&gt;&gt;<BR>
&gt;&gt;I think we can assume standard C for DJGPP.<BR>
&gt;<BR>
&gt;Yes.<BR>
&gt;<BR>
&gt;&gt;Why don't we move everything from &lt;libm/math.h&gt; into &lt;math.=
h&gt; and make<BR>
&gt;&gt;&lt;libm/math.h&gt; just include &lt;math.h&gt;?<BR>
&gt;<BR>
&gt;That's what I suggested the other day.<BR>
<BR>
Sorry. I thought that you had suggested it the other way round. But you are<=
BR>
quite right - I just misremembered.<BR>
<BR>
</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
Attached is a version of math.h that combines the two files.&nbsp; This vers=
ion compiles all the source in ../src/libm/math without error when I put thi=
s version of math.h in the same directory and issue the following command:<B=
R>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gcc -c -I. *.c<BR>
<BR>
No need for -D_USE_LIBM_MATH_H either.<BR>
<BR>
Also, under the same conditions, I compiled all my long double stuff (74 C f=
iles) all the *.cpp source in the test-generator directory (../tests/cygnus/=
tgen) and all C files in its parent directory, ../tests/cygnus.&nbsp; Then,=20=
I ran the test program, mtest.exe, in the latter directory to verify the res=
ults.<BR>
<BR>
It needs some work to verify that the restrictive #if defines do the right t=
hings.&nbsp; I am woefully ignorant in those areas.<BR>
<BR>
Enjoy.<BR>
<BR>
<BR>
KB Williams</FONT></HTML>

--part1_123.2528bff9.2c8380a0_alt_boundary--

--part1_123.2528bff9.2c8380a0_boundary
Content-Type: text/plain; name="math.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline; filename="math.h"

/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_math_h_
#define __dj_include_math_h_

//#ifdef _USE_LIBM_MATH_H
//#include <libm/math.h>
//#else

#ifdef __cplusplus
extern "C" {
#endif

#ifndef __dj_ENFORCE_ANSI_FREESTANDING

extern double __dj_huge_val;
#define HUGE_VAL  __dj_huge_val

double=09acos(double);
double=09acosh(double);
double=09asin(double);
double=09asinh(double);
double=09atan(double);
double=09atan2(double , double);
double=09atanh(double);
double=09cbrt(double);
double=09ceil(double);
double=09cos(double);
double=09cosh(double);
double=09exp(double);
double=09exp10(double);
double=09exp2(double);
double=09expm1(double);
double=09fabs(double);
double=09floor(double);
double=09fmod(double , double);
double=09frexp(double , int *);
double=09hypot(double, double);
double=09ldexp(double , int);
double=09log(double);
double=09log10(double);
double=09log1p(double);
double=09log2(double);
double=09modf(double , double *);
long double modfl(long double , long double *);
double=09pow(double , double);
double=09pow10(double);
double=09pow2(double);
double=09powi(double, int);
double=09sin(double);
void=09sincos(double *, double *, double);
double=09sinh(double);
double=09sqrt(double);
double=09tan(double);
double=09tanh(double);

#ifndef __STRICT_ANSI__

#ifndef _POSIX_SOURCE

#define=09M_1_PI=09=090.31830988618379067154=09        /* 1/pi=09=09*/
#define=09M_2_PI=09=090.63661977236758134308=09        /* 2/pi =09*/
#define=09M_2_SQRTPI=091.12837916709551257390=09        /* 2/sqrt(pi) =09*/
#define=09M_3PI_4=09=092.3561944901923448370=09        /* 3/4 * pi =09*/
#define=09M_E=09=092.7182818284590452354=09       =09/* e =09=09*/
#define=09M_INVLN2=091.4426950408889633870E0  =09/* 1 / log e2=09*/
#define=09M_IVLN10=090.43429448190325182765 =09=09/* 1 / log(10)=09*/
#define=09M_LN10=09=092.30258509299404568402=09        /* loge(10)=09*/
#define=09M_LN2=09=090.693147180559945309417=09        /* loge(2)=09*/
#define=09M_LN2HI=09=096.9314718036912381649E-1=09/* upper bits of loge(2) *=
/
#define=09M_LN2LO=09=091.9082149292705877000E-10 =09/* lower bits of loge(2)=
 */
#define=09M_LOG10E=090.43429448190325182765=09        /* log10(e)=09*/
#define=09M_LOG2E=09=091.4426950408889634074=09        /* log(2e)=09*/
#define=09M_LOG2_E=090.693147180559945309417=09=09/* log2(e)=09*/
#define=09M_PI=09=093.14159265358979323846=09        /* pi=09=09*/
#define=09M_PI_2=09=091.57079632679489661923=09        /* pi/2=09=09*/
#define=09M_PI_4=09=090.78539816339744830962=09        /* pi/4 =09*/
#define=09M_SQRT1_2=090.70710678118654752440=09        /* 1/sqrt(2) =09*/
#define=09M_SQRT2=09=091.41421356237309504880=09        /* sqrt(2) =09*/
#define=09M_SQRT3   =091.73205080756887719000=09=09/* sqrt(3) =09*/
#define=09M_SQRTPI=091.77245385090551602792981=09/* sqrt(pi) =09*/
#define=09M_TWOPI=09=096.28318530717958647692=09        /* 2*pi =09*/
#define PI=09=09M_PI
#define PI2=09=09M_PI_2



/* These are in libm.a (Cygnus).  You must link -lm to get these */
/* See libm/math.h for comments */

/*
 * ANSI/POSIX
 */
typedef int __int32_t;
typedef unsigned int __uint32_t;

union __dmath
{
  __uint32_t i[2];
  double d;
};

extern const union __dmath __infinity;
//#define HUGE_VAL (__infinity.d)

/*
 * XOPEN/SVID
 */

extern int signgam;

enum __fdlibm_version
{
  __fdlibm_ieee =3D -1,
  __fdlibm_svid,
  __fdlibm_xopen,
  __fdlibm_posix
};

#define _LIB_VERSION_TYPE enum __fdlibm_version
#define _LIB_VERSION __fdlib_version

/* if global variable _LIB_VERSION is not desirable, one may=20
 * change the following to be a constant by:=20
 *=09#define _LIB_VERSION_TYPE const enum version
 * In that case, after one initializes the value _LIB_VERSION (see
 * s_lib_version.c) during compile time, it cannot be modified
 * in the middle of a program
 */=20
extern  _LIB_VERSION_TYPE  _LIB_VERSION;

#define _IEEE_  __fdlibm_ieee
#define _SVID_  __fdlibm_svid
#define _XOPEN_ __fdlibm_xopen
#define _POSIX_ __fdlibm_posix

/* The exception structure passed to the matherr routine.  */

#ifndef __cplusplus
struct exception
{
=09int type;
=09const char *name;
=09double arg1;
=09double arg2;
=09double retval;
=09int err;
};
#endif

double erf(double);
double erfc(double);
double gamma(double);
int isinf(double);
int isnan(double);
# if !defined isinff
int isinff(float);
# endif
# if !defined isnanf
int isnanf(float);
# endif
# if !defined finitef
int finitef(float);
# endif
int finite(double);
double infinity (void);
double j0(double);
double j1(double);
double jn(int, double);
double lgamma(double);
double nan(void);
double y0(double);
double y1(double);
double yn(int, double);
double logb(double);
double nextafter(double, double);
double remainder(double, double);
double scalb(double, double);
#ifndef __cplusplus
int matherr(struct exception *);
#endif
double significand(double);
double copysign(double, double);
int ilogb(double);
double rint(double);
double scalbn(double, int);
double drem(double, double);
double gamma_r(double, int *);
double lgamma_r(double, int *);
float acosf(float);
float asinf(float);
float atanf(float);
float atan2f(float, float);
float cosf(float);
float sinf(float);
float tanf(float);
float coshf(float);
float sinhf(float);
float tanhf(float);
float expf(float);
float frexpf(float, int *);
float infinityf (void);
float ldexpf(float, int);
float logf(float);
float log10f(float);
float modff(float, float *);
float powf(float, float);
float sqrtf(float);
float ceilf(float);
float fabsf(float);
float floorf(float);
float fmodf(float, float);
float erff(float);
float erfcf(float);
float gammaf(float);
float hypotf(float, float);
float j0f(float);
float j1f(float);
float jnf(int, float);
float lgammaf(float);
float nanf(void);
float y0f(float);
float y1f(float);
float ynf(int, float);
float acoshf(float);
float asinhf(float);
float atanhf(float);
float cbrtf(float);
float logbf(float);
float nextafterf(float, float);
float remainderf(float, float);
float scalbf(float, float);
float significandf(float);
float copysignf(float, float);
int ilogbf(float);
float rintf(float);
float scalbnf(float, int);
float dremf(float, float);
float expm1f(float);
float log1pf(float);
float gammaf_r(float, int *);
float lgammaf_r(float, int *);

/*=20
 * set X_TLOSS =3D pi*2**52, which is possibly defined in <values.h>
 * (one may replace the following line by "#include <values.h>")
 */

#define X_TLOSS=09=091.41484755040568800000e+16=20

#define=09DOMAIN=09=091
#define=09SING=09=092
#define=09OVERFLOW=093
#define=09UNDERFLOW=094
#define=09TLOSS=09=095
#define=09PLOSS=09=096

#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */

#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */

#ifdef __cplusplus
}
#endif

//#endif /* _USE_LIBM_MATH_H */

#ifdef __cplusplus
extern "C" {
#endif

/* ------------------- */
/* FUNCTION PROTOTYPES */
/* ------------------- */
/* *INDENT-OFF* */

extern=09long=09double acoshl=09  (long double);
extern=09long=09double acosl=09  (long double);
extern=09long=09double asinhl=09  (long double);
extern=09long=09double asinl=09  (long double);
extern=09long=09double atan2l=09  (long double, long double);
extern=09long=09double atanhl=09  (long double);
extern=09long=09double atanl=09  (long double);
extern=09long=09double cbrtl=09  (long double);
extern=09long=09double ceill=09  (long double);
extern=09long=09double copysignl  (long double, long double);
extern=09long=09double coshl=09  (long double);
extern=09long=09double cosl=09  (long double);
extern=09long=09double cotl=09  (long double);
extern=09long=09double erfcl=09  (long double);
extern=09long=09double erfl=09  (long double);
extern=09long=09double exp2l=09  (long double);
extern=09long=09double expl=09  (long double);
extern=09long=09double expm1l=09  (long double);
extern=09long=09double fabsl=09  (long double);
extern=09long=09double fdiml=09  (long double, long double);
extern=09long=09double floorl=09  (long double);
extern=09long=09double fmaxl=09  (long double, long double);
extern=09long=09double fminl=09  (long double, long double);
extern=09long=09double fmodl=09  (long double, long double);
extern=09int=09fpclassifyl=09  (long double);
extern=09long=09double frexpl=09  (long double, int *);
extern=09long=09double hypotl=09  (long double, long double);
extern=09int=09ilogbl=09=09  (long double);
extern=09long=09double _infinityl (void);
extern=09int=09isfinitel=09  (long double);
extern=09int=09isinfl=09=09  (long double);
extern=09int=09isnanl=09=09  (long double);
extern=09long=09double j0l=09  (long double);
extern=09long=09double j1l=09  (long double);
extern=09long=09double jnl=09  (int, long double);
extern=09long=09double ldexpl=09  (long double, int);
extern=09long=09double lgammal=09  (long double);
extern=09long=09double lgammal_r  (long double, int *);
extern=09long=09long int llrintl  (long double);
extern=09long=09long int llroundl (long double);
extern=09long=09int lrintl=09  (long double);
extern=09long=09int lroundl=09  (long double);
extern=09long=09double log10l=09  (long double);
extern=09long=09double log1pl=09  (long double);
extern=09long=09double log2l=09  (long double);
extern=09long=09double logbl=09  (long double);
extern=09long=09double logl=09  (long double);
extern=09long=09double modfl=09  (long double, long double *);
extern=09long=09double nanl=09  (const char *);
extern=09long=09double _nanl=09  (void);
extern=09long=09double nearbyintl (long double);
extern=09long=09double nextafterl (long double, long double);
extern=09long=09double powil=09  (long double, int);
extern=09long=09double powl=09  (long double, long double);
extern=09long=09double remainderl (long double, long double);
extern=09long=09double remquol=09  (long double, long double, int *);
extern=09long=09double rintl=09  (long double);
extern=09long=09double roundl=09  (long double);
extern=09long=09double scalblnl=09  (long double, long int);
extern=09long=09double scalbnl=09  (long double, int);
extern=09int=09signbitl=09  (long double);
extern=09long=09double sinhl=09  (long double);
extern=09long=09double sinl=09  (long double);
extern=09long=09double sqrtl=09  (long double);
extern=09long=09double tanl=09  (long double);
extern=09long=09double tanhl=09  (long double);
extern=09long=09double tgammal=09  (long double);
extern=09long=09double truncl=09  (long double);
extern=09long=09double y0l=09  (long double);
extern=09long=09double y1l  =09  (long double);
extern=09long=09double ynl=09  (int, long double);

/* *INDENT-ON* */


#ifdef __cplusplus
}
#endif

#endif /* !__dj_include_math_h_ */


--part1_123.2528bff9.2c8380a0_boundary--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019