aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2007-04-06 23:36:56 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2007-04-06 23:36:56 +0000
commit1bfe2e5fca9f4962aed93b1a1696784bf9cf1909 (patch)
treec771b6beaa1c816e9c29838ff51c42346b3c0734 /libstdc++-v3
parent91f753f8eed9fa2a89b149b02ac9059755598103 (diff)
downloadgcc-1bfe2e5fca9f4962aed93b1a1696784bf9cf1909.zip
gcc-1bfe2e5fca9f4962aed93b1a1696784bf9cf1909.tar.gz
gcc-1bfe2e5fca9f4962aed93b1a1696784bf9cf1909.tar.bz2
re PR libstdc++/31117 (c++locale.o thread-unsafe in libstdc++)
2007-04-06 Paolo Carlini <pcarlini@suse.de> PR libstdc++/31117 * config/locale/gnu/c_locale.cc (__convert_to_v): Do not use errno, just check that the value is finite. * config/locale/generic/c_locale.cc (__convert_to_v): Likewise. From-SVN: r123635
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/config/locale/generic/c_locale.cc26
-rw-r--r--libstdc++-v3/config/locale/gnu/c_locale.cc15
3 files changed, 27 insertions, 21 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 63e408c..6600997 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,12 @@
2007-04-06 Paolo Carlini <pcarlini@suse.de>
+ PR libstdc++/31117
+ * config/locale/gnu/c_locale.cc (__convert_to_v): Do not use errno,
+ just check that the value is finite.
+ * config/locale/generic/c_locale.cc (__convert_to_v): Likewise.
+
+2007-04-06 Paolo Carlini <pcarlini@suse.de>
+
* include/ext/type_traits.h (__numeric_traits): Move...
* include/ext/numeric_traits.h: ... here.
* include/Makefile.am: Add.
diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc
index 783b196..f448fa8 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.cc
+++ b/libstdc++-v3/config/locale/generic/c_locale.cc
@@ -1,6 +1,6 @@
// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -34,7 +34,6 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
-#include <cerrno> // For errno
#include <cmath> // For isinf, finite, finitef, fabs
#include <cstdlib> // For strof, strtold
#include <locale>
@@ -52,7 +51,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale&)
{
// Assumes __s formatted for "C" locale.
- errno = 0;
char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
char* __sanity;
@@ -63,19 +61,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
float __f = static_cast<float>(__d);
#ifdef _GLIBCXX_HAVE_FINITEF
if (!finitef (__f))
- errno = ERANGE;
+ __f = __builtin_huge_valf();
#elif defined (_GLIBCXX_HAVE_FINITE)
if (!finite (static_cast<double> (__f)))
- errno = ERANGE;
+ __f = __builtin_huge_valf();
#elif defined (_GLIBCXX_HAVE_ISINF)
if (isinf (static_cast<double> (__f)))
- errno = ERANGE;
+ __f = __builtin_huge_valf();
#else
if (fabs(__d) > numeric_limits<float>::max())
- errno = ERANGE;
+ __f = __builtin_huge_valf();
#endif
#endif
- if (__sanity != __s && errno != ERANGE)
+ if (__sanity != __s && __f != __builtin_huge_valf()
+ && __f != -__builtin_huge_valf())
__v = __f;
else
__err |= ios_base::failbit;
@@ -89,12 +88,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale&)
{
// Assumes __s formatted for "C" locale.
- errno = 0;
char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
char* __sanity;
double __d = strtod(__s, &__sanity);
- if (__sanity != __s && errno != ERANGE)
+ if (__sanity != __s && __d != __builtin_huge_val()
+ && __d != -__builtin_huge_val())
__v = __d;
else
__err |= ios_base::failbit;
@@ -108,20 +107,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
ios_base::iostate& __err, const __c_locale&)
{
// Assumes __s formatted for "C" locale.
- errno = 0;
char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
#if defined(_GLIBCXX_HAVE_STRTOLD)
char* __sanity;
long double __ld = strtold(__s, &__sanity);
- if (__sanity != __s && errno != ERANGE)
+ if (__sanity != __s && __ld != __builtin_huge_vall()
+ && __ld != -__builtin_huge_vall())
__v = __ld;
#else
typedef char_traits<char>::int_type int_type;
long double __ld;
int __p = sscanf(__s, "%Lf", &__ld);
if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
- && errno != ERANGE)
+ && __ld != __builtin_huge_vall()
+ && __ld != -__builtin_huge_vall())
__v = __ld;
#endif
else
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc
index 37db702..a811cc7 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.cc
+++ b/libstdc++-v3/config/locale/gnu/c_locale.cc
@@ -1,6 +1,6 @@
// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -34,7 +34,6 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
-#include <cerrno> // For errno
#include <locale>
#include <stdexcept>
#include <langinfo.h>
@@ -48,9 +47,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale& __cloc)
{
char* __sanity;
- errno = 0;
float __f = __strtof_l(__s, &__sanity, __cloc);
- if (__sanity != __s && errno != ERANGE)
+ if (__sanity != __s && __f != __builtin_huge_valf()
+ && __f != -__builtin_huge_valf())
__v = __f;
else
__err |= ios_base::failbit;
@@ -62,9 +61,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale& __cloc)
{
char* __sanity;
- errno = 0;
double __d = __strtod_l(__s, &__sanity, __cloc);
- if (__sanity != __s && errno != ERANGE)
+ if (__sanity != __s && __d != __builtin_huge_val()
+ && __d != -__builtin_huge_val())
__v = __d;
else
__err |= ios_base::failbit;
@@ -76,7 +75,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale& __cloc)
{
char* __sanity;
- errno = 0;
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
// Prefer strtold_l, as __strtold_l isn't prototyped in more recent
// glibc versions.
@@ -84,7 +82,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#else
long double __ld = __strtold_l(__s, &__sanity, __cloc);
#endif
- if (__sanity != __s && errno != ERANGE)
+ if (__sanity != __s && __ld != __builtin_huge_vall()
+ && __ld != -__builtin_huge_vall())
__v = __ld;
else
__err |= ios_base::failbit;