Mail Archives: djgpp-workers/2003/11/09/15:55:04
--part1_d.1bb62c77.2ce0039d_boundary
Content-Type: multipart/alternative;
boundary="part1_d.1bb62c77.2ce0039d_alt_boundary"
--part1_d.1bb62c77.2ce0039d_alt_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
In a message dated 11/9/2003 3:13:54 PM Eastern Standard Time,
rich AT phekda DOT freeserve DOT co DOT uk writes:
> The header genmathv.h doesn't include enough braces in the definitions
> it generates for test vectors. Below is a patch to fix this.
>
> Even after applying this patch there are still warnings, because
> the entries terminating the lists don't have enough braces.
> I guess fixing "0" to be "{0}" is enough, but I didn't feel like
> fixing tens of files. I'll do that some other time.
>
> OK to commit?
>
This will be repaired in the new version of the test generators that I'm
working on. None of the old code for the float and double functions is used when
the C code is generated.
I have a copy of the old version of genmathv.h that I used when Eli
discovered how to fix the problem. It is attached. I hope it helps. It generated
clean C code from the tgen subdirectory. Problem is, it also contains some new
code for the long double functions that might get in the way. I believe the new
code is blocked out by #ifdef statements.
KB Williams
--part1_d.1bb62c77.2ce0039d_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 11/9/2003 3:13:54 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">The header genmathv.h doesn't include enough braces in the=20=
definitions<BR>
it generates for test vectors. Below is a patch to fix this.<BR>
<BR>
Even after applying this patch there are still warnings, because<BR>
the entries terminating the lists don't have enough braces.<BR>
I guess fixing "0" to be "{0}" is enough, but I didn't feel like<BR>
fixing tens of files. I'll do that some other time.<BR>
<BR>
OK to commit?<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>
This will be repaired in the new version of the test generators that I'm wor=
king on. None of the old code for the float and double functions is us=
ed when the C code is generated.<BR>
<BR>
I have a copy of the old version of genmathv.h that I used when Eli discover=
ed how to fix the problem. It is attached. I hope it helps. It g=
enerated clean C code from the tgen subdirectory. Problem is, it also=20=
contains some new code for the long double functions that might get in the w=
ay. I believe the new code is blocked out by #ifdef statements.<BR>
<BR>
<BR>
KB Williams</FONT></HTML>
--part1_d.1bb62c77.2ce0039d_alt_boundary--
--part1_d.1bb62c77.2ce0039d_boundary
Content-Type: text/plain; name="genmathv.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline; filename="genmathv.h"
// ----------------------------------------------
// genmathv.h - Header for Test-Vector Generators
// ----------------------------------------------
# if defined _GEN_MATHV_H_
#=09// Do Nothing
# else
#=09define _GEN_MATHV_H_
#
#include "fdlibml.h"=09// Get LDBL Macros
#include <fenv.h>=09// Rounding Modes (etc.)
#define=09__NO_ERROR_=090
#define=09EQUAL(s1, s2)=09(strcmp(s1, s2) =3D=3D 0)
#define=09GEN_FIRST_TWO_LINES=09\
printf("#include \"test.h\"\n one_line_type %s_vec[] =3D {\n", Name);
#define GEN_LAST_LINES_OF_CODE(FuncName, TypeArgs) \
printf("{0,0,0,0,{{0,},{0,}},},};\n"=09=09=09=09\
=09"void\ntest_%s(int m)\t{ run_vector_1(m, %s_vec,(char *)" \
=09"(%s),\"%s\",\"%s\");}\n", FuncName, FuncName, FuncName, FuncName, TypeAr=
gs)
#define=09START_LONG_DOUBLE_DATA=09\
printf("#include \"LdblTest.h\"\n LdblTestVector %s_vec[] =3D {\n", Name=
)
#define FINISH_LONG_DOUBLE_DATA(FuncName, TypeArgs) =20=
\
printf("{0,}};\nvoid\ntest_%s(int m)\n{\n TestLdblFunction(m, %s_vec,=
(void *)" \
"(%s),\"%s\",\"%s\");\n}\n", FuncName, FuncName, FuncName, FuncName,=
TypeArgs)
typedef struct=09LongLoopLimits
{
=09long double=09Start;
=09long double=09Step;
=09long double=09Stop;
}
=09LONG_LOOP_LIMITS;
typedef struct=09LoopLimits
{
=09double=09Start;
=09double=09Step;
=09double=09Stop;
}
=09LOOP_LIMITS;
# if defined WRITE_LONG_DOUBLE_VECTORS
# =09if defined USE_WRITE_2_VECTOR || defined USE_WRITE_3_VECTOR
#=09=09if defined USE_WRITE_2_VECTOR
// -------------------------------------------------------------------------=
-----
// Write2VectorLdbl - Writes next long double two-parameter test vector
//=09=09=09to stdout
// -------------------------------------------------------------------------=
-----
static=09void
Write2VectorLdbl(int MeasBit, long double ArgY, long double ArgX, long doubl=
e Exp,
=09=09int ErrExp)
{
volatile=09LDBL_UNION=09Arg1, Arg2, Expected;
Arg1.Arg =3D ArgY, Arg2.Arg =3D ArgX, Expected.Arg =3D Exp;
printf("{%d, %d, 0,__LINE__, 0x%04x, 0x%016Lx, "
=09=09"0x%04x, 0x%016Lx, 0x%04x, 0x%016Lx,},"
=09=09"\t/* %+.4LE%s=3DF(%+8.4Lg,%+8.4Lg) */\n", MeasBit, ErrExp,
=09=09(USHORT)Expected.Parts_2.Sign_and_Exp, Expected.Parts_2.FracBits,
=09=09(USHORT)Arg1.Parts_2.Sign_and_Exp, Arg1.Parts_2.FracBits,
=09=09(USHORT)Arg2.Parts_2.Sign_and_Exp, Arg2.Parts_2.FracBits,
=09=09Exp, (isinfl(Exp) || isnanl(Exp)) ? " " : "",
=09=09ArgY, ArgX);
=09=09fflush(NULL);
}
#=09=09endif
#=09=09if defined USE_WRITE_3_VECTOR
// -------------------------------------------------------------------------=
-----
// Write3VectorLdbl - Writes next long double three-parameter test vector
//=09=09=09to stdout
// -------------------------------------------------------------------------=
-----
static=09void
Write3VectorLdbl(int MeasBit, long double ArgY, long double ArgX,
=09=09=09 long double ArgZ, long double Exp, int ErrExp)
{
volatile=09LDBL_UNION=09Arg1, Arg2, Arg3, Expected;
Arg1.Arg =3D ArgY, Arg2.Arg =3D ArgX, Arg3.Arg =3D ArgZ, Expected.Arg=20=
=3D Exp;
printf("{%d, %d, 0,__LINE__, 0x%04x, 0x%016Lx, "
=09=09"0x%04x, 0x%016Lx, 0x%04x, 0x%016Lx,0x%04x, 0x%016Lx, },"
=09=09"\t/* %+.4LE%s=3DF(%+8.4Lg,%+8.4Lg,%+8.4Lg) */\n", MeasBit, ErrExp,
=09=09(USHORT)Expected.Parts_2.Sign_and_Exp, Expected.Parts_2.FracBits,
=09=09(USHORT)Arg1.Parts_2.Sign_and_Exp, Arg1.Parts_2.FracBits,
=09=09(USHORT)Arg2.Parts_2.Sign_and_Exp, Arg2.Parts_2.FracBits,
=09=09(USHORT)Arg3.Parts_2.Sign_and_Exp, Arg3.Parts_2.FracBits,
=09=09Exp, (isinfl(Exp) || isnanl(Exp)) ? " " : "",
=09=09ArgY, ArgX, ArgZ);
=09=09fflush(NULL);
}
#=09=09endif
# else // End of USE_WRITE_2_VECTOR part of WRITE_LONG_DOUBLE_VECTORS
// ------------------------------------------------------------------------
// WriteVectorLdbl - Writes one-parameter long double test vector to stdout
// ------------------------------------------------------------------------
static=09void
WriteVectorLdbl(int MeasBit, long double Arg, long double Exp, int ErrExp)
{
volatile=09LDBL_UNION=09Argument, Expected;
Argument.Arg =3D Arg, Expected.Arg =3D Exp;
printf("{%d, %d, 0,__LINE__, 0x%04x, 0x%016Lx, 0x%04x, 0x%016Lx,},"
"\t/* %+.4LE%s=3DF(%+.5Lg) */\n", MeasBit, ErrExp,
=09=09(USHORT)Expected.Parts_2.Sign_and_Exp, Expected.Parts_2.FracBits,
=09=09(USHORT)Argument.Parts_2.Sign_and_Exp, Argument.Parts_2.FracBits,
Exp, (isinfl(Exp) || isnanl(Exp)) ? " " : "",
=09=09Arg);
=09=09fflush(NULL);
}
# endif // end of else part of USE_WRITE_2_VECTOR
#=09if defined WRITE_LDBL_RND_VECTOR
static int RndMode[] =3D {FE_DOWNWARD, FE_TONEAREST, FE_TOWARDZERO, FE_UPWAR=
D};
#define NumModes (sizeof(RndMode)/sizeof(RndMode[0]))
// -------------------------------------------------------------------------
// WriteVectorLdblRnd - Writes test vectors with rounding mode for functions
//=09=09=09with one parameter of type long double to stdout
// ------------------------------------------------------------------------
static=09void
WriteVectorLdblRnd(int MeasBit, LDBL Arg, LDBL Exp, int ErrExp, int RndMode)
{
volatile=09LDBL_UNION=09Argument, Expected;
Argument.Arg =3D Arg, Expected.Arg =3D Exp;
printf("{%d, %d, 0x%04x,__LINE__, 0x%04x, 0x%016Lx, 0x%04x, 0x%016Lx,},"
" /* %+.4LE%s=3DF(%+.5Lg) */\n", MeasBit, ErrExp, RndMode,
=09=09(USHORT)Expected.Parts_2.Sign_and_Exp, Expected.Parts_2.FracBits,
=09=09(USHORT)Argument.Parts_2.Sign_and_Exp, Argument.Parts_2.FracBits,
Exp, (isinfl(Exp) || isnanl(Exp)) ? " " : "",
=09=09Arg);
=09=09fflush(NULL);
}
#=09endif // WRITE_LDBL_RND_VECTOR
# endif // WRITE_LONG_DOUBLE_VECTORS
# ifdef USE_WRITE_2_VECTOR
// --------------------------------------------------------------
// Write2Vector - Writes next two-parameter test vector to stdout
// --------------------------------------------------------------
static=09void
Write2Vector(int MeasBit, double ArgY, double ArgX, double Exp,
=09=09int ErrExp)
{
volatile __ieee_double_shape_type Arg1, Arg2, Expected;
Arg1.value =3D ArgY, Arg2.value =3D ArgX, Expected.value =3D Exp;
printf("{%d, %d, 0,__LINE__, {{0x%08lx, 0x%08lx}, "
=09=09"{0x%08lx, 0x%08lx}, {0x%08lx, 0x%08lx}},},"
=09=09"\t/* %+.4E%s=3DF(%+8.4g,%+8.4g) */\n", MeasBit, ErrExp,
=09=09Expected.parts.msw, Expected.parts.lsw,
=09=09Arg1.parts.msw, Arg1.parts.lsw,
=09=09Arg2.parts.msw, Arg2.parts.lsw,
=09=09Expected.value,
=09=09(isinf(Expected.value) ||
=09=09 isnan(Expected.value)) ? " " : "",
=09=09Arg1.value, Arg2.value);
=09=09fflush(NULL);
}
#else // End of USE_WRITE_2_VECTOR
// -------------------------------------------------------------
// WriteVector - Writes next one-parameter test vector to stdout
// -------------------------------------------------------------
static=09void
WriteVector(int MeasBit, double Arg, double Exp, int ErrExp)
{
volatile __ieee_double_shape_type Argument, Expected;
Argument.value =3D Arg, Expected.value =3D Exp;
printf("{%d, %d, 0,__LINE__, {{0x%08lx, 0x%08lx}, {0x%08lx, 0x%08lx}}, }=
,"
=09=09"\t/* %+.4E%s=3DF(%+8.4g) */\n", MeasBit, ErrExp,
=09=09Expected.parts.msw, Expected.parts.lsw,
=09=09Argument.parts.msw, Argument.parts.lsw,
=09=09Expected.value,
=09=09(isinf(Expected.value) ||
=09=09 isnan(Expected.value)) ? " " : "",
=09=09Argument.value);
=09=09fflush(NULL);
}
# endif // USE_WRITE_2_VECTOR
// -------------------------------------------------------------
// AssignOutputFile - Reopens stdout as a diskfile based on Name
// -------------------------------------------------------------
void
AssignOutputFile(char *Name)
{
FILE *OutPtr;
char OutNam[128];
strcpy(OutNam, Name);
strcat(OutNam, "_vec.c");
OutPtr =3D freopen(OutNam, "w", stdout);
if (OutPtr =3D=3D NULL)
{
=09fprintf(stderr, "In AssignOutputFile() in File %s:\n", __FILE__);
=09perror(OutNam);
=09exit(1);
}
}
# endif /* ! defined _GEN_MATHV_H */
--part1_d.1bb62c77.2ce0039d_boundary--
- Raw text -