[Test] Patch to fix problems with VC8-Windows CE

Attached is a small patch for execution_monitor.ipp to fix Windows CE-related problems in the new test library code. The changes are mostly just a few #ifdef blocks to account for the following: - The Windows CE CRT does not support _set_se_translator or _set_invalid_parameter_handler. - The Windows CE CRT supplies _vsnprintf instead of vsnprintf. - The Windows CE CRT does not support errno. Thanks, -Dave Index: execution_monitor.ipp =================================================================== --- execution_monitor.ipp (revision 40282) +++ execution_monitor.ipp (working copy) @@ -141,7 +141,9 @@ #endif +#ifndef UNDER_CE #include <errno.h> +#endif #include <boost/test/detail/suppress_warnings.hpp> @@ -158,7 +160,8 @@ #ifdef __BORLANDC__ # 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)) + BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3000)) || \ + defined(UNDER_CE) # 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) ) @@ -905,6 +908,8 @@ //____________________________________________________________________________// +#ifndef UNDER_CE + void BOOST_TEST_CALL_DECL invalid_param_handler( wchar_t const* /* expr */, wchar_t const* /* func */, @@ -916,6 +921,8 @@ "Invalid parameter detected by C runtime library" ); } +#endif + //____________________________________________________________________________// void BOOST_TEST_CALL_DECL @@ -951,11 +958,14 @@ int execution_monitor::catch_signals( unit_test::callback0<int> const& F ) { +#ifndef UNDER_CE _invalid_parameter_handler old_iph; if( !p_catch_system_errors ) _set_se_translator( &detail::system_signal_exception::seh_catch_preventer ); - else { + else +#endif + { if( !!p_detect_fp_exceptions ) detail::switch_fp_exceptions( true ); @@ -963,15 +973,19 @@ _CrtSetReportHook( &detail::assert_reporting_function ); #endif +#ifndef UNDER_CE old_iph = _set_invalid_parameter_handler( reinterpret_cast<_invalid_parameter_handler>( &detail::invalid_param_handler ) ); +#endif } detail::system_signal_exception SSE( this ); + + int ret_val = 0; __try { __try { - return detail::do_invoke( m_custom_translators , F ); + ret_val = detail::do_invoke( m_custom_translators , F ); } __except( SSE( GetExceptionCode(), GetExceptionInformation() ) ) { throw SSE; @@ -982,11 +996,13 @@ if( !!p_detect_fp_exceptions ) detail::switch_fp_exceptions( false ); +#ifndef UNDER_CE _set_invalid_parameter_handler( old_iph ); +#endif } } - return 0; + return ret_val; } //____________________________________________________________________________// @@ -1093,10 +1109,20 @@ // ************** system_error ************** // // ************************************************************************** // +#ifdef UNDER_CE + system_error::system_error() +: p_errno( 0 ) +{} + +#else + +system_error::system_error() : p_errno( errno ) {} +#endif + //____________________________________________________________________________// } // namespace boost

"David Deakins" <ddeakins@veeco.com> wrote in message news:ffltb5$hdk$1@ger.gmane.org...
Attached is a small patch for execution_monitor.ipp to fix Windows CE-related problems in the new test library code. The changes are mostly just a few #ifdef blocks to account for the following:
- The Windows CE CRT does not support _set_se_translator or _set_invalid_parameter_handler.
There already workarounds in place for different compilers for missing symbols above. Can you try to fit in with additional conditions instead of extra ifdefs inside the code
- The Windows CE CRT supplies _vsnprintf instead of vsnprintf.
This one applied
- The Windows CE CRT does not support errno.
What does it support instead? Gennadiy

Gennadiy Rozental wrote:
"David Deakins" <ddeakins@veeco.com> wrote in message
- The Windows CE CRT does not support _set_se_translator or _set_invalid_parameter_handler.
There already workarounds in place for different compilers for missing symbols above. Can you try to fit in with additional conditions instead of extra ifdefs inside the code
My apologies for not studying the code more carefully. I have attached a new version of the patch following the existing method for handling these missing symbols.
- The Windows CE CRT supplies _vsnprintf instead of vsnprintf.
This one applied
- The Windows CE CRT does not support errno.
What does it support instead?
It only provides the Win32 GetLastError() method for this functionality. I have revised the patch to reflect this. Thanks, -Dave Index: execution_monitor.ipp =================================================================== --- execution_monitor.ipp (revision 40282) +++ execution_monitor.ipp (working copy) @@ -65,7 +65,7 @@ # include <stdint.h> #endif -# if BOOST_WORKAROUND(BOOST_MSVC, < 1300 ) +# if BOOST_WORKAROUND(BOOST_MSVC, < 1300 ) || defined(UNDER_CE) typedef void* uintptr_t; # endif @@ -101,7 +101,7 @@ # include <crtdbg.h> # endif -# if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) +# if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) || defined(UNDER_CE) typedef void* _invalid_parameter_handler; @@ -113,7 +113,7 @@ # endif -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) +# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) || defined(UNDER_CE) namespace { void _set_se_translator( void* ) {} } @@ -141,7 +141,9 @@ #endif +#ifndef UNDER_CE #include <errno.h> +#endif #include <boost/test/detail/suppress_warnings.hpp> @@ -158,7 +160,8 @@ #ifdef __BORLANDC__ # 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)) + BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3000)) || \ + defined(UNDER_CE) # 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) ) @@ -968,10 +971,12 @@ } detail::system_signal_exception SSE( this ); + + int ret_val = 0; __try { __try { - return detail::do_invoke( m_custom_translators , F ); + ret_val = detail::do_invoke( m_custom_translators , F ); } __except( SSE( GetExceptionCode(), GetExceptionInformation() ) ) { throw SSE; @@ -986,7 +991,7 @@ } } - return 0; + return ret_val; } //____________________________________________________________________________// @@ -1094,9 +1099,14 @@ // ************************************************************************** // system_error::system_error() +#ifdef UNDER_CE +: p_errno( GetLastError() ) +#else : p_errno( errno ) +#endif {} + //____________________________________________________________________________// } // namespace boost

