From stdcxx-commits-return-1649-apmail-incubator-stdcxx-commits-archive=incubator.apache.org@incubator.apache.org Thu Aug 23 21:29:28 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 18969 invoked from network); 23 Aug 2007 21:29:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Aug 2007 21:29:28 -0000 Received: (qmail 36592 invoked by uid 500); 23 Aug 2007 21:29:25 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 36575 invoked by uid 500); 23 Aug 2007 21:29:25 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 36564 invoked by uid 99); 23 Aug 2007 21:29:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2007 14:29:24 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2007 21:29:27 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 722AF1A983A; Thu, 23 Aug 2007 14:29:07 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r569152 - /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp Date: Thu, 23 Aug 2007 21:29:07 -0000 To: stdcxx-commits@incubator.apache.org From: ablack@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070823212907.722AF1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ablack Date: Thu Aug 23 14:29:06 2007 New Revision: 569152 URL: http://svn.apache.org/viewvc?rev=569152&view=rev Log: 2007-08-23 Andrew Black STDCXX-482 * LIMITS.cpp: Deploy http://svn.apache.org/viewvc?view=rev&rev=555106 to 4.2.0 to avoid stalls in nightly testing testing system (caused by usage of the 4.2.0 branch in the nightly testing system.) Modified: incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp Modified: incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp?rev=569152&r1=569151&r2=569152&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp (original) +++ incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp Thu Aug 23 14:29:06 2007 @@ -155,7 +155,7 @@ template -T compute_limits (T, const char *pfx, const char *sfx, const char *type) +T compute_limits (T *pval, const char *pfx, const char *sfx, const char *type) { T min = T (-one); T max = T (one); @@ -167,17 +167,17 @@ // compute the maximum representable value for (; T (max * two) > max; max *= two); - for (T n = max / (two + two); n; ) { - if (T (max + n) < max) { - if (n > T (two)) - n /= two; + for (*pval = max / (two + two); *pval; ) { + if (T (max + *pval) < max) { + if (*pval > T (two)) + *pval /= two; else if (max < T (max + one)) - n = one; + *pval = one; else break; } else - max += n; + max += *pval; } // print the maximum representable value @@ -281,18 +281,24 @@ } printf ("#define _RWSTD_NO_TWOS_COMPLEMENT\n"); - compute_limits ((char)0, "CHAR", "", "char"); - compute_limits ((signed char)0, "SCHAR", "", "signed char"); - compute_limits ((unsigned char)0, "UCHAR", "U", "unsigned char"); +#define MKLIMITS(T, pfx, sfx, type) \ + do { \ + T buf = 0; \ + compute_limits (&buf, pfx, sfx, type); \ + } while (0) + + MKLIMITS (char, "CHAR", "", "char"); + MKLIMITS (signed char, "SCHAR", "", "signed char"); + MKLIMITS (unsigned char, "UCHAR", "U", "unsigned char"); - compute_limits ((short)0, "SHRT", "", "short"); - compute_limits ((unsigned short)0, "USHRT", "U", "unsigned short"); + MKLIMITS (short, "SHRT", "", "short"); + MKLIMITS (unsigned short, "USHRT", "U", "unsigned short"); - compute_limits ((int)0, "INT", "", "int"); - compute_limits ((unsigned int)0, "UINT", "U", "unsigned int"); + MKLIMITS (int, "INT", "", "int"); + MKLIMITS (unsigned int, "UINT", "U", "unsigned int"); - compute_limits ((long)0, "LONG", "L", "long"); - compute_limits ((unsigned long)0, "ULONG", "UL", "unsigned long"); + MKLIMITS (long, "LONG", "L", "long"); + MKLIMITS (unsigned long, "ULONG", "UL", "unsigned long"); #ifndef _RWSTD_NO_LONG_LONG @@ -302,8 +308,8 @@ const char llong_name[] = "long long"; - compute_limits ((LLong)0, "LLONG", "LL", "long long"); - compute_limits ((unsigned LLong)0, "ULLONG", "ULL", "unsigned long long"); + MKLIMITS (LLong, "LLONG", "LL", "long long"); + MKLIMITS (unsigned LLong, "ULLONG", "ULL", "unsigned long long"); #else // if defined (_RWSTD_NO_LONG_LONG) @@ -315,9 +321,8 @@ const char llong_name[] = "__int64"; - compute_limits ((LLong)0, "LLONG", "L", "__int64"); - compute_limits ((unsigned LLong)0, "ULLONG", "UL", - "unsigned __int64"); + MKLIMITS (LLong, "LLONG", "L", "__int64"); + MKLIMITS (unsigned LLong, "ULLONG", "UL", "unsigned __int64"); # else @@ -331,14 +336,14 @@ #ifndef _RWSTD_NO_WCHAR_T - printf ("#define _RWSTD_WCHAR_T_SIZE %2u /* sizeof (wchar_t) */\n", + printf ("#define _RWSTD_WCHAR_SIZE %2u /* sizeof (wchar_t) */\n", SIZEOF (wchar_t)); const char *suffix = "U"; if ((wchar_t)~0 < (wchar_t)0) suffix = ""; - compute_limits ((wchar_t)0, "WCHAR_T", suffix, "wchar_t"); + MKLIMITS (wchar_t, "WCHAR", suffix, "wchar_t"); #endif // _RWSTD_NO_WCHAR_T