diff --git a/boost/binary_stream.hpp b/boost/binary_stream.hpp index 4cb063d..1f7528b 100644 --- a/boost/binary_stream.hpp +++ b/boost/binary_stream.hpp @@ -10,11 +10,15 @@ #ifndef BOOST_BINARY_STREAM_HPP #define BOOST_BINARY_STREAM_HPP +#include #include #include #include #include // for strlen -#include // for wcslen + +#ifndef BOOST_NO_CWCHAR +# include // for wcslen +#endif // unformatted binary (as opposed to formatted character-set) input and output @@ -127,8 +131,10 @@ namespace boost inline std::ostream& operator<=(std::ostream& os, const unsigned char* p) { return os.write( reinterpret_cast(p), std::strlen(reinterpret_cast(p))+1 ); } +#ifndef BOOST_NO_CWCHAR inline std::ostream& operator<=(std::ostream& os, const wchar_t* p) { return os.write( reinterpret_cast(p), (std::wcslen(p)+1)*sizeof(wchar_t) ); } +#endif // Caution: note the asymmetry between output and input; a string with embedded // nulls will be output with the embedded nulls, but input will stop at the first null. @@ -138,9 +144,11 @@ namespace boost inline std::istream& operator>=(std::istream& is, std::string& s) { return getline(is, s, '\0'); } +#ifndef BOOST_NO_STD_WSTRING inline std::ostream& operator<=(std::ostream& os, const std::wstring& s) { return os.write( reinterpret_cast(s.c_str()), (s.size()+1)*sizeof(wchar_t) ); } // TODO: provide input function +#endif } // namespace boost diff --git a/boost/integer/cover_operators.hpp b/boost/integer/cover_operators.hpp index 4b970cd..56cf3c8 100644 --- a/boost/integer/cover_operators.hpp +++ b/boost/integer/cover_operators.hpp @@ -65,16 +65,16 @@ namespace boost friend T& operator<<=(T& x, IntegerType y) { return x = +x << y; } friend T& operator>>=(T& x, IntegerType y) { return x = +x >> y; } + // A few binary arithmetic operations not covered by operators base class. + friend IntegerType operator<<(const T& x, IntegerType y) { return +x << y; } + friend IntegerType operator>>(const T& x, IntegerType y) { return +x >> y; } + // Auto-increment and auto-decrement can be defined in terms of the // arithmetic operations. friend T& operator++(T& x) { return x += 1; } friend T& operator--(T& x) { return x -= 1; } -# ifndef BOOST_MINIMAL_INTEGER_COVER_OPERATORS - // A few binary arithmetic operations not covered by operators base class. - friend IntegerType operator<<(const T& x, IntegerType y) { return +x << y; } - friend IntegerType operator>>(const T& x, IntegerType y) { return +x >> y; } - +# ifdef BOOST_MINIMAL_INTEGER_COVER_OPERATORS friend T operator++(T& x, int) { T tmp(x); diff --git a/boost/integer/endian.hpp b/boost/integer/endian.hpp index 047b217..b267b84 100644 --- a/boost/integer/endian.hpp +++ b/boost/integer/endian.hpp @@ -21,6 +21,14 @@ #ifndef BOOST_ENDIAN_HPP #define BOOST_ENDIAN_HPP +#ifdef BOOST_ENDIAN_LOG +# include +#endif + +#if defined(__BORLANDC__) || defined( __CODEGEARC__) +# pragma pack(push, 1) +#endif + #include #include #define BOOST_MINIMAL_INTEGER_COVER_OPERATORS @@ -411,4 +419,8 @@ namespace boost } // namespace integer } // namespace boost +#if defined(__BORLANDC__) || defined( __CODEGEARC__) +# pragma pack(pop) +#endif + #endif // BOOST_ENDIAN_HPP diff --git a/libs/integer/test/Jamfile.v2 b/libs/integer/test/Jamfile.v2 index f36b1a3..b5862f2 100644 --- a/libs/integer/test/Jamfile.v2 +++ b/libs/integer/test/Jamfile.v2 @@ -14,7 +14,8 @@ [ run binary_stream_test.cpp ] [ run endian_binary_stream_test.cpp ] [ run endian_test.cpp ] - [ run endian_operations_test.cpp ] + [ run endian_operations_test.cpp + : : : gcc:-Wno-sign-compare ] [ run endian_in_union_test.cpp ] [ run scoped_enum_emulation_test.cpp ] ; diff --git a/libs/integer/test/endian_operations_test.cpp b/libs/integer/test/endian_operations_test.cpp index ee513aa..2fd4329 100644 --- a/libs/integer/test/endian_operations_test.cpp +++ b/libs/integer/test/endian_operations_test.cpp @@ -46,6 +46,7 @@ struct construct { T2 o2(1); T1 o1(o2); + ++o1; // quiet gcc unused variable warning } }; @@ -56,6 +57,7 @@ struct initialize { T1 o2(2); T1 o1 = o2; + ++o1; // quiet gcc unused variable warning } }; @@ -122,6 +124,12 @@ struct op_star template class Test, class T1> void op_test_aux() { +#ifdef BOOST_SHORT_ENDIAN_TEST + Test::test(); + Test::test(); + Test::test(); + Test::test(); +#else Test::test(); Test::test(); Test::test(); @@ -181,12 +189,19 @@ void op_test_aux() Test::test(); Test::test(); Test::test(); - +#endif } template class Test> void op_test() { +#ifdef BOOST_SHORT_ENDIAN_TEST + op_test_aux(); + op_test_aux(); + op_test_aux(); + op_test_aux(); + op_test_aux(); +#else op_test_aux(); op_test_aux(); op_test_aux(); @@ -246,6 +261,7 @@ void op_test() op_test_aux(); op_test_aux(); op_test_aux(); +#endif } int main() @@ -280,7 +296,7 @@ int main() ++big; std::clog << "\nresult = big++\n"; - big++; + result = big++; std::clog << "\n--big\n"; --big; diff --git a/libs/integer/test/endian_test.cpp b/libs/integer/test/endian_test.cpp index b6c3f67..dbd6e0e 100644 --- a/libs/integer/test/endian_test.cpp +++ b/libs/integer/test/endian_test.cpp @@ -53,7 +53,7 @@ namespace { if ( actual == expected ) return; ++err_count; - cout << "Error: verify failed on line " << line << endl; + cout << "Error: verify size failed on line " << line << endl; cout << " A structure with an expected sizeof() " << expected << " had an actual sizeof() " << actual << "\n This will cause common uses of to fail\n"; @@ -149,75 +149,75 @@ namespace VERIFY( numeric_limits::digits == 7 ); VERIFY( numeric_limits::digits == 8 ); - VERIFY( sizeof( big8_t ) == 1 ); - VERIFY( sizeof( big16_t ) == 2 ); - VERIFY( sizeof( big24_t ) == 3 ); - VERIFY( sizeof( big32_t ) == 4 ); - VERIFY( sizeof( big40_t ) == 5 ); - VERIFY( sizeof( big48_t ) == 6 ); - VERIFY( sizeof( big56_t ) == 7 ); - VERIFY( sizeof( big64_t ) == 8 ); + VERIFY_SIZE( sizeof( big8_t ), 1 ); + VERIFY_SIZE( sizeof( big16_t ), 2 ); + VERIFY_SIZE( sizeof( big24_t ), 3 ); + VERIFY_SIZE( sizeof( big32_t ), 4 ); + VERIFY_SIZE( sizeof( big40_t ), 5 ); + VERIFY_SIZE( sizeof( big48_t ), 6 ); + VERIFY_SIZE( sizeof( big56_t ), 7 ); + VERIFY_SIZE( sizeof( big64_t ), 8 ); - VERIFY( sizeof( ubig8_t ) == 1 ); - VERIFY( sizeof( ubig16_t ) == 2 ); - VERIFY( sizeof( ubig24_t ) == 3 ); - VERIFY( sizeof( ubig32_t ) == 4 ); - VERIFY( sizeof( ubig40_t ) == 5 ); - VERIFY( sizeof( ubig48_t ) == 6 ); - VERIFY( sizeof( ubig56_t ) == 7 ); - VERIFY( sizeof( ubig64_t ) == 8 ); + VERIFY_SIZE( sizeof( ubig8_t ), 1 ); + VERIFY_SIZE( sizeof( ubig16_t ), 2 ); + VERIFY_SIZE( sizeof( ubig24_t ), 3 ); + VERIFY_SIZE( sizeof( ubig32_t ), 4 ); + VERIFY_SIZE( sizeof( ubig40_t ), 5 ); + VERIFY_SIZE( sizeof( ubig48_t ), 6 ); + VERIFY_SIZE( sizeof( ubig56_t ), 7 ); + VERIFY_SIZE( sizeof( ubig64_t ), 8 ); - VERIFY( sizeof( little8_t ) == 1 ); - VERIFY( sizeof( little16_t ) == 2 ); - VERIFY( sizeof( little24_t ) == 3 ); - VERIFY( sizeof( little32_t ) == 4 ); - VERIFY( sizeof( little40_t ) == 5 ); - VERIFY( sizeof( little48_t ) == 6 ); - VERIFY( sizeof( little56_t ) == 7 ); - VERIFY( sizeof( little64_t ) == 8 ); + VERIFY_SIZE( sizeof( little8_t ), 1 ); + VERIFY_SIZE( sizeof( little16_t ), 2 ); + VERIFY_SIZE( sizeof( little24_t ), 3 ); + VERIFY_SIZE( sizeof( little32_t ), 4 ); + VERIFY_SIZE( sizeof( little40_t ), 5 ); + VERIFY_SIZE( sizeof( little48_t ), 6 ); + VERIFY_SIZE( sizeof( little56_t ), 7 ); + VERIFY_SIZE( sizeof( little64_t ), 8 ); - VERIFY( sizeof( ulittle8_t ) == 1 ); - VERIFY( sizeof( ulittle16_t ) == 2 ); - VERIFY( sizeof( ulittle24_t ) == 3 ); - VERIFY( sizeof( ulittle32_t ) == 4 ); - VERIFY( sizeof( ulittle40_t ) == 5 ); - VERIFY( sizeof( ulittle48_t ) == 6 ); - VERIFY( sizeof( ulittle56_t ) == 7 ); - VERIFY( sizeof( ulittle64_t ) == 8 ); + VERIFY_SIZE( sizeof( ulittle8_t ), 1 ); + VERIFY_SIZE( sizeof( ulittle16_t ), 2 ); + VERIFY_SIZE( sizeof( ulittle24_t ), 3 ); + VERIFY_SIZE( sizeof( ulittle32_t ), 4 ); + VERIFY_SIZE( sizeof( ulittle40_t ), 5 ); + VERIFY_SIZE( sizeof( ulittle48_t ), 6 ); + VERIFY_SIZE( sizeof( ulittle56_t ), 7 ); + VERIFY_SIZE( sizeof( ulittle64_t ), 8 ); - VERIFY( sizeof( native8_t ) == 1 ); - VERIFY( sizeof( native16_t ) == 2 ); - VERIFY( sizeof( native24_t ) == 3 ); - VERIFY( sizeof( native32_t ) == 4 ); - VERIFY( sizeof( native40_t ) == 5 ); - VERIFY( sizeof( native48_t ) == 6 ); - VERIFY( sizeof( native56_t ) == 7 ); - VERIFY( sizeof( native64_t ) == 8 ); + VERIFY_SIZE( sizeof( native8_t ), 1 ); + VERIFY_SIZE( sizeof( native16_t ), 2 ); + VERIFY_SIZE( sizeof( native24_t ), 3 ); + VERIFY_SIZE( sizeof( native32_t ), 4 ); + VERIFY_SIZE( sizeof( native40_t ), 5 ); + VERIFY_SIZE( sizeof( native48_t ), 6 ); + VERIFY_SIZE( sizeof( native56_t ), 7 ); + VERIFY_SIZE( sizeof( native64_t ), 8 ); - VERIFY( sizeof( unative8_t ) == 1 ); - VERIFY( sizeof( unative16_t ) == 2 ); - VERIFY( sizeof( unative24_t ) == 3 ); - VERIFY( sizeof( unative32_t ) == 4 ); - VERIFY( sizeof( unative40_t ) == 5 ); - VERIFY( sizeof( unative48_t ) == 6 ); - VERIFY( sizeof( unative56_t ) == 7 ); - VERIFY( sizeof( unative64_t ) == 8 ); + VERIFY_SIZE( sizeof( unative8_t ), 1 ); + VERIFY_SIZE( sizeof( unative16_t ), 2 ); + VERIFY_SIZE( sizeof( unative24_t ), 3 ); + VERIFY_SIZE( sizeof( unative32_t ), 4 ); + VERIFY_SIZE( sizeof( unative40_t ), 5 ); + VERIFY_SIZE( sizeof( unative48_t ), 6 ); + VERIFY_SIZE( sizeof( unative56_t ), 7 ); + VERIFY_SIZE( sizeof( unative64_t ), 8 ); - VERIFY( sizeof( aligned_big16_t ) == 2 ); - VERIFY( sizeof( aligned_big32_t ) == 4 ); - VERIFY( sizeof( aligned_big64_t ) == 8 ); + VERIFY_SIZE( sizeof( aligned_big16_t ), 2 ); + VERIFY_SIZE( sizeof( aligned_big32_t ), 4 ); + VERIFY_SIZE( sizeof( aligned_big64_t ), 8 ); - VERIFY( sizeof( aligned_ubig16_t ) == 2 ); - VERIFY( sizeof( aligned_ubig32_t ) == 4 ); - VERIFY( sizeof( aligned_ubig64_t ) == 8 ); + VERIFY_SIZE( sizeof( aligned_ubig16_t ), 2 ); + VERIFY_SIZE( sizeof( aligned_ubig32_t ), 4 ); + VERIFY_SIZE( sizeof( aligned_ubig64_t ), 8 ); - VERIFY( sizeof( aligned_little16_t ) == 2 ); - VERIFY( sizeof( aligned_little32_t ) == 4 ); - VERIFY( sizeof( aligned_little64_t ) == 8 ); + VERIFY_SIZE( sizeof( aligned_little16_t ), 2 ); + VERIFY_SIZE( sizeof( aligned_little32_t ), 4 ); + VERIFY_SIZE( sizeof( aligned_little64_t ), 8 ); - VERIFY( sizeof( aligned_ulittle16_t ) == 2 ); - VERIFY( sizeof( aligned_ulittle32_t ) == 4 ); - VERIFY( sizeof( aligned_ulittle64_t ) == 8 ); + VERIFY_SIZE( sizeof( aligned_ulittle16_t ), 2 ); + VERIFY_SIZE( sizeof( aligned_ulittle32_t ), 4 ); + VERIFY_SIZE( sizeof( aligned_ulittle64_t ), 8 ); } // check_size // check_alignment -------------------------------------------------------//