system_error (system_category): To system_category().

2009-02-17  Benjamin Kosnik  <bkoz@redhat.com>

	* include/std/system_error (system_category): To system_category().
	(generic_category): To generic_category. DR 890.
	* src/system_error.cc: Define.
	* include/bits/functexcept.h: Only one __throw_system_error.
	* src/functexcept.cc: Same.
	* include/std/mutex: Fixup for changes above.
	* testsuite/19_diagnostics/error_condition/cons/1.cc: Same.
	* testsuite/19_diagnostics/error_code/cons/1.cc: Same.
	* testsuite/19_diagnostics/system_error/cons-1.cc: Same.
	* config/abi/pre/gnu.ver: Clean up exports.

From-SVN: r144259
This commit is contained in:
Benjamin Kosnik 2009-02-18 07:35:36 +00:00
parent 0705d3f487
commit 9b3003d590
12 changed files with 67 additions and 61 deletions

View File

@ -1,3 +1,21 @@
2009-02-17 Benjamin Kosnik <bkoz@redhat.com>
* include/std/system_error (system_category): To system_category().
(generic_category): To generic_category. DR 890.
* src/system_error.cc: Define.
* include/bits/functexcept.h: Only one __throw_system_error.
* src/functexcept.cc: Same.
* include/std/mutex: Fixup for changes above.
* testsuite/19_diagnostics/error_condition/cons/1.cc: Same.
* testsuite/19_diagnostics/error_code/cons/1.cc: Same.
* testsuite/19_diagnostics/system_error/cons-1.cc: Same.
* config/abi/pre/gnu.ver: Clean up exports.
2009-02-17 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/std/thread: Fix typo.
* src/thread.cc (thread::join): Use NULL.
2009-02-15 Paolo Carlini <paolo.carlini@oracle.com> 2009-02-15 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/39168 PR libstdc++/39168

View File

