Author: sebor
Date: Thu May 22 11:48:54 2008
New Revision: 659199
URL: http://svn.apache.org/viewvc?rev=659199&view=rev
Log:
2008-05-22 Martin Sebor <[EMAIL PROTECTED]>
* src/fpclass.h: New header with declarations of floating point
classification functions mirroring the equivalent macros defined
by C99 in <math.h>.
* src/num_put.cpp (__rw_isfinite, __rw_signbit, __rw_isinf,
__rw_isnan, __rw_isqnan, __rw_issnan): Moved inline functions to
the new fpclass.h header.
Added:
stdcxx/branches/4.2.x/src/fpclass.h (with props)
Modified:
stdcxx/branches/4.2.x/src/num_put.cpp
Added: stdcxx/branches/4.2.x/src/fpclass.h
URL:
http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/fpclass.h?rev=659199&view=auto
==============================================================================
--- stdcxx/branches/4.2.x/src/fpclass.h (added)
+++ stdcxx/branches/4.2.x/src/fpclass.h Thu May 22 11:48:54 2008
@@ -0,0 +1,270 @@
+/***************************************************************************
+ *
+ * fpclass.h - definitions of floating point classification functions
+ * mirrorring those defined by C99 in <math.h>
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the License); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 2008 Rogue Wave Software, Inc.
+ *
+ **************************************************************************/
+
+#ifndef _RWSTD_FPCLASS_H_INCLUDED
+#define _RWSTD_FPCLASS_H_INCLUDED
+
+#include <rw/_defs.h>
+
+#include <float.h> // for _finite(), _fpclass(), _isnan(), _copysign()
+#include <math.h> // for isfinite(), isnan(), isinf(), signbit()
+
+#ifndef _RWSTD_NO_IEEEFP_H
+# include <ieeefp.h> // for fpclass(), isnan()
+#endif // _RWSTD_NO_IEEEFP_H
+
+
+#if defined (_MSC_VER)
+
+
+inline bool
+__rw_isfinite (double val)
+{
+ return !!_finite (val);
+}
+
+
+inline bool
+__rw_signbit (double val)
+{
+ return 0 > _copysign (1., val);
+}
+
+
+inline bool
+__rw_isinf (double val)
+{
+ const int fpc = _fpclass (val);
+
+ if (_FPCLASS_NINF == fpc) {
+ // verify that __rw_signbit() correctly determines
+ // the sign of negative infinity
+ _RWSTD_ASSERT (__rw_signbit (val));
+ return true;
+ }
+ else if (_FPCLASS_PINF == fpc) {
+ // verify that __rw_signbit() correctly determines
+ // the sign of positive infinity
+ _RWSTD_ASSERT (!__rw_signbit (val));
+ return true;
+ }
+
+ return false;
+}
+
+
+inline bool
+__rw_isnan (double val)
+{
+ return !!_isnan (val);
+}
+
+
+inline bool __rw_isqnan (double val)
+{
+ return _FPCLASS_QNAN == _fpclass (val);
+}
+
+
+inline bool __rw_issnan (double val)
+{
+ return _FPCLASS_SNAN == _fpclass (val);
+}
+
+
+#elif defined (_RWSTD_OS_SUNOS)
+
+inline bool
+__rw_isfinite (double val)
+{
+ return !!finite (val);
+}
+
+
+inline bool
+__rw_signbit (double val)
+{
+ // implement own signbit() to avoid dragging in libm or libsunmath
+ return _RWSTD_REINTERPRET_CAST (const _RWSTD_UINT64_T&, val) >> 63;
+}
+
+
+inline bool
+__rw_isinf (double val)
+{
+ const int fpc = fpclass (val);
+
+ if (FP_NINF == fpc) {
+ // verify that __rw_signbit() correctly determines
+ // the sign of negative infinity
+ _RWSTD_ASSERT (__rw_signbit (val));
+ return true;
+ }
+ else if (FP_PINF == fpc) {
+ // verify that __rw_signbit() correctly determines
+ // the sign of positive infinity
+ _RWSTD_ASSERT (!__rw_signbit (val));
+ return true;
+ }
+
+ return false;
+}
+
+
+inline bool
+__rw_isnan (double val)
+{
+ return 0 != isnan (val);
+}
+
+
+inline bool
+__rw_isqnan (double val)
+{
+ return FP_QNAN == fpclass (val);
+}
+
+
+inline bool
+__rw_issnan (double val)
+{
+ return FP_SNAN == fpclass (val);
+}
+
+
+#elif defined (fpclassify)
+
+
+inline bool
+__rw_isfinite (double val)
+{
+ return !!isfinite (val);
+}
+
+
+inline bool
+__rw_signbit (double val)
+{
+ return !!signbit (val);
+}
+
+
+inline bool
+__rw_isinf (double val)
+{
+ return !!isinf (val);
+}
+
+
+inline bool
+__rw_isnan (double val)
+{
+ return !!isnan (val);
+}
+
+
+inline bool
+__rw_isqnan (double)
+{
+ return false;
+}
+
+
+inline bool
+__rw_issnan (double)
+{
+ return false;
+}
+
+#else
+
+inline bool __rw_isfinite (double) { return true; }
+
+inline bool __rw_signbit (double) { return false; }
+
+inline bool __rw_isinf (double) { return false; }
+
+inline bool __rw_isnan (double) { return false; }
+
+inline bool __rw_isqnan (double) { return false; }
+
+inline bool __rw_issnan (double) { return false; }
+
+#endif
+
+
+inline bool __rw_isfinite (float) { return true; }
+
+inline bool __rw_signbit (float) { return false; }
+
+inline bool __rw_isinf (float) { return false; }
+
+inline bool __rw_isnan (float) { return false; }
+
+inline bool __rw_isqnan (float) { return false; }
+
+inline bool __rw_issnan (float) { return false; }
+
+
+#ifndef _RWSTD_NO_LONG_DOUBLE
+
+# if _RWSTD_DBL_SIZE == _RWSTD_LDBL_SIZE
+
+inline bool __rw_isfinite (long double x) { return __rw_isfinite (double (x));
}
+
+inline bool __rw_signbit (long double x) { return __rw_signbit (double (x)); }
+
+inline bool __rw_isinf (long double x) { return __rw_isinf (double (x)); }
+
+inline bool __rw_isnan (long double x) { return __rw_isnan (double (x)); }
+
+inline bool __rw_isqnan (long double x) { return __rw_isqnan (double (x)); }
+
+inline bool __rw_issnan (long double x) { return __rw_issnan (double (x)); }
+
+# else // _RWSTD_DBL_SIZE != _RWSTD_LDBL_SIZE
+
+inline bool __rw_isfinite (long double) { return true; }
+
+inline bool __rw_signbit (long double) { return false; }
+
+inline bool __rw_isinf (long double) { return false; }
+
+inline bool __rw_isnan (long double) { return false; }
+
+inline bool __rw_isqnan (long double) { return false; }
+
+inline bool __rw_issnan (long double) { return false; }
+
+# endif // _RWSTD_DBL_SIZE == _RWSTD_LDBL_SIZE
+
+#endif // _RWSTD_NO_LONG_DOUBLE
+
+
+#endif // _RWSTD_FPCLASS_H_INCLUDED
Propchange: stdcxx/branches/4.2.x/src/fpclass.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: stdcxx/branches/4.2.x/src/fpclass.h
------------------------------------------------------------------------------
svn:keywords = Id
Modified: stdcxx/branches/4.2.x/src/num_put.cpp
URL:
http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/num_put.cpp?rev=659199&r1=659198&r2=659199&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/src/num_put.cpp (original)
+++ stdcxx/branches/4.2.x/src/num_put.cpp Thu May 22 11:48:54 2008
@@ -34,15 +34,9 @@
#include <stdio.h> // for snprintf()
#include <string.h> // for memmove(), memset()
-#include <float.h> // for _finite(), _fpclass(), _isnan(), _copysign()
-#include <math.h> // for isfinite(), isnan(), isinf(), signbit()
-
-#ifndef _RWSTD_NO_IEEEFP_H
-# include <ieeefp.h> // for fpclass(), isnan()
-#endif // _RWSTD_NO_IEEEFP_H
-
#include <loc/_num_put.h>
+#include "fpclass.h" // for __rw_isfinite(), ...
#include "strtol.h" // for __rw_digit_map
#include "punct.h" // for __rw_get_stdio_fmat
@@ -80,155 +74,6 @@
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-#if defined (_MSC_VER)
-
-inline bool __rw_isfinite (double val) { return !!_finite (val); }
-
-inline bool __rw_signbit (double val) { return 0 > _copysign (1., val); }
-
-inline bool __rw_isinf (double val) {
- const int fpc = _fpclass (val);
-
- if (_FPCLASS_NINF == fpc) {
- // verify that __rw_signbit() correctly determines
- // the sign of negative infinity
- _RWSTD_ASSERT (__rw_signbit (val));
- return true;
- }
- else if (_FPCLASS_PINF == fpc) {
- // verify that __rw_signbit() correctly determines
- // the sign of positive infinity
- _RWSTD_ASSERT (!__rw_signbit (val));
- return true;
- }
-
- return false;
-}
-
-inline bool __rw_isnan (double val) { return !!_isnan (val); }
-
-inline bool __rw_isqnan (double val) {
- return _FPCLASS_QNAN == _fpclass (val);
-}
-
-inline bool __rw_issnan (double val) {
- return _FPCLASS_SNAN == _fpclass (val);
-}
-
-#elif defined (_RWSTD_OS_SUNOS)
-
-inline bool __rw_isfinite (double val) { return !!finite (val); }
-
-inline bool __rw_signbit (double val)
-{
- // implement own signbit() to avoid dragging in libm or libsunmath
- return _RWSTD_REINTERPRET_CAST (const _RWSTD_UINT64_T&, val) >> 63;
-}
-
-inline bool __rw_isinf (double val) {
- const int fpc = fpclass (val);
-
- if (FP_NINF == fpc) {
- // verify that __rw_signbit() correctly determines
- // the sign of negative infinity
- _RWSTD_ASSERT (__rw_signbit (val));
- return true;
- }
- else if (FP_PINF == fpc) {
- // verify that __rw_signbit() correctly determines
- // the sign of positive infinity
- _RWSTD_ASSERT (!__rw_signbit (val));
- return true;
- }
-
- return false;
-}
-
-inline bool __rw_isnan (double val) { return 0 != isnan (val); }
-
-inline bool __rw_isqnan (double val) { return FP_QNAN == fpclass (val); }
-
-inline bool __rw_issnan (double val) { return FP_SNAN == fpclass (val); }
-
-#elif defined (fpclassify)
-
-inline bool __rw_isfinite (double val) { return !!isfinite (val); }
-
-inline bool __rw_signbit (double val) { return !!signbit (val); }
-
-inline bool __rw_isinf (double val) { return !!isinf (val); }
-
-inline bool __rw_isnan (double val) { return !!isnan (val); }
-
-inline bool __rw_isqnan (double) { return false; }
-
-inline bool __rw_issnan (double) { return false; }
-
-#else
-
-inline bool __rw_isfinite (double) { return true; }
-
-inline bool __rw_signbit (double) { return false; }
-
-inline bool __rw_isinf (double) { return false; }
-
-inline bool __rw_isnan (double) { return false; }
-
-inline bool __rw_isqnan (double) { return false; }
-
-inline bool __rw_issnan (double) { return false; }
-
-#endif
-
-
-inline bool __rw_isfinite (float) { return true; }
-
-inline bool __rw_signbit (float) { return false; }
-
-inline bool __rw_isinf (float) { return false; }
-
-inline bool __rw_isnan (float) { return false; }
-
-inline bool __rw_isqnan (float) { return false; }
-
-inline bool __rw_issnan (float) { return false; }
-
-
-#ifndef _RWSTD_NO_LONG_DOUBLE
-
-# if _RWSTD_DBL_SIZE == _RWSTD_LDBL_SIZE
-
-inline bool __rw_isfinite (long double x) { return __rw_isfinite (double (x));
}
-
-inline bool __rw_signbit (long double x) { return __rw_signbit (double (x)); }
-
-inline bool __rw_isinf (long double x) { return __rw_isinf (double (x)); }
-
-inline bool __rw_isnan (long double x) { return __rw_isnan (double (x)); }
-
-inline bool __rw_isqnan (long double x) { return __rw_isqnan (double (x)); }
-
-inline bool __rw_issnan (long double x) { return __rw_issnan (double (x)); }
-
-# else // _RWSTD_DBL_SIZE != _RWSTD_LDBL_SIZE
-
-inline bool __rw_isfinite (long double) { return true; }
-
-inline bool __rw_signbit (long double) { return false; }
-
-inline bool __rw_isinf (long double) { return false; }
-
-inline bool __rw_isnan (long double) { return false; }
-
-inline bool __rw_isqnan (long double) { return false; }
-
-inline bool __rw_issnan (long double) { return false; }
-
-# endif // _RWSTD_DBL_SIZE == _RWSTD_LDBL_SIZE
-
-#endif // _RWSTD_NO_LONG_DOUBLE
-
-
static int
__rw_fmat_infinite (char *buf, size_t bufsize, double val, unsigned flags)
{