update boost on linux

This commit is contained in:
Bassem Girgis
2019-08-10 16:06:25 -05:00
parent 76ad52be58
commit 861b918727
5363 changed files with 483306 additions and 116507 deletions

View File

@@ -23,7 +23,6 @@
// Boost.Test
#include <boost/test/detail/config.hpp>
#include <boost/test/detail/workaround.hpp>
#include <boost/test/detail/throw_exception.hpp>
#include <boost/test/execution_monitor.hpp>
#include <boost/test/debug.hpp>
@@ -35,6 +34,7 @@
#ifndef BOOST_NO_EXCEPTIONS
#include <boost/exception/get_error_info.hpp> // for get_error_info
#include <boost/exception/current_exception_cast.hpp> // for current_exception_cast
#include <boost/exception/diagnostic_information.hpp>
#endif
// STL
@@ -47,28 +47,32 @@
#include <cassert> // for assert
#include <cstddef> // for NULL
#include <cstdio> // for vsnprintf
#include <stdio.h>
#include <cstdarg> // for varargs
#include <stdarg.h>
#include <cmath> // for ceil
#include <iostream> // for varargs
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std { using ::strerror; using ::strlen; using ::strncat; }
namespace std { using ::strerror; using ::strlen; using ::strncat; using ::ceil; }
#endif
// to use vsnprintf
#if defined(__SUNPRO_CC) || defined(__SunOS)
# include <stdio.h>
# include <stdarg.h>
#if defined(__SUNPRO_CC) || defined(__SunOS) || defined(__QNXNTO__) || defined(__VXWORKS__)
using std::va_list;
#endif
// to use vsnprintf
#if defined(__QNXNTO__)
# include <stdio.h>
using std::va_list;
#if defined(__VXWORKS__)
# define BOOST_TEST_LIMITED_SIGNAL_DETAILS
#endif
#ifdef BOOST_SEH_BASED_SIGNAL_HANDLING
# if !defined(_WIN32_WINNT) // WinXP
# define _WIN32_WINNT 0x0501
# endif
# include <windows.h>
# if defined(__MWERKS__) || (defined(_MSC_VER) && !defined(UNDER_CE))
@@ -102,6 +106,10 @@ using std::va_list;
# define BOOST_TEST_CRT_SET_HOOK(H) (void*)(H)
# endif
# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) /* WinXP */
# define BOOST_TEST_WIN32_WAITABLE_TIMERS
# endif
# if (!BOOST_WORKAROUND(_MSC_VER, >= 1400 ) && \
!defined(BOOST_COMO)) || defined(UNDER_CE)
@@ -210,7 +218,8 @@ namespace detail {
# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) std::vsnprintf( (a1), (a2), (a3), (a4) )
#elif BOOST_WORKAROUND(_MSC_VER, <= 1310) || \
BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3000)) || \
defined(UNDER_CE)
defined(UNDER_CE) || \
(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) _vsnprintf( (a1), (a2), (a3), (a4) )
#else
# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) vsnprintf( (a1), (a2), (a3), (a4) )
@@ -363,11 +372,17 @@ system_signal_exception::report() const
return; // no error actually occur?
switch( m_sig_info->si_code ) {
#ifdef __VXWORKS__
// a bit of a hack to adapt code to small m_sig_info VxWorks uses
#define si_addr si_value.sival_int
#define si_band si_value.sival_int
#else
case SI_USER:
report_error( execution_exception::system_error,
"signal: generated by kill() (or family); uid=%d; pid=%d",
(int)m_sig_info->si_uid, (int)m_sig_info->si_pid );
break;
#endif
case SI_QUEUE:
report_error( execution_exception::system_error,
"signal: sent by sigqueue()" );
@@ -686,7 +701,7 @@ signal_action::~signal_action()
class signal_handler {
public:
// Constructor
explicit signal_handler( bool catch_system_errors, bool detect_fpe, unsigned timeout, bool attach_dbg, char* alt_stack );
explicit signal_handler( bool catch_system_errors, bool detect_fpe, unsigned timeout_microseconds, bool attach_dbg, char* alt_stack );
// Destructor
~signal_handler();
@@ -709,7 +724,7 @@ public:
private:
// Data members
signal_handler* m_prev_handler;
unsigned m_timeout;
unsigned m_timeout_microseconds;
// Note: We intentionality do not catch SIGCHLD. Users have to deal with it themselves
signal_action m_ILL_action;
@@ -733,24 +748,24 @@ signal_handler* signal_handler::s_active_handler = signal_handler_ptr();
//____________________________________________________________________________//
signal_handler::signal_handler( bool catch_system_errors, bool detect_fpe, unsigned timeout, bool attach_dbg, char* alt_stack )
signal_handler::signal_handler( bool catch_system_errors, bool detect_fpe, unsigned timeout_microseconds, bool attach_dbg, char* alt_stack )
: m_prev_handler( s_active_handler )
, m_timeout( timeout )
, m_ILL_action ( SIGILL , catch_system_errors, attach_dbg, alt_stack )
, m_FPE_action ( SIGFPE , detect_fpe , attach_dbg, alt_stack )
, m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack )
, m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack )
, m_timeout_microseconds( timeout_microseconds )
, m_ILL_action ( SIGILL , catch_system_errors, attach_dbg, alt_stack )
, m_FPE_action ( SIGFPE , detect_fpe , attach_dbg, alt_stack )
, m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack )
, m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack )
#ifdef BOOST_TEST_CATCH_SIGPOLL
, m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack )
, m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack )
#endif
, m_ABRT_action( SIGABRT, catch_system_errors, attach_dbg, alt_stack )
, m_ALRM_action( SIGALRM, timeout > 0 , attach_dbg, alt_stack )
, m_ABRT_action( SIGABRT, catch_system_errors, attach_dbg, alt_stack )
, m_ALRM_action( SIGALRM, timeout_microseconds > 0, attach_dbg, alt_stack )
{
s_active_handler = this;
if( m_timeout > 0 ) {
if( m_timeout_microseconds > 0 ) {
::alarm( 0 );
::alarm( timeout );
::alarm( static_cast<unsigned int>(std::ceil(timeout_microseconds / 1E6) )); // alarm has a precision to the seconds
}
#ifdef BOOST_TEST_USE_ALT_STACK
@@ -776,7 +791,7 @@ signal_handler::~signal_handler()
{
assert( s_active_handler == this );
if( m_timeout > 0 )
if( m_timeout_microseconds > 0 )
::alarm( 0 );
#ifdef BOOST_TEST_USE_ALT_STACK
@@ -892,8 +907,10 @@ public:
, m_se_id( 0 )
, m_fault_address( 0 )
, m_dir( false )
, m_timeout( false )
{}
void set_timed_out();
void report() const;
int operator()( unsigned id, _EXCEPTION_POINTERS* exps );
@@ -904,6 +921,7 @@ private:
unsigned m_se_id;
void* m_fault_address;
bool m_dir;
bool m_timeout;
};
//____________________________________________________________________________//
@@ -918,6 +936,14 @@ seh_catch_preventer( unsigned /* id */, _EXCEPTION_POINTERS* /* exps */ )
//____________________________________________________________________________//
void
system_signal_exception::set_timed_out()
{
m_timeout = true;
}
//____________________________________________________________________________//
int
system_signal_exception::operator()( unsigned id, _EXCEPTION_POINTERS* exps )
{
@@ -1069,7 +1095,12 @@ system_signal_exception::report() const
break;
default:
detail::report_error( execution_exception::system_error, "unrecognized exception. Id: 0x%08lx", m_se_id );
if( m_timeout ) {
detail::report_error(execution_exception::timeout_error, "timeout while executing function");
}
else {
detail::report_error( execution_exception::system_error, "unrecognized exception. Id: 0x%08lx", m_se_id );
}
break;
}
}
@@ -1128,6 +1159,31 @@ execution_monitor::catch_signals( boost::function<int ()> const& F )
#endif
}
#if defined(BOOST_TEST_WIN32_WAITABLE_TIMERS)
HANDLE htimer = INVALID_HANDLE_VALUE;
BOOL bTimerSuccess = FALSE;
if( p_timeout ) {
htimer = ::CreateWaitableTimer(
NULL,
TRUE,
TEXT("Boost.Test timer"));
if( htimer != INVALID_HANDLE_VALUE ) {
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = - static_cast<signed long int>(p_timeout) * 10; // resolution of 100 ns
bTimerSuccess = ::SetWaitableTimer(
htimer,
&liDueTime,
0,
0,
0,
FALSE); // Do not restore a suspended system
}
}
#endif
detail::system_signal_exception SSE( this );
int ret_val = 0;
@@ -1141,8 +1197,26 @@ execution_monitor::catch_signals( boost::function<int ()> const& F )
__except( SSE( GetExceptionCode(), GetExceptionInformation() ) ) {
throw SSE;
}
// we check for time outs: we do not have any signaling facility on Win32
// however, we signal a timeout as a hard error as for the other operating systems
// and throw the signal error handler
if( bTimerSuccess && htimer != INVALID_HANDLE_VALUE) {
if (::WaitForSingleObject(htimer, 0) == WAIT_OBJECT_0) {
SSE.set_timed_out();
throw SSE;
}
}
}
__finally {
#if defined(BOOST_TEST_WIN32_WAITABLE_TIMERS)
if( htimer != INVALID_HANDLE_VALUE ) {
::CloseHandle(htimer);
}
#endif
if( l_catch_system_errors ) {
BOOST_TEST_CRT_SET_HOOK( old_crt_hook );
@@ -1198,7 +1272,7 @@ execution_monitor::execute( boost::function<int ()> const& F )
BOOST_TEST_I_TRY {
detail::fpe_except_guard G( p_detect_fp_exceptions );
unit_test::ut_detail::ignore_unused_variable_warning( G );
boost::ignore_unused( G );
return catch_signals( F );
}
@@ -1217,6 +1291,16 @@ execution_monitor::execute( boost::function<int ()> const& F )
{ detail::report_error( execution_exception::cpp_exception_error,
"std::string: %s", ex.c_str() ); }
// boost::exception (before std::exception, with extended diagnostic)
catch( boost::exception const& ex )
{ detail::report_error( execution_exception::cpp_exception_error,
&ex,
#if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI)
"unknown boost::exception" ); }
#else
boost::diagnostic_information(ex).c_str() ); }
#endif
// std:: exceptions
#if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI)
#define CATCH_AND_REPORT_STD_EXCEPTION( ex_name ) \
@@ -1235,15 +1319,8 @@ execution_monitor::execute( boost::function<int ()> const& F )
#endif
CATCH_AND_REPORT_STD_EXCEPTION( std::bad_alloc )
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)
CATCH_AND_REPORT_STD_EXCEPTION( std::bad_cast )
CATCH_AND_REPORT_STD_EXCEPTION( std::bad_typeid )
#else
CATCH_AND_REPORT_STD_EXCEPTION( std::bad_cast )
CATCH_AND_REPORT_STD_EXCEPTION( std::bad_typeid )
#endif
CATCH_AND_REPORT_STD_EXCEPTION( std::bad_exception )
CATCH_AND_REPORT_STD_EXCEPTION( std::domain_error )
CATCH_AND_REPORT_STD_EXCEPTION( std::invalid_argument )
@@ -1257,15 +1334,6 @@ execution_monitor::execute( boost::function<int ()> const& F )
CATCH_AND_REPORT_STD_EXCEPTION( std::exception )
#undef CATCH_AND_REPORT_STD_EXCEPTION
catch( boost::exception const& ex )
{ detail::report_error( execution_exception::cpp_exception_error,
&ex,
#if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI)
"unknown boost::exception" ); }
#else
typeid(ex).name() ); }
#endif
// system errors
catch( system_error const& ex )
{ detail::report_error( execution_exception::cpp_exception_error,
@@ -1342,6 +1410,12 @@ execution_exception::location::location( char const* file_name, size_t line_num,
, m_function( func )
{}
execution_exception::location::location(const_string file_name, size_t line_num, char const* func )
: m_file_name( file_name )
, m_line_num( line_num )
, m_function( func )
{}
//____________________________________________________________________________//
// ************************************************************************** //