Module Name:    src
Committed By:   joerg
Date:           Tue Feb 23 00:03:10 UTC 2010

Modified Files:
        src/include: math.h

Log Message:
PR 36988: ISO C99 mandates that HUGE_VAL, HUGE_VALF, HUGE_VALL and
INFINITY are constant expressions.

Use the GCC builtins if possible to implement them.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/include/math.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/include/math.h
diff -u src/include/math.h:1.50 src/include/math.h:1.51
--- src/include/math.h:1.50	Mon Jan 11 16:28:39 2010
+++ src/include/math.h	Tue Feb 23 00:03:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: math.h,v 1.50 2010/01/11 16:28:39 christos Exp $	*/
+/*	$NetBSD: math.h,v 1.51 2010/02/23 00:03:09 joerg Exp $	*/
 
 /*
  * ====================================================
@@ -59,8 +59,12 @@
  * ANSI/POSIX
  */
 /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
+#if __GNUC_PREREQ__(3, 3)
+#define HUGE_VAL	__builtin_huge_val()
+#else
 extern const union __double_u __infinity;
 #define HUGE_VAL	__infinity.__val
+#endif
 
 /*
  * ISO C99
@@ -72,14 +76,21 @@
     ((_XOPEN_SOURCE  - 0) >= 600) || \
     defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
 /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
+#if __GNUC_PREREQ__(3, 3)
+#define	HUGE_VALF	__builtin_huge_valf()
+#define	HUGE_VALL	__builtin_huge_vall()
+#else
 extern const union __float_u __infinityf;
 #define	HUGE_VALF	__infinityf.__val
 
 extern const union __long_double_u __infinityl;
 #define	HUGE_VALL	__infinityl.__val
+#endif
 
 /* 7.12#4 INFINITY */
-#ifdef __INFINITY
+#if __GNUC_PREREQ__(3, 3)
+#define	INFINITY	__builtin_inff()
+#elif defined(__INFINITY)
 #define	INFINITY	__INFINITY	/* float constant which overflows */
 #else
 #define	INFINITY	HUGE_VALF	/* positive infinity */

Reply via email to