Skip site navigation (1)Skip section navigation (2)
Date:      Mon,  8 Mar 2004 18:02:41 +0100 (CET)
From:      Stefan Farfeleder <stefan@fafoe.narf.at>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        stefan@fafoe.narf.at
Subject:   standards/63935: [patch] Fix C90 namespace pollution in <float.h>
Message-ID:  <20040308170241.F121B4CB@wombat.fafoe.narf.at>
Resent-Message-ID: <200403081710.i28HAAmB062574@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         63935
>Category:       standards
>Synopsis:       [patch] Fix C90 namespace pollution in <float.h>
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 08 09:10:10 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Farfeleder
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD wombat.fafoe.narf.at 5.2-CURRENT FreeBSD 5.2-CURRENT #16: Tue Mar 2 19:09:53 CET 2004 stefan@wombat.fafoe.narf.at:/usr/home/stefan/freebsd/obj/usr/home/stefan/freebsd/src/sys/WOMBAT i386

>Description:
C99 added the macros FLT_EVAL_METHOD and DECIMAL_DIG to <float.h>.  Since these
identifiers aren't in the namespace reserved for the implementation, a strictly
compliant C90 program is allowed to use them.  They must not be visible in a
C90 compilation mode like they currently are.

>How-To-Repeat:
$ cat test.c
#include <float.h>
int
main(void)
{
	int FLT_EVAL_METHOD, DECIMAL_DIG;
	return 0;
}
$ c89 -D_ANSI_SOURCE test.c
test.c: In function `main':
test.c:6: error: syntax error before '-' token

>Fix:
--- float.h.diff begins here ---
Index: src/sys/alpha/include/float.h
===================================================================
RCS file: /usr/home/ncvs/src/sys/alpha/include/float.h,v
retrieving revision 1.4
diff -u -r1.4 float.h
--- src/sys/alpha/include/float.h	8 Feb 2003 20:37:54 -0000	1.4
+++ src/sys/alpha/include/float.h	8 Mar 2004 15:31:24 -0000
@@ -45,8 +45,10 @@
 
 #define FLT_RADIX	2		/* b */
 #define FLT_ROUNDS	__flt_rounds()
+#if __ISO_C_VISIBLE >= 1999
 #define	FLT_EVAL_METHOD	0		/* no promotions */
 #define	DECIMAL_DIG	17		/* max precision in decimal digits */
+#endif
 
 #define FLT_MANT_DIG	24		/* p */
 #define FLT_EPSILON	1.19209290E-07F	/* b**(1-p) */
Index: src/sys/amd64/include/float.h
===================================================================
RCS file: /usr/home/ncvs/src/sys/amd64/include/float.h,v
retrieving revision 1.10
diff -u -r1.10 float.h
--- src/sys/amd64/include/float.h	8 Feb 2003 20:37:54 -0000	1.10
+++ src/sys/amd64/include/float.h	8 Mar 2004 15:57:46 -0000
@@ -37,10 +37,14 @@
 #ifndef _MACHINE_FLOAT_H_
 #define _MACHINE_FLOAT_H_ 1
 
+#include <sys/cdefs.h>
+
 #define FLT_RADIX	2		/* b */
 #define FLT_ROUNDS	1		/* FP addition rounds to nearest */
+#if __ISO_C_VISIBLE >= 1999
 #define	FLT_EVAL_METHOD	(-1)		/* i387 semantics are...interesting */
 #define	DECIMAL_DIG	21		/* max precision in decimal digits */
+#endif
 
 #define FLT_MANT_DIG	24		/* p */
 #define FLT_EPSILON	1.19209290E-07F	/* b**(1-p) */
Index: src/sys/i386/include/float.h
===================================================================
RCS file: /usr/home/ncvs/src/sys/i386/include/float.h,v
retrieving revision 1.10
diff -u -r1.10 float.h
--- src/sys/i386/include/float.h	8 Feb 2003 20:37:54 -0000	1.10
+++ src/sys/i386/include/float.h	8 Mar 2004 15:57:52 -0000
@@ -37,10 +37,14 @@
 #ifndef _MACHINE_FLOAT_H_
 #define _MACHINE_FLOAT_H_ 1
 
+#include <sys/cdefs.h>
+
 #define FLT_RADIX	2		/* b */
 #define FLT_ROUNDS	1		/* FP addition rounds to nearest */
+#if __ISO_C_VISIBLE >= 1999
 #define	FLT_EVAL_METHOD	(-1)		/* i387 semantics are...interesting */
 #define	DECIMAL_DIG	21		/* max precision in decimal digits */
+#endif
 
 #define FLT_MANT_DIG	24		/* p */
 #define FLT_EPSILON	1.19209290E-07F	/* b**(1-p) */
Index: src/sys/ia64/include/float.h
===================================================================
RCS file: /usr/home/ncvs/src/sys/ia64/include/float.h,v
retrieving revision 1.4
diff -u -r1.4 float.h
--- src/sys/ia64/include/float.h	27 Mar 2003 20:38:22 -0000	1.4
+++ src/sys/ia64/include/float.h	8 Mar 2004 15:32:04 -0000
@@ -41,8 +41,10 @@
 
 #define FLT_RADIX	2		/* b */
 #define FLT_ROUNDS	1		/* FP addition rounds to nearest */
+#if __ISO_C_VISIBLE >= 1999
 #define	FLT_EVAL_METHOD	0		/* no promotions */
 #define	DECIMAL_DIG	35		/* max precision in decimal digits */
+#endif
 
 #define FLT_MANT_DIG	24		/* p */
 #define FLT_EPSILON	1.19209290E-07F	/* b**(1-p) */
Index: src/sys/powerpc/include/float.h
===================================================================
RCS file: /usr/home/ncvs/src/sys/powerpc/include/float.h,v
retrieving revision 1.3
diff -u -r1.3 float.h
--- src/sys/powerpc/include/float.h	21 Jan 2004 04:56:39 -0000	1.3
+++ src/sys/powerpc/include/float.h	8 Mar 2004 15:58:00 -0000
@@ -38,10 +38,14 @@
 #ifndef _MACHINE_FLOAT_H_
 #define _MACHINE_FLOAT_H_ 1
 
+#include <sys/cdefs.h>
+
 #define FLT_RADIX	2		/* b */
 #define FLT_ROUNDS	1		/* FP addition rounds to nearest */
+#if __ISO_C_VISIBLE >= 1999
 #define	FLT_EVAL_METHOD	1		/* operands promoted to double */
 #define	DECIMAL_DIG	35		/* max precision in decimal digits */
+#endif
 
 #define FLT_MANT_DIG	24		/* p */
 #define FLT_EPSILON	1.19209290E-07F	/* b**(1-p) */
Index: src/sys/sparc64/include/float.h
===================================================================
RCS file: /usr/home/ncvs/src/sys/sparc64/include/float.h,v
retrieving revision 1.3
diff -u -r1.3 float.h
--- src/sys/sparc64/include/float.h	8 Feb 2003 20:37:55 -0000	1.3
+++ src/sys/sparc64/include/float.h	8 Mar 2004 15:31:50 -0000
@@ -55,8 +55,10 @@
 
 #define FLT_RADIX	2		/* b */
 #define FLT_ROUNDS	__flt_rounds()
+#if __ISO_C_VISIBLE >= 1999
 #define	FLT_EVAL_METHOD	0		/* no promotion */
 #define	DECIMAL_DIG	35		/* max precision in decimal digits */
+#endif
 
 #define FLT_MANT_DIG	24		/* p */
 #define FLT_EPSILON	1.19209290E-7F	/* b**(1-p) */
--- float.h.diff ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040308170241.F121B4CB>