@ -902,8 +902,8 @@ GLIBCXX_3.4.11 {
_ZNSt6thread15_M_start_threadESt10shared_ptrINS_10_Impl_baseEE; _ZNSt6thread15_M_start_threadESt10shared_ptrINS_10_Impl_baseEE;
# system_error # system_error
_ZSt15system_category; _ZSt15system_categoryv;
_ZSt16generic_category; _ZSt16generic_categoryv;
_ZNKSt10error_code23default_error_conditionEv; _ZNKSt10error_code23default_error_conditionEv;
_ZNKSt14error_category23default_error_conditionEi; _ZNKSt14error_category23default_error_conditionEi;
@ -923,7 +923,6 @@ GLIBCXX_3.4.11 {
_ZNKSt4hashISt10error_codeEclES0_; _ZNKSt4hashISt10error_codeEclES0_;
_ZSt20__throw_system_errorPKc;
_ZSt20__throw_system_errori; _ZSt20__throw_system_errori;
# char16_t and char32_t # char16_t and char32_t

View File

@ -1,6 +1,6 @@
// Function-Based Exception Support -*- C++ -*- // Function-Based Exception Support -*- C++ -*-
// Copyright (C) 2001, 2004, 2005, 2008 Free Software Foundation, Inc. // Copyright (C) 2001, 2004, 2005, 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
@ -86,16 +86,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void void
__throw_underflow_error(const char*) __attribute__((__noreturn__)); __throw_underflow_error(const char*) __attribute__((__noreturn__));
// Helpers for exception objects in <ios>
void void
__throw_system_error(const char*) __attribute__((__noreturn__)); __throw_ios_failure(const char*) __attribute__((__noreturn__));
void void
__throw_system_error(int) __attribute__((__noreturn__)); __throw_system_error(int) __attribute__((__noreturn__));
// Helpers for exception objects in basic_ios
void
__throw_ios_failure(const char*) __attribute__((__noreturn__));
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
#endif #endif

View File

@ -493,9 +493,9 @@ namespace std
lock() lock()
{ {
if (!_M_device) if (!_M_device)
__throw_system_error((int)errc::operation_not_permitted); __throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns) else if (_M_owns)
__throw_system_error((int)errc::resource_deadlock_would_occur); __throw_system_error(int(errc::resource_deadlock_would_occur));
else else
{ {
_M_device->lock(); _M_device->lock();
@ -507,9 +507,9 @@ namespace std
try_lock() try_lock()
{ {
if (!_M_device) if (!_M_device)
__throw_system_error((int)errc::operation_not_permitted); __throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns) else if (_M_owns)
__throw_system_error((int)errc::resource_deadlock_would_occur); __throw_system_error(int(errc::resource_deadlock_would_occur));
else else
{ {
_M_owns = _M_device->try_lock(); _M_owns = _M_device->try_lock();
@ -522,9 +522,9 @@ namespace std
try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
{ {
if (!_M_device) if (!_M_device)
__throw_system_error((int)errc::operation_not_permitted); __throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns) else if (_M_owns)
__throw_system_error((int)errc::resource_deadlock_would_occur); __throw_system_error(int(errc::resource_deadlock_would_occur));
else else
{ {
_M_owns = _M_device->try_lock_until(__atime); _M_owns = _M_device->try_lock_until(__atime);
@ -537,9 +537,9 @@ namespace std
try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
{ {
if (!_M_device) if (!_M_device)
__throw_system_error((int)errc::operation_not_permitted); __throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns) else if (_M_owns)
__throw_system_error((int)errc::resource_deadlock_would_occur); __throw_system_error(int(errc::resource_deadlock_would_occur));
else else
{ {
_M_owns = _M_device->try_lock_for(__rtime); _M_owns = _M_device->try_lock_for(__rtime);
@ -551,7 +551,7 @@ namespace std
unlock() unlock()
{ {
if (!_M_owns) if (!_M_owns)
__throw_system_error((int)errc::operation_not_permitted); __throw_system_error(int(errc::operation_not_permitted));
else if (_M_device) else if (_M_device)
{ {
_M_device->unlock(); _M_device->unlock();

View File

@ -1,6 +1,6 @@
// <system_error> -*- C++ -*- // <system_error> -*- C++ -*-
// Copyright (C) 2007, 2008 Free Software Foundation, Inc. // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
@ -110,15 +110,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}; };
// DR 890. // DR 890.
extern const error_category& system_category; const error_category& system_category();
extern const error_category& generic_category; const error_category& generic_category();
/// error_code /// error_code
// Implementation-specific error identification // Implementation-specific error identification
struct error_code struct error_code
{ {
error_code() error_code()
: _M_value(0), _M_cat(&system_category) { } : _M_value(0), _M_cat(&system_category()) { }
error_code(int __v, const error_category& __cat) error_code(int __v, const error_category& __cat)
: _M_value(__v), _M_cat(&__cat) { } : _M_value(__v), _M_cat(&__cat) { }
@ -126,7 +126,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _ErrorCodeEnum> template<typename _ErrorCodeEnum>
error_code(_ErrorCodeEnum __e, error_code(_ErrorCodeEnum __e,
typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0) typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0)
: _M_value(static_cast<int>(__e)), _M_cat(&generic_category) : _M_value(static_cast<int>(__e)), _M_cat(&generic_category())
{ } { }
void void
@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void void
clear() clear()
{ assign(0, system_category); } { assign(0, system_category()); }
// DR 804. // DR 804.
template<typename _ErrorCodeEnum> template<typename _ErrorCodeEnum>
@ -146,7 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
error_code&>::type error_code&>::type
operator=(_ErrorCodeEnum __e) operator=(_ErrorCodeEnum __e)
{ {
assign(static_cast<int>(__e), generic_category); assign(static_cast<int>(__e), generic_category());
return *this; return *this;
} }
@ -182,7 +182,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// 19.4.2.6 non-member functions // 19.4.2.6 non-member functions
inline error_code inline error_code
make_error_code(errc __e) make_error_code(errc __e)
{ return error_code(static_cast<int>(__e), generic_category); } { return error_code(static_cast<int>(__e), generic_category()); }
inline bool inline bool
operator<(const error_code& __lhs, const error_code& __rhs) operator<(const error_code& __lhs, const error_code& __rhs)
@ -202,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Portable error identification // Portable error identification
struct error_condition struct error_condition
{ {
error_condition() : _M_value(0), _M_cat(&generic_category) { } error_condition() : _M_value(0), _M_cat(&generic_category()) { }
error_condition(int __v, const error_category& __cat) error_condition(int __v, const error_category& __cat)
: _M_value(__v), _M_cat(&__cat) { } : _M_value(__v), _M_cat(&__cat) { }
@ -211,7 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
error_condition(_ErrorConditionEnum __e, error_condition(_ErrorConditionEnum __e,
typename enable_if<is_error_condition_enum typename enable_if<is_error_condition_enum
<_ErrorConditionEnum>::value>::type* = 0) <_ErrorConditionEnum>::value>::type* = 0)
: _M_value(static_cast<int>(__e)), _M_cat(&generic_category) { } : _M_value(static_cast<int>(__e)), _M_cat(&generic_category()) { }
void void
assign(int __v, const error_category& __cat) assign(int __v, const error_category& __cat)
@ -226,13 +226,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
<_ErrorConditionEnum>::value, error_condition&>::type <_ErrorConditionEnum>::value, error_condition&>::type
operator=(_ErrorConditionEnum __e) operator=(_ErrorConditionEnum __e)
{ {
assign(static_cast<int>(__e), generic_category); assign(static_cast<int>(__e), generic_category());
return *this; return *this;
} }
void void
clear() clear()
{ assign(0, generic_category); } { assign(0, generic_category()); }
// 19.4.3.4 observers // 19.4.3.4 observers
int int
@ -264,7 +264,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// 19.4.3.6 non-member functions // 19.4.3.6 non-member functions
inline error_condition inline error_condition
make_error_condition(errc __e) make_error_condition(errc __e)
{ return error_condition(static_cast<int>(__e), generic_category); } { return error_condition(static_cast<int>(__e), generic_category()); }
inline bool inline bool
operator<(const error_condition& __lhs, const error_condition& __rhs) operator<(const error_condition& __lhs, const error_condition& __rhs)

View File

@ -89,7 +89,7 @@ namespace std
}; };
// Simple base type that the templatized, derived class containing // Simple base type that the templatized, derived class containing
// an abitrary functor can be converted to and called. // an arbitrary functor can be converted to and called.
struct _Impl_base struct _Impl_base
{ {
__shared_base_type _M_this_ptr; __shared_base_type _M_this_ptr;

View File

@ -1,4 +1,4 @@
// Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
@ -97,16 +97,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ throw underflow_error(_(__s)); } { throw underflow_error(_(__s)); }
void void
__throw_system_error(const char* __s) __throw_ios_failure(const char* __s)
{ throw system_error(error_code(), _(__s)); } { throw ios_base::failure(_(__s)); }
void void
__throw_system_error(int __i) __throw_system_error(int __i)
{ throw system_error(error_code(__i, generic_category)); } { throw system_error(error_code(__i, generic_category())); }
void
__throw_ios_failure(const char* __s)
{ throw ios_base::failure(_(__s)); }
#else #else
void void
__throw_bad_exception(void) __throw_bad_exception(void)
@ -161,16 +157,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ std::abort(); } { std::abort(); }
void void
__throw_system_error(const char* __s) __throw_ios_failure(const char*)
{ std::abort(); } { std::abort(); }
void void
__throw_system_error(int __i) __throw_system_error(int __i)
{ std::abort(); } { std::abort(); }
void
__throw_ios_failure(const char*)
{ std::abort(); }
#endif //__EXCEPTIONS #endif //__EXCEPTIONS
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE

View File

@ -1,6 +1,6 @@
// <system_error> implementation file // <system_error> implementation file
// Copyright (C) 2007, 2008 // Copyright (C) 2007, 2008, 2009
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
@ -73,8 +73,11 @@ namespace
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
const error_category& system_category = system_category_instance; const error_category&
const error_category& generic_category = generic_category_instance; system_category() { return system_category_instance; }
const error_category&
generic_category() { return generic_category_instance; }
system_error::~system_error() throw() { } system_error::~system_error() throw() { }

View File

@ -62,10 +62,7 @@ namespace std
int __e = EINVAL; int __e = EINVAL;
if (_M_id != id()) if (_M_id != id())
{ __e = __gthread_join(_M_id._M_thread, NULL);
void* __r = 0;
__e = __gthread_join(_M_id._M_thread, &__r);
}
if (__e) if (__e)
__throw_system_error(__e); __throw_system_error(__e);

View File

@ -1,7 +1,7 @@
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com> // 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2007, 2008 Free Software Foundation, Inc. // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
@ -29,7 +29,7 @@ int main()
// 1 // 1
std::error_code e1; std::error_code e1;
VERIFY( e1.value() == 0 ); VERIFY( e1.value() == 0 );
VERIFY( e1.category() == std::system_category ); VERIFY( e1.category() == std::system_category() );
// 2 // 2
const __gnu_test::test_category cat; const __gnu_test::test_category cat;
@ -40,7 +40,7 @@ int main()
// 3 // 3
std::error_code e3(std::errc::operation_not_supported); std::error_code e3(std::errc::operation_not_supported);
VERIFY( e3.value() == int(std::errc::operation_not_supported) ); VERIFY( e3.value() == int(std::errc::operation_not_supported) );
VERIFY( e3.category() == std::generic_category ); VERIFY( e3.category() == std::generic_category() );
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
@ -28,7 +28,7 @@ void test01()
// 1 // 1
std::error_condition e1; std::error_condition e1;
VERIFY( e1.value() == 0 ); VERIFY( e1.value() == 0 );
VERIFY( e1.category() == std::generic_category ); VERIFY( e1.category() == std::generic_category() );
// 2 // 2
const __gnu_test::test_category cat; const __gnu_test::test_category cat;
@ -39,7 +39,7 @@ void test01()
// 3 // 3
std::error_condition e3(std::errc::operation_not_supported); std::error_condition e3(std::errc::operation_not_supported);
VERIFY( e3.value() == int(std::errc::operation_not_supported) ); VERIFY( e3.value() == int(std::errc::operation_not_supported) );
VERIFY( e3.category() == std::generic_category ); VERIFY( e3.category() == std::generic_category() );
} }
int main() int main()

View File

@ -1,7 +1,7 @@
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// 2007-06-05 Benjamin Kosnik <bkoz@redhat.com> // 2007-06-05 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2007, 2008 Free Software Foundation, Inc. // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
@ -38,8 +38,8 @@ int main()
// 2 // 2
{ {
std::system_error err2(95, std::system_category, s); std::system_error err2(95, std::system_category(), s);
VERIFY( err2.code() == std::error_code(95, std::system_category) ); VERIFY( err2.code() == std::error_code(95, std::system_category()) );
VERIFY( std::strcmp(err2.runtime_error::what(), s.c_str()) == 0 ); VERIFY( std::strcmp(err2.runtime_error::what(), s.c_str()) == 0 );
} }