mirror of
https://github.com/boostorg/system.git
synced 2025-12-25 16:28:05 +01:00
Compare commits
7 Commits
feature/de
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb3f3a8e41 | ||
|
|
e6986a51d5 | ||
|
|
71ee26c188 | ||
|
|
8449c62162 | ||
|
|
4bca94ffc4 | ||
|
|
86ff47ff63 | ||
|
|
06ddfdb4a6 |
@@ -106,18 +106,6 @@ namespace boost
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class = void> struct stdcat_mx_holder
|
||||
{
|
||||
static mutex mx_;
|
||||
};
|
||||
|
||||
template<class T> mutex stdcat_mx_holder<T>::mx_;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
inline void error_category::init_stdcat() const
|
||||
{
|
||||
static_assert( sizeof( stdcat_ ) >= sizeof( boost::system::detail::std_category ), "sizeof(stdcat_) is not enough for std_category" );
|
||||
@@ -130,7 +118,13 @@ inline void error_category::init_stdcat() const
|
||||
|
||||
#endif
|
||||
|
||||
system::detail::lock_guard<system::detail::mutex> lk( system::detail::stdcat_mx_holder<>::mx_ );
|
||||
// detail::mutex has a constexpr default constructor,
|
||||
// and therefore guarantees static initialization, on
|
||||
// everything except VS 2013 (msvc-12.0)
|
||||
|
||||
static system::detail::mutex mx_;
|
||||
|
||||
system::detail::lock_guard<system::detail::mutex> lk( mx_ );
|
||||
|
||||
if( sc_init_.load( std::memory_order_acquire ) == 0 )
|
||||
{
|
||||
|
||||
@@ -31,6 +31,28 @@ struct mutex
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#elif defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION >= 140
|
||||
|
||||
// Under the MS STL, std::mutex::mutex() is not constexpr, as is
|
||||
// required by the standard, which leads to initialization order
|
||||
// issues. However, shared_mutex is based on SRWLock and its
|
||||
// default constructor is constexpr, so we use that instead.
|
||||
|
||||
#include <shared_mutex>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
typedef std::shared_mutex mutex;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#else
|
||||
|
||||
#include <mutex>
|
||||
|
||||
@@ -134,6 +134,8 @@ boost_test(TYPE run SOURCES win32_generic_test.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES ec_hash_value_test.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES std_interop_test16.cpp)
|
||||
|
||||
# result
|
||||
|
||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||
|
||||
@@ -162,6 +162,8 @@ run win32_generic_test.cpp ;
|
||||
|
||||
run ec_hash_value_test.cpp ;
|
||||
|
||||
run std_interop_test16.cpp ;
|
||||
|
||||
# result
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
57
test/std_interop_test16.cpp
Normal file
57
test/std_interop_test16.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright 2023 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_category.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/snprintf.hpp>
|
||||
#include <system_error>
|
||||
|
||||
// get_user_category
|
||||
|
||||
class user_category: public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char * name() const BOOST_NOEXCEPT
|
||||
{
|
||||
return "user";
|
||||
}
|
||||
|
||||
virtual std::string message( int ev ) const
|
||||
{
|
||||
char buffer[ 256 ];
|
||||
boost::core::snprintf( buffer, sizeof( buffer ), "user message %d", ev );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
||||
boost::system::error_category const & get_user_category()
|
||||
{
|
||||
static user_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool init_lwt = (boost::core::lwt_init(), true);
|
||||
|
||||
std::error_category const & cat = get_user_category();
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( cat.name(), "user" );
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user