From 5bcd700e86a985bddfd2f49f165dfea2af9ac1e6 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Fri, 7 Dec 2012 17:55:34 +0000 Subject: [PATCH] coroutine: fix memset() typo, add Licence and Copyright [SVN r81767] --- example/asio/stream_client.cpp | 8 +-- example/asio/stream_server.cpp | 8 +-- include/boost/coroutine/coroutine.hpp | 66 +++++++------------ .../detail/stack_allocator_posix.hpp | 4 +- .../detail/stack_allocator_windows.hpp | 8 ++- 5 files changed, 31 insertions(+), 63 deletions(-) diff --git a/example/asio/stream_client.cpp b/example/asio/stream_client.cpp index 4d209cb..a20d5d3 100644 --- a/example/asio/stream_client.cpp +++ b/example/asio/stream_client.cpp @@ -1,9 +1,3 @@ - -// Copyright Oliver Kowalke 2009. -// 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 @@ -35,7 +29,7 @@ int main( int argc, char* argv[]) desc), vm); boost::program_options::notify( vm); - + if ( vm.count("help") ) { std::cout << desc << std::endl; return EXIT_SUCCESS; diff --git a/example/asio/stream_server.cpp b/example/asio/stream_server.cpp index f44b5de..bb77906 100644 --- a/example/asio/stream_server.cpp +++ b/example/asio/stream_server.cpp @@ -1,9 +1,3 @@ - -// Copyright Oliver Kowalke 2009. -// 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) - #define NOMINMAX #include @@ -38,7 +32,7 @@ private: int fetch_() { - std::streamsize num = (std::min)( + std::streamsize num = std::min( static_cast< std::streamsize >( gptr() - eback() ), pb_size); std::memmove( diff --git a/include/boost/coroutine/coroutine.hpp b/include/boost/coroutine/coroutine.hpp index 9fbcd7e..b6196ed 100644 --- a/include/boost/coroutine/coroutine.hpp +++ b/include/boost/coroutine/coroutine.hpp @@ -286,8 +286,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -324,8 +323,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, std::allocator< coroutine >, @@ -361,8 +359,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, Allocator, @@ -400,8 +397,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -438,8 +434,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, std::allocator< coroutine >, @@ -475,8 +470,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, Allocator, @@ -514,8 +508,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -552,8 +545,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, std::allocator< coroutine >, @@ -589,8 +581,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, Allocator, @@ -873,8 +864,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -912,8 +902,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -950,8 +939,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, std::allocator< coroutine >, @@ -988,8 +976,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, std::allocator< coroutine >, @@ -1025,8 +1012,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, Allocator, @@ -1062,8 +1048,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, Allocator, @@ -1101,8 +1086,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -1140,8 +1124,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -1178,8 +1161,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, std::allocator< coroutine >, @@ -1215,8 +1197,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, Allocator, @@ -1254,8 +1235,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, stack_allocator, std::allocator< coroutine >, @@ -1292,8 +1272,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, std::allocator< coroutine >, @@ -1329,8 +1308,7 @@ public: impl_() { // BOOST_STATIC_ASSERT(( -// is_same< typename result_of< Fn( caller_type &) >::type, void >::value -// )); +// is_same< void, typename result_of< Fn() >::type >::value)); typedef detail::coroutine_object< Signature, Fn, StackAllocator, Allocator, diff --git a/include/boost/coroutine/detail/stack_allocator_posix.hpp b/include/boost/coroutine/detail/stack_allocator_posix.hpp index 874ab64..f14784d 100644 --- a/include/boost/coroutine/detail/stack_allocator_posix.hpp +++ b/include/boost/coroutine/detail/stack_allocator_posix.hpp @@ -93,7 +93,7 @@ public: BOOST_ASSERT( maximum_stacksize() >= minimum_stacksize() ); return maximum_stacksize() == size ? size - : (std::min)( size, maximum_stacksize() ); + : std::min( size, maximum_stacksize() ); } static std::size_t minimum_stacksize() @@ -126,7 +126,7 @@ public: ::close( fd); if ( ! limit) throw std::bad_alloc(); - std::memset( limit, '\0', size_); + std::memset( limit, size_, '\0'); // conforming to POSIX.1-2001 const int result( ::mprotect( limit, pagesize(), PROT_NONE) ); diff --git a/include/boost/coroutine/detail/stack_allocator_windows.hpp b/include/boost/coroutine/detail/stack_allocator_windows.hpp index 3a5c7d4..20183b1 100644 --- a/include/boost/coroutine/detail/stack_allocator_windows.hpp +++ b/include/boost/coroutine/detail/stack_allocator_windows.hpp @@ -89,14 +89,16 @@ public: static std::size_t default_stacksize() { + using namespace std; + std::size_t size = 64 * 1024; // 64 kB if ( is_stack_unbound() ) - return (std::max)( size, minimum_stacksize() ); + return max( size, minimum_stacksize() ); BOOST_ASSERT( maximum_stacksize() >= minimum_stacksize() ); return maximum_stacksize() == minimum_stacksize() ? minimum_stacksize() - : (std::min)( size, maximum_stacksize() ); + : min( size, maximum_stacksize() ); } // because Windows seams not to provide a limit for minimum stacksize @@ -123,7 +125,7 @@ public: void * limit = ::VirtualAlloc( 0, size_, MEM_COMMIT, PAGE_READWRITE); if ( ! limit) throw std::bad_alloc(); - std::memset( limit, '\0', size_); + std::memset( limit, size_, '\0'); DWORD old_options; const BOOL result = ::VirtualProtect(