diff --git a/test/Jamfile b/test/Jamfile index 9e8fee6..d5a5b6d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -278,9 +278,25 @@ compile spinlock_windows_h_test.cpp ; compile yield_k_windows_h_test.cpp ; lib dll_test : dll_test_lib.cpp : shared:DLL_TEST_DYN_LINK=1 ; +explicit dll_test ; run dll_test_main.cpp dll_test : : : static : dll_test_static ; run dll_test_main.cpp dll_test : : : shared : dll_test_shared ; run make_shared_const_test.cpp ; run make_local_shared_const_test.cpp ; + +lib abi_test_mt : abi_test_lib.cpp : static ; +explicit abi_test_mt ; + +obj abi_test_lib_nt : abi_test_lib.cpp : BOOST_DISABLE_THREADS ; +explicit abi_test_lib_nt ; + +lib abi_test_nt : abi_test_lib_nt : static ; +explicit abi_test_nt ; + +run abi_test_main.cpp abi_test_mt : : : BOOST_DISABLE_THREADS : abi_test_nt_mt ; +run abi_test_main.cpp abi_test_nt : : : : abi_test_mt_nt ; + +run abi_test_main.cpp abi_test_mt/11 : : : 03 : abi_test_03_11 ; +run abi_test_main.cpp abi_test_mt/03 : : : 11 : abi_test_11_03 ; diff --git a/test/abi_test_lib.cpp b/test/abi_test_lib.cpp new file mode 100644 index 0000000..db46416 --- /dev/null +++ b/test/abi_test_lib.cpp @@ -0,0 +1,31 @@ +// Copyright 2018 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if defined(BOOST_DISABLE_THREADS) +BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is defined" ) +#else +BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is not defined" ) +#endif + +#if defined(BOOST_NO_CXX11_HDR_ATOMIC) +BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is defined" ) +#else +BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is not defined" ) +#endif + +void abi_test_1( boost::shared_ptr & p ) +{ + p.reset(); +} + +boost::shared_ptr abi_test_2( boost::shared_ptr const & p ) +{ + return p; +} diff --git a/test/abi_test_main.cpp b/test/abi_test_main.cpp new file mode 100644 index 0000000..f1de554 --- /dev/null +++ b/test/abi_test_main.cpp @@ -0,0 +1,71 @@ +// Copyright 2018 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if defined(BOOST_DISABLE_THREADS) +BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is defined" ) +#else +BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is not defined" ) +#endif + +#if defined(BOOST_NO_CXX11_HDR_ATOMIC) +BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is defined" ) +#else +BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is not defined" ) +#endif + +void abi_test_1( boost::shared_ptr & p ); +boost::shared_ptr abi_test_2( boost::shared_ptr const & p ); + +static int deleter_called; + +void deleter( void* ) +{ + ++deleter_called; +} + +int main() +{ + { + deleter_called = 0; + + boost::shared_ptr p( static_cast( 0 ), deleter ); + + BOOST_TEST_EQ( p.use_count(), 1 ); + + abi_test_1( p ); + + BOOST_TEST_EQ( p.use_count(), 0 ); + BOOST_TEST_EQ( deleter_called, 1 ); + } + + { + deleter_called = 0; + + boost::shared_ptr p1( static_cast( 0 ), deleter ); + + BOOST_TEST_EQ( p1.use_count(), 1 ); + + boost::shared_ptr p2 = abi_test_2( p1 ); + + BOOST_TEST_EQ( p1.use_count(), 2 ); + BOOST_TEST_EQ( p2.use_count(), 2 ); + + p1.reset(); + + BOOST_TEST_EQ( p2.use_count(), 1 ); + + p2.reset(); + + BOOST_TEST_EQ( deleter_called, 1 ); + } + + return boost::report_errors(); +}