Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 98486 invoked from network); 22 May 2008 18:49:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 May 2008 18:49:17 -0000 Received: (qmail 49610 invoked by uid 500); 22 May 2008 18:49:18 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 49593 invoked by uid 500); 22 May 2008 18:49:18 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 49584 invoked by uid 99); 22 May 2008 18:49:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 May 2008 11:49:18 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 May 2008 18:48:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0FB9C23889C1; Thu, 22 May 2008 11:48:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r659199 - in /stdcxx/branches/4.2.x/src: fpclass.h num_put.cpp Date: Thu, 22 May 2008 18:48:55 -0000 To: commits@stdcxx.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080522184856.0FB9C23889C1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 * src/fpclass.h: New header with declarations of floating point classification functions mirroring the equivalent macros defined by C99 in . * 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 + * + * $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 + +#include // for _finite(), _fpclass(), _isnan(), _copysign() +#include // for isfinite(), isnan(), isinf(), signbit() + +#ifndef _RWSTD_NO_IEEEFP_H +# include // 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 // for snprintf() #include // for memmove(), memset() -#include // for _finite(), _fpclass(), _isnan(), _copysign() -#include // for isfinite(), isnan(), isinf(), signbit() - -#ifndef _RWSTD_NO_IEEEFP_H -# include // for fpclass(), isnan() -#endif // _RWSTD_NO_IEEEFP_H - #include +#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) {