diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index b382963..237ee71 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.50 2005-05-07 13:21:49 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.51 2005-05-07 17:03:55 obarthel Exp $ # # :ts=8 # @@ -527,6 +527,7 @@ MATH_LIB = \ math_fmod.o \ math_frexp.o \ math_huge_val.o \ + math_huge_valf.o \ math_hypot.o \ math_init_exit.o \ math_isinf.o \ diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index f50da1b..d1329f8 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.53 2005-05-07 13:21:49 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.54 2005-05-07 17:03:55 obarthel Exp $ # # :ts=8 # @@ -527,6 +527,7 @@ MATH_LIB = \ math_fmod.o \ math_frexp.o \ math_huge_val.o \ + math_huge_valf.o \ math_hypot.o \ math_init_exit.o \ math_isnan.o \ diff --git a/library/changes b/library/changes index 65a1456..d30c930 100644 --- a/library/changes +++ b/library/changes @@ -30,7 +30,10 @@ - The printf() family now supports the %hh, %j, %t and %z modifiers and the %a/%A conversions for C99. The %j is treated like %ll, %t and %z are treated - like %l. + like %l. Also, the "infinity"/"not a number" signals now come out as the + strings "inf" and "nan". + +- Added HUGE_VALF to . c.lib 1.191 (9.4.2005) diff --git a/library/include/math.h b/library/include/math.h index c5a7c00..b81874b 100644 --- a/library/include/math.h +++ b/library/include/math.h @@ -1,5 +1,5 @@ /* - * $Id: math.h,v 1.6 2005-02-25 10:14:22 obarthel Exp $ + * $Id: math.h,v 1.7 2005-05-07 17:04:07 obarthel Exp $ * * :ts=4 * @@ -110,6 +110,19 @@ extern double hypot(double x,double y); /****************************************************************************/ +/* The following is not part of the ISO 'C' (1994) standard, but it should + be part of ISO/IEC 9899:1999, also known as "C99". */ + +/****************************************************************************/ + +extern float __huge_val_float; + +/****************************************************************************/ + +#define HUGE_VALF ((const float)__huge_val_float) + +/****************************************************************************/ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/library/math_headers.h b/library/math_headers.h index dbcc1a6..2c80fc1 100644 --- a/library/math_headers.h +++ b/library/math_headers.h @@ -1,5 +1,5 @@ /* - * $Id: math_headers.h,v 1.7 2005-03-18 12:38:22 obarthel Exp $ + * $Id: math_headers.h,v 1.8 2005-05-07 17:03:55 obarthel Exp $ * * :ts=4 * @@ -222,4 +222,9 @@ extern double __get_huge_val(void); /****************************************************************************/ +/* math_huge_valf.c */ +extern float __get_huge_valf(void); + +/****************************************************************************/ + #endif /* _MATH_HEADERS_H */ diff --git a/library/math_huge_valf.c b/library/math_huge_valf.c new file mode 100644 index 0000000..dad4910 --- /dev/null +++ b/library/math_huge_valf.c @@ -0,0 +1,44 @@ +/* + * $Id: math_huge_valf.c,v 1.1 2005-05-07 17:03:55 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MATH_HEADERS_H +#include "math_headers.h" +#endif /* _MATH_HEADERS_H */ + +/****************************************************************************/ + +float +__get_huge_valf(void) +{ + return(__huge_val_float); +} diff --git a/library/math_init_exit.c b/library/math_init_exit.c index ba46a4a..927195f 100644 --- a/library/math_init_exit.c +++ b/library/math_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: math_init_exit.c,v 1.15 2005-03-20 17:14:58 obarthel Exp $ + * $Id: math_init_exit.c,v 1.16 2005-05-07 17:03:55 obarthel Exp $ * * :ts=4 * @@ -73,7 +73,8 @@ struct Library * MathIeeeDoubTransBase; /****************************************************************************/ -double __huge_val; +float __huge_val_float; +double __huge_val; /****************************************************************************/ @@ -114,6 +115,8 @@ MATH_DESTRUCTOR(math_exit) MATH_CONSTRUCTOR(math_init) { + union ieee_double * double_x; + union ieee_single * single_x; BOOL success = FALSE; ENTER(); @@ -163,34 +166,28 @@ MATH_CONSTRUCTOR(math_init) } #endif /* IEEE_FLOATING_POINT_SUPPORT */ - /* Now fill in the HUGE_VAL constant, which is set to - the largest representable floating point value. */ - if(sizeof(__huge_val) == 4) /* single precision */ - { - union ieee_single * x = (union ieee_single *)&__huge_val; + /* Now fill in HUGE_VAL and HUGE_VALF, respectively. TODO: + also take care of HUGE_VALL. */ - /* Exponent = +126, Mantissa = 8,388,607 */ - x->raw[0] = 0x7f7fffff; - } - else if (sizeof(__huge_val) == 8) /* double precision */ - { - union ieee_double * x = (union ieee_double *)&__huge_val; + /* Exponent = +126, Mantissa = 8,388,607 */ + single_x = (union ieee_single *)&__huge_val_float; + single_x->raw[0] = 0x7f7fffff; - /* Exponent = +1022, Mantissa = 4,503,599,627,370,495 */ - x->raw[0] = 0x7fefffff; - x->raw[1] = 0xffffffff; - } -#if defined(USE_LONG_DOUBLE) - else if (sizeof(__huge_val) == 12) /* extended precision */ + /* Exponent = +1022, Mantissa = 4,503,599,627,370,495 */ + double_x = (union ieee_double *)&__huge_val; + double_x->raw[0] = 0x7fefffff; + double_x->raw[1] = 0xffffffff; + + #if defined(USE_LONG_DOUBLE) { - union ieee_long_double * x = (union ieee_long_double *)&__huge_val; + union ieee_long_double * x = (union ieee_long_double *)&__huge_val_long_double; /* Exponent = +32766, Mantissa = 18,446,744,073,709,551,615 */ x->raw[0] = 0x7ffe0000; x->raw[1] = 0xffffffff; x->raw[2] = 0xffffffff; } -#endif /* USE_LONG_DOUBLE */ + #endif /* USE_LONG_DOUBLE */ success = TRUE; diff --git a/library/smakefile b/library/smakefile index cb0b8f7..73675bc 100644 --- a/library/smakefile +++ b/library/smakefile @@ -1,5 +1,5 @@ # -# $Id: smakefile,v 1.38 2005-05-07 13:21:49 obarthel Exp $ +# $Id: smakefile,v 1.39 2005-05-07 17:03:55 obarthel Exp $ # # :ts=8 # @@ -191,6 +191,7 @@ MATH_OBJ = \ math_fmod.o \ math_frexp.o \ math_huge_val.o \ + math_huge_valf.o \ math_hypot.o \ math_init_exit.o \ math_isinf.o \ diff --git a/library/stdio_vfprintf.c b/library/stdio_vfprintf.c index ba3c741..a609e53 100644 --- a/library/stdio_vfprintf.c +++ b/library/stdio_vfprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vfprintf.c,v 1.13 2005-05-07 16:39:27 obarthel Exp $ + * $Id: stdio_vfprintf.c,v 1.14 2005-05-07 17:03:55 obarthel Exp $ * * :ts=4 * @@ -1362,7 +1362,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { char * byte_ptr; - byte_ptr = va_arg(arg, byte *); + byte_ptr = va_arg(arg, char *); assert( byte_ptr != NULL ); diff --git a/library/stdlib_strtof.c b/library/stdlib_strtof.c index 4fb6660..12f7488 100644 --- a/library/stdlib_strtof.c +++ b/library/stdlib_strtof.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_strtof.c,v 1.1 2005-05-07 13:21:49 obarthel Exp $ + * $Id: stdlib_strtof.c,v 1.2 2005-05-07 17:03:55 obarthel Exp $ * * :ts=4 * @@ -89,7 +89,7 @@ strtof(const char *str, char ** ptr) __set_errno(EFAULT); - result = __get_huge_val(); + result = __get_huge_valf(); goto out; } } @@ -298,7 +298,7 @@ strtof(const char *str, char ** ptr) { __set_errno(error); - sum = __get_huge_val(); + sum = __get_huge_valf(); } if(is_negative)