David Deakins wrote:
I have attached a new version of the patch following the existing method for handling these missing symbols.
Apparently, Windows CE also does not have support for _CrtSetReportHook. I have amended the patch one more time to include a fix for this. Thanks, -Dave Index: execution_monitor.ipp =================================================================== --- execution_monitor.ipp (revision 40426) +++ execution_monitor.ipp (working copy) @@ -65,7 +65,7 @@ # include <stdint.h> #endif -# if BOOST_WORKAROUND(_MSC_VER, < 1300 ) +# if BOOST_WORKAROUND(_MSC_VER, < 1300 ) || defined(UNDER_CE) typedef void* uintptr_t; # endif @@ -96,12 +96,12 @@ #define MCW_EM _MCW_EM #endif -# if !defined(NDEBUG) && defined(_MSC_VER) +# if !defined(NDEBUG) && defined(_MSC_VER) && !defined(UNDER_CE) # define BOOST_TEST_USE_DEBUG_MS_CRT # include <crtdbg.h> # endif -# if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) +# if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) || defined(UNDER_CE) typedef void* _invalid_parameter_handler; @@ -113,7 +113,7 @@ # endif -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) +# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) || defined(UNDER_CE) namespace { void _set_se_translator( void* ) {} } @@ -145,7 +145,9 @@ #endif +#ifndef UNDER_CE #include <errno.h> +#endif #include <boost/test/detail/suppress_warnings.hpp> @@ -977,10 +979,12 @@ } detail::system_signal_exception SSE( this ); + + int ret_val = 0; __try { __try { - return detail::do_invoke( m_custom_translators , F ); + ret_val = detail::do_invoke( m_custom_translators , F ); } __except( SSE( GetExceptionCode(), GetExceptionInformation() ) ) { throw SSE; @@ -995,7 +999,7 @@ } } - return 0; + return ret_val; } //____________________________________________________________________________// @@ -1103,9 +1107,14 @@ // ************************************************************************** // system_error::system_error() +#ifdef UNDER_CE +: p_errno( GetLastError() ) +#else : p_errno( errno ) +#endif {} + //____________________________________________________________________________// } // namespace boost

Attached is a patch for the new debug.ipp functionality to disable it for Windows CE. -Dave Index: debug.ipp =================================================================== --- debug.ipp (revision 40463) +++ debug.ipp (working copy) @@ -24,7 +24,7 @@ #include <boost/test/debug_config.hpp> // Implementation in windows -#if defined(_WIN32) && !defined(BOOST_DISABLE_WIN32) // ******* WIN32 +#if defined(_WIN32) && !defined(BOOST_DISABLE_WIN32) && !defined(UNDER_CE) // ******* WIN32 # define BOOST_WIN32_BASED_DEBUG

Hi Gennadiy, If you have a chance, can you please apply the attached debug.ipp patch for WinCE? Because Windows CE does not have most of the ANSI versions of the Win32 functions or structures (only the wide-character versions), some of the code in debug.ipp fails to compile. This causes all the regression tests for almost all libraries to fail. Since automatic support for the debugger probably would not work as intended on a WinCE device anyway, the attached patch disables debugger support on Windows CE builds. Thanks, -Dave Index: debug.ipp =================================================================== --- debug.ipp (revision 40610) +++ debug.ipp (working copy) @@ -24,7 +24,7 @@ #include <boost/test/debug_config.hpp> // Implementation in windows -#if defined(_WIN32) && !defined(BOOST_DISABLE_WIN32) // ******* WIN32 +#if defined(_WIN32) && !defined(UNDER_CE) && !defined(BOOST_DISABLE_WIN32) // ******* WIN32 # define BOOST_WIN32_BASED_DEBUG

"David Deakins" <ddeakins@veeco.com> wrote in message news:fg7v3l$aqk$1@ger.gmane.org...
Hi Gennadiy,
If you have a chance, can you please apply the attached debug.ipp patch for WinCE? Because Windows CE does not have most of the ANSI versions of the Win32 functions or structures (only the wide-character versions), some of the code in debug.ipp fails to compile. This causes all the regression tests for almost all libraries to fail. Since automatic support for the debugger probably would not work as intended on a WinCE device anyway, the attached patch disables debugger support on Windows CE builds.
I've applied the patch, but can you figure out how to make these facilities to work on CE? Gennadiy
participants (2)
-
David Deakins
-
Gennadiy Rozental