Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/include PR 36988: ISO C99 mandates that HUGE_VAL, HUGE_VALF, ...
details: https://anonhg.NetBSD.org/src/rev/cb0fd283daa0
branches: trunk
changeset: 752318:cb0fd283daa0
user: joerg <joerg%NetBSD.org@localhost>
date: Tue Feb 23 00:03:09 2010 +0000
description:
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.
diffstat:
include/math.h | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diffs (45 lines):
diff -r 3d90d33b215e -r cb0fd283daa0 include/math.h
--- a/include/math.h Mon Feb 22 23:52:17 2010 +0000
+++ b/include/math.h Tue Feb 23 00:03:09 2010 +0000
@@ -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 */
Home |
Main Index |
Thread Index |
Old Index