This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: newlib's nan(void) x ISO C99 nan(const char *)
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: newlib at sources dot redhat dot com
- Date: 09 Jul 2003 14:52:10 -0300
- Subject: Re: newlib's nan(void) x ISO C99 nan(const char *)
- Organization: GCC Team, Red Hat
- References: <ory8zfe7si.fsf@free.redhat.lsd.ic.unicamp.br>
On Jul 3, 2003, Alexandre Oliva <aoliva@redhat.com> wrote:
> Would anybody mind if we dropped nan(void) and nanf(void) in favor of
> the ISO C99-compliant functions that take a string as an argument?
> Should we try to retain backward-compatibility by means of macro
> magic, or just bite the bullet and replace the old, non-conforming
> functions and prototypes with the now-Standard ones?
> If nobody objects, I'll implement the Standard-compliant functions in
> the next few days.
strtod() didn't support NAN(...), whose code I meant to borrow for
nan(), so I'm being lazy and just disregarding the argument of nan()
and nanf(). I doubt anyone cares. The macro adaptors in
linux/cmath/math_private.h already did it and nobody seemed to care,
so... Approved by Jeff Johnston, I'm checking this in:
Index: newlib/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* libc/include/math.h (nan, nanf): Update prototype to C99.
* libm/common/s_nan.c (nan): Likewise.
* libm/common/s_nanf.c (nanf, nan): Likewise.
* libc/sys/linux/cmath/math_private.h (nan, nanf): Likewise.
Index: newlib/libc/include/math.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/math.h,v
retrieving revision 1.15
diff -u -p -r1.15 math.h
--- newlib/libc/include/math.h 16 Aug 2002 21:29:43 -0000 1.15
+++ newlib/libc/include/math.h 9 Jul 2003 17:50:14 -0000
@@ -119,7 +119,7 @@ extern int __fpclassifyd (double x);
/* Non ANSI double precision functions. */
extern double infinity _PARAMS((void));
-extern double nan _PARAMS((void));
+extern double nan _PARAMS((const char *));
extern int isnan _PARAMS((double));
extern int isinf _PARAMS((double));
extern int finite _PARAMS((double));
@@ -234,7 +234,7 @@ extern float fminf _PARAMS((float, float
extern float fmaf _PARAMS((float, float, float));
extern float infinityf _PARAMS((void));
-extern float nanf _PARAMS((void));
+extern float nanf _PARAMS((const char *));
extern int isnanf _PARAMS((float));
extern int isinff _PARAMS((float));
extern int finitef _PARAMS((float));
Index: newlib/libc/sys/linux/cmath/math_private.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/linux/cmath/math_private.h,v
retrieving revision 1.2
diff -u -p -r1.2 math_private.h
--- newlib/libc/sys/linux/cmath/math_private.h 23 Aug 2002 01:56:04 -0000 1.2
+++ newlib/libc/sys/linux/cmath/math_private.h 9 Jul 2003 17:50:15 -0000
@@ -24,14 +24,14 @@
#define INFINITY HUGE_VALF
-#define __nan(x) nan()
+#define __nan nan
#define __isnan isnan
#define __isinf isinf
#define __copysignf copysignf
#define __copysign copysign
#define __isnanf isnanf
#define __isinff isinff
-#define __nanf(x) nanf()
+#define __nanf nanf
#define feraiseexcept(x) /* nothing */
#define __sincos sincos
#define __sincosf sincosf
Index: newlib/libm/common/s_nan.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/common/s_nan.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 s_nan.c
--- newlib/libm/common/s_nan.c 17 Feb 2000 19:39:51 -0000 1.1.1.1
+++ newlib/libm/common/s_nan.c 9 Jul 2003 17:50:16 -0000
@@ -14,8 +14,8 @@ INDEX
ANSI_SYNOPSIS
#include <math.h>
- double nan(void);
- float nanf(void);
+ double nan(const char *);
+ float nanf(const char *);
TRAD_SYNOPSIS
#include <math.h>
@@ -25,7 +25,8 @@ TRAD_SYNOPSIS
DESCRIPTION
<<nan>> and <<nanf>> return an IEEE NaN (Not a Number) in
- double and single precision arithmetic respectivly.
+ double and single precision arithmetic respectivly. The
+ argument is currently disregarded.
QUICKREF
nan - pure
@@ -36,7 +37,7 @@ QUICKREF
#ifndef _DOUBLE_IS_32BITS
- double nan()
+ double nan(const char *unused)
{
double x;
Index: newlib/libm/common/sf_nan.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/common/sf_nan.c,v
retrieving revision 1.2
diff -u -p -r1.2 sf_nan.c
--- newlib/libm/common/sf_nan.c 4 Apr 2001 13:30:59 -0000 1.2
+++ newlib/libm/common/sf_nan.c 9 Jul 2003 17:50:16 -0000
@@ -5,7 +5,7 @@
#include "fdlibm.h"
- float nanf()
+ float nanf(const char *unused)
{
float x;
@@ -15,9 +15,9 @@
#ifdef _DOUBLE_IS_32BITS
- double nan()
+ double nan(const char *arg)
{
- return (double) nanf();
+ return (double) nanf(arg);
}
#endif /* defined(_DOUBLE_IS_32BITS) */
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer