[system] - patch for problems with strerror_r on LINUX/HPUX

Hi, LINUX and HP/UX have different strerror_r functions. At least for me the moduification works. regards, Oliver std::string errno_md( const error_code & ec ) { # if !defined(BOOST_WINDOWS_API) // does not have strerror_t #if defined(__linux) char buf[64]; char * bp = buf; std::size_t sz = sizeof(buf); return strerror_r( ec.value(), bp, sz); #elif defined(__hpux) return strerror( ec.value() ); #else char buf[64]; char * bp = buf; std::size_t sz = sizeof(buf); int result; while ( (result = strerror_r( ec.value(), bp, sz )) == ERANGE ) { if ( sz > sizeof(buf) ) std::free( bp ); sz *= 2; if ( (bp = static_cast<char*>(std::malloc( sz ))) == 0 ) return std::string( "ENOMEM" ); } std::string msg( ( result == EINVAL ) ? "EINVAL" : bp ); if ( sz > sizeof(buf) ) std::free( bp ); return msg; # endif # else const char * c_str = std::strerror( ec.value() ); return std::string( c_str ? c_str : "EINVAL" ); # endif }

Oliver.Kowalke@qimonda.com wrote:
Hi, LINUX and HP/UX have different strerror_r functions. At least for me the moduification works.
OK, I'm just now starting to apply backed up patches and fixes. It will take several days to get them integrated and tested. Thanks, --Beman
regards, Oliver
std::string errno_md( const error_code & ec ) { # if !defined(BOOST_WINDOWS_API) // does not have strerror_t #if defined(__linux) char buf[64]; char * bp = buf; std::size_t sz = sizeof(buf); return strerror_r( ec.value(), bp, sz); #elif defined(__hpux) return strerror( ec.value() ); #else char buf[64]; char * bp = buf; std::size_t sz = sizeof(buf); int result; while ( (result = strerror_r( ec.value(), bp, sz )) == ERANGE ) { if ( sz > sizeof(buf) ) std::free( bp ); sz *= 2; if ( (bp = static_cast<char*>(std::malloc( sz ))) == 0 ) return std::string( "ENOMEM" ); } std::string msg( ( result == EINVAL ) ? "EINVAL" : bp ); if ( sz > sizeof(buf) ) std::free( bp ); return msg; # endif # else const char * c_str = std::strerror( ec.value() ); return std::string( c_str ? c_str : "EINVAL" ); # endif } _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Beman Dawes
-
Oliver.Kowalke@qimonda.com