From 6bdac416e9e1aecfb94cd3ae383889cc7b7e62e3 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 6 Dec 2000 23:50:11 +0000 Subject: 2000-12-06 Jeff Johnston * libc/stdlib/Makefile.am: Added ldtoa.c to list of sources. * libc/stdlib/Makefile.in: Regenerated. * libc/stdio/floatio.h: Added suitable MAXEXP for long double. * libc/stdio/vfieeefp.h: Added long double bit structures. * libc/stdio/vfprintf.c[WANT_IO_LONG_DBL]: Added long double support. [WANT_IO_LONG_DBL](isinfl, isnanl): New static long double routines. (exponent): Changed expbuf to reasonable maximum instead of MAXEXP. * libc/stdio/vfscanf.c[WANT_IO_LONG_DBL]: Added long double support. * libc/stdlib/ldtoa.c: New file containing _ldtoa_r and _strtold routines used for conversions between character and long double. --- newlib/libc/stdio/vfieeefp.h | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'newlib/libc/stdio/vfieeefp.h') diff --git a/newlib/libc/stdio/vfieeefp.h b/newlib/libc/stdio/vfieeefp.h index 6843d5f47..de0267223 100644 --- a/newlib/libc/stdio/vfieeefp.h +++ b/newlib/libc/stdio/vfieeefp.h @@ -57,6 +57,85 @@ Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. #endif +#ifdef WANT_IO_LONG_DBL +/* If we are going to examine or modify specific bits in a long double using + the lword0 or lwordx macros, then we must wrap the long double inside + a union. This is necessary to avoid undefined behavior according to + the ANSI C spec. */ + +#ifdef IEEE_8087 +#if LDBL_MANT_DIG == 24 +struct ldieee +{ + unsigned manh:23; + unsigned exp:8; + unsigned sign:1; +} +#elif LDBL_MANT_DIG == 53 +struct ldieee +{ + unsigned manl:20; + unsigned manh:32; + unsigned exp:11; + unsigned sign:1; +} +#elif LDBL_MANT_DIG == 64 +struct ldieee +{ + unsigned manl:32; + unsigned manh:32; + unsigned exp:15; + unsigned sign:1; +}; +#elif LDBL_MANT_DIG > 64 +struct ldieee +{ + unsigned manl3:16; + unsigned manl2:32; + unsigned manl:32; + unsigned manh:32; + unsigned exp:15; + unsigned sign:1; +}; +#endif /* LDBL_MANT_DIG */ +#else /* !IEEE_8087 */ +#if LDBL_MANT_DIG == 24 +struct ldieee +{ + unsigned sign:1; + unsigned exp:8; + unsigned manh:23; +} +#elif LDBL_MANT_DIG == 53 +struct ldieee +{ + unsigned sign:1; + unsigned exp:11; + unsigned manh:32; + unsigned manl:20; +} +#elif LDBL_MANT_DIG == 64 +struct ldieee +{ + unsigned sign:1; + unsigned exp:15; + unsigned manh:32; + unsigned manl:32; +} +#elif LDBL_MANT_DIG > 64 +struct ldieee +{ + unsigned sign:1; + unsigned exp:15; + unsigned manh:32; + unsigned manl:32; + unsigned manl2:32; + unsigned manl3;16; +}; +#endif /* LDBL_MANT_DIG */ +#endif /* !IEEE_8087 */ +#endif /* WANT_IO_LONG_DBL */ + /* If we are going to examine or modify specific bits in a double using the word0 and/or word1 macros, then we must wrap the double inside a union. This is necessary to avoid undefined behavior according to -- cgit v1.2.3