forked from boostorg/system
Merge trunk, including changes to come into closer conformance with C++0x FCD
[SVN r63685]
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// boost/system/api_config.hpp -------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2003, 2006, 2010
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// See http://www.boost.org/libs/system for documentation.
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
// Boost.System calls operating system API functions to implement system error category
|
||||
// functions. Usually there is no question as to which API is to be used.
|
||||
//
|
||||
// In the case of MinGW or Cygwin/MinGW, however, both POSIX and Windows API's are
|
||||
// available. Chaos ensues if other code thinks one is in use when Boost.System was
|
||||
// actually built with the other. This header centralizes the API choice and prevents
|
||||
// user definition of API macros, thus elminating the possibility of mismatches and the
|
||||
// need to test configurations with little or no practical value.
|
||||
//
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_SYSTEM_API_CONFIG_HPP
|
||||
#define BOOST_SYSTEM_API_CONFIG_HPP
|
||||
|
||||
# if defined(BOOST_POSIX_API) || defined(BOOST_WINDOWS_API)
|
||||
# error user defined BOOST_POSIX_API or BOOST_WINDOWS_API not supported
|
||||
# endif
|
||||
|
||||
// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use
|
||||
// Cygwin/MinGW does not predefine _WIN32.
|
||||
// Standalone MinGW and all other known Windows compilers do predefine _WIN32
|
||||
// Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too.
|
||||
|
||||
# if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin
|
||||
# define BOOST_WINDOWS_API
|
||||
# else
|
||||
# define BOOST_POSIX_API
|
||||
# endif
|
||||
|
||||
#endif // BOOST_SYSTEM_API_CONFIG_HPP
|
||||
@@ -1,4 +1,4 @@
|
||||
// boost/system/config.hpp -------------------------------------------------//
|
||||
// boost/system/config.hpp -----------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2003, 2006
|
||||
|
||||
@@ -11,47 +11,24 @@
|
||||
#define BOOST_SYSTEM_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
|
||||
|
||||
// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use.
|
||||
// If not specified, a sensible default will be applied.
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
# if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API )
|
||||
# error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined
|
||||
# elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API )
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)
|
||||
# define BOOST_WINDOWS_API
|
||||
# else
|
||||
# define BOOST_POSIX_API
|
||||
# endif
|
||||
# endif
|
||||
// enable dynamic or static linking as requested --------------------------------------//
|
||||
|
||||
// enable dynamic linking on Windows ---------------------------------------//
|
||||
|
||||
//# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK)) && defined(__BORLANDC__) && defined(__WIN32__)
|
||||
//# error Dynamic linking Boost.System does not work for Borland; use static linking instead
|
||||
//# endif
|
||||
|
||||
#ifdef BOOST_HAS_DECLSPEC // defined in config system
|
||||
// we need to import/export our code only if the user has specifically
|
||||
// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
|
||||
// libraries to be dynamically linked, or BOOST_SYSTEM_DYN_LINK
|
||||
// if they want just this one to be dynamically liked:
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK)
|
||||
// export if this is our own source, otherwise import:
|
||||
#ifdef BOOST_SYSTEM_SOURCE
|
||||
# define BOOST_SYSTEM_DECL __declspec(dllexport)
|
||||
# if defined(BOOST_SYSTEM_SOURCE)
|
||||
# define BOOST_SYSTEM_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define BOOST_SYSTEM_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define BOOST_SYSTEM_DECL __declspec(dllimport)
|
||||
#endif // BOOST_SYSTEM_SOURCE
|
||||
#endif // DYN_LINK
|
||||
#endif // BOOST_HAS_DECLSPEC
|
||||
//
|
||||
// if BOOST_SYSTEM_DECL isn't defined yet define it now:
|
||||
#ifndef BOOST_SYSTEM_DECL
|
||||
#define BOOST_SYSTEM_DECL
|
||||
# define BOOST_SYSTEM_DECL
|
||||
#endif
|
||||
|
||||
// enable automatic library variant selection ------------------------------//
|
||||
// enable automatic library variant selection ----------------------------------------//
|
||||
|
||||
#if !defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SYSTEM_NO_LIB)
|
||||
//
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace boost
|
||||
{
|
||||
// To construct an error_code after a API error:
|
||||
//
|
||||
// error_code( errno, system_category )
|
||||
// error_code( errno, system_category() )
|
||||
|
||||
// User code should use the portable "posix" enums for POSIX errors; this
|
||||
// allows such code to be portable to non-POSIX systems. For the non-POSIX
|
||||
@@ -46,7 +46,7 @@ namespace boost
|
||||
namespace cygwin_error
|
||||
{
|
||||
inline error_code make_error_code( cygwin_errno e )
|
||||
{ return error_code( e, get_system_category() ); }
|
||||
{ return error_code( e, system_category() ); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,18 +202,18 @@ namespace boost
|
||||
|
||||
// predefined error categories -----------------------------------------//
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & get_system_category();
|
||||
BOOST_SYSTEM_DECL const error_category & get_generic_category();
|
||||
BOOST_SYSTEM_DECL const error_category & system_category();
|
||||
BOOST_SYSTEM_DECL const error_category & generic_category();
|
||||
|
||||
// deprecated synonyms --------------------------------------------------//
|
||||
|
||||
static const error_category & system_category = get_system_category();
|
||||
static const error_category & generic_category = get_generic_category();
|
||||
|
||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||
// deprecated synonyms
|
||||
inline const error_category & get_posix_category() { return get_generic_category(); }
|
||||
static const error_category & posix_category = get_generic_category();
|
||||
static const error_category & errno_ecat = get_generic_category();
|
||||
static const error_category & native_ecat = get_system_category();
|
||||
inline const error_category & get_system_category() { return system_category(); }
|
||||
inline const error_category & get_generic_category() { return generic_category(); }
|
||||
inline const error_category & get_posix_category() { return generic_category(); }
|
||||
static const error_category & posix_category = generic_category();
|
||||
static const error_category & errno_ecat = generic_category();
|
||||
static const error_category & native_ecat = system_category();
|
||||
# endif
|
||||
|
||||
// class error_condition -----------------------------------------------//
|
||||
@@ -225,7 +225,7 @@ namespace boost
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
error_condition() : m_val(0), m_cat(&get_generic_category()) {}
|
||||
error_condition() : m_val(0), m_cat(&generic_category()) {}
|
||||
error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
|
||||
|
||||
template <class ErrorConditionEnum>
|
||||
@@ -254,7 +254,7 @@ namespace boost
|
||||
void clear()
|
||||
{
|
||||
m_val = 0;
|
||||
m_cat = &get_generic_category();
|
||||
m_cat = &generic_category();
|
||||
}
|
||||
|
||||
// observers:
|
||||
@@ -312,7 +312,7 @@ namespace boost
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
error_code() : m_val(0), m_cat(&get_system_category()) {}
|
||||
error_code() : m_val(0), m_cat(&system_category()) {}
|
||||
error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
|
||||
|
||||
template <class ErrorCodeEnum>
|
||||
@@ -340,7 +340,7 @@ namespace boost
|
||||
void clear()
|
||||
{
|
||||
m_val = 0;
|
||||
m_cat = &get_system_category();
|
||||
m_cat = &system_category();
|
||||
}
|
||||
|
||||
// observers:
|
||||
@@ -473,11 +473,11 @@ namespace boost
|
||||
{
|
||||
// explicit conversion:
|
||||
inline error_code make_error_code( errc_t e )
|
||||
{ return error_code( e, get_generic_category() ); }
|
||||
{ return error_code( e, generic_category() ); }
|
||||
|
||||
// implicit conversion:
|
||||
inline error_condition make_error_condition( errc_t e )
|
||||
{ return error_condition( e, get_generic_category() ); }
|
||||
{ return error_condition( e, generic_category() ); }
|
||||
}
|
||||
|
||||
// error_category default implementation -------------------------------//
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace boost
|
||||
{
|
||||
// To construct an error_code after a API error:
|
||||
//
|
||||
// error_code( errno, system_category )
|
||||
// error_code( errno, system_category() )
|
||||
|
||||
// User code should use the portable "posix" enums for POSIX errors; this
|
||||
// allows such code to be portable to non-POSIX systems. For the non-POSIX
|
||||
@@ -99,7 +99,7 @@ namespace boost
|
||||
namespace linux_error
|
||||
{
|
||||
inline error_code make_error_code( linux_errno e )
|
||||
{ return error_code( e, get_system_category() ); }
|
||||
{ return error_code( e, system_category() ); }
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
|
||||
@@ -17,9 +17,11 @@ namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
// class system_error --------------------------------------------------//
|
||||
// class system_error ------------------------------------------------------------//
|
||||
|
||||
class system_error : public std::runtime_error
|
||||
class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error
|
||||
// BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared
|
||||
// library can be caught. See svn.boost.org/trac/boost/ticket/3697
|
||||
{
|
||||
public:
|
||||
system_error( error_code ec )
|
||||
@@ -62,11 +64,8 @@ namespace boost
|
||||
try
|
||||
{
|
||||
m_what = this->std::runtime_error::what();
|
||||
if ( m_error_code )
|
||||
{
|
||||
if ( !m_what.empty() ) m_what += ": ";
|
||||
m_what += m_error_code.message();
|
||||
}
|
||||
if ( !m_what.empty() ) m_what += ": ";
|
||||
m_what += m_error_code.message();
|
||||
}
|
||||
catch (...) { return std::runtime_error::what(); }
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace boost
|
||||
|
||||
// To construct an error_code after a API error:
|
||||
//
|
||||
// error_code( ::GetLastError(), system_category )
|
||||
// error_code( ::GetLastError(), system_category() )
|
||||
|
||||
namespace windows_error
|
||||
{
|
||||
@@ -107,7 +107,7 @@ namespace boost
|
||||
namespace windows_error
|
||||
{
|
||||
inline error_code make_error_code( windows_error_code e )
|
||||
{ return error_code( e, get_system_category() ); }
|
||||
{ return error_code( e, system_category() ); }
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
|
||||
Reference in New Issue
Block a user