From b05500570c36cf0ca720e5bc720d0fa7b2e4b450 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 16 Aug 2007 22:14:17 +0000 Subject: [PATCH] added parenthesis around std::min and std::max for msvc compatibility --- src/bt_peer_connection.cpp | 6 +++--- src/http_tracker_connection.cpp | 4 ++-- src/session_impl.cpp | 4 ++-- src/storage.cpp | 2 +- src/torrent.cpp | 6 +++--- src/torrent_handle.cpp | 4 ++-- src/tracker_manager.cpp | 6 +++--- src/web_peer_connection.cpp | 6 +++--- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 07ebf5431..2a4347778 100755 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -1369,7 +1369,7 @@ namespace libtorrent assert(t->is_seed() == (std::count(bitfield.begin(), bitfield.end(), true) == num_pieces)); if (t->is_seed() && m_ses.settings().lazy_bitfields) { - num_lazy_pieces = std::min(50, num_pieces / 10); + num_lazy_pieces = (std::min)(50, num_pieces / 10); if (num_lazy_pieces < 1) num_lazy_pieces = 1; for (int i = 0; i < num_pieces; ++i) { @@ -1735,7 +1735,7 @@ namespace libtorrent if (m_sync_bytes_read >= 512) throw protocol_error("sync hash not found within 532 bytes"); - cut_receive_buffer(bytes_processed, std::min(packet_size(), (512+20) - m_sync_bytes_read)); + cut_receive_buffer(bytes_processed, (std::min)(packet_size(), (512+20) - m_sync_bytes_read)); assert(!packet_finished()); return; @@ -1873,7 +1873,7 @@ namespace libtorrent if (m_sync_bytes_read >= 512) throw protocol_error("sync verification constant not found within 520 bytes"); - cut_receive_buffer(bytes_processed, std::min(packet_size(), (512+8) - m_sync_bytes_read)); + cut_receive_buffer(bytes_processed, (std::min)(packet_size(), (512+8) - m_sync_bytes_read)); assert(!packet_finished()); return; diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 936f8292a..8af09e6a6 100755 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -250,7 +250,7 @@ namespace libtorrent assert(m_state == read_body); if (m_content_length >= 0) return buffer::const_interval(m_recv_buffer.begin + m_body_start_pos - , m_recv_buffer.begin + std::min(m_recv_pos + , m_recv_buffer.begin + (std::min)(m_recv_pos , m_body_start_pos + m_content_length)); else return buffer::const_interval(m_recv_buffer.begin + m_body_start_pos @@ -408,7 +408,7 @@ namespace libtorrent { m_send_buffer += "numwant="; m_send_buffer += boost::lexical_cast( - std::min(req.num_want, 999)); + (std::min)(req.num_want, 999)); m_send_buffer += '&'; } if (m_settings.announce_ip != address() && !url_has_argument(request, "ip")) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 694e5f49d..8c978a754 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2220,7 +2220,7 @@ namespace detail const std::string& bitmask = (*i)["bitmask"].string(); - const int num_bitmask_bytes = std::max(num_blocks_per_piece / 8, 1); + const int num_bitmask_bytes = (std::max)(num_blocks_per_piece / 8, 1); if ((int)bitmask.size() != num_bitmask_bytes) { error = "invalid size of bitmask (" + boost::lexical_cast(bitmask.size()) + ")"; @@ -2229,7 +2229,7 @@ namespace detail for (int j = 0; j < num_bitmask_bytes; ++j) { unsigned char bits = bitmask[j]; - int num_bits = std::min(num_blocks_per_piece - j*8, 8); + int num_bits = (std::min)(num_blocks_per_piece - j*8, 8); for (int k = 0; k < num_bits; ++k) { const int bit = j * 8 + k; diff --git a/src/storage.cpp b/src/storage.cpp index b23a2e858..8d738c669 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -2096,7 +2096,7 @@ namespace libtorrent , offset += stack_buffer_size) { m_storage->write(zeroes, pos, offset - , std::min(piece_size, stack_buffer_size)); + , (std::min)(piece_size, stack_buffer_size)); } written = true; } diff --git a/src/torrent.cpp b/src/torrent.cpp index f26563503..9995f742e 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2126,7 +2126,7 @@ namespace libtorrent if ((unsigned)m_currently_trying_tracker >= m_trackers.size()) { int delay = tracker_retry_delay_min - + std::min(m_failed_trackers, (int)tracker_failed_max) + + (std::min)(m_failed_trackers, (int)tracker_failed_max) * (tracker_retry_delay_max - tracker_retry_delay_min) / tracker_failed_max; @@ -2691,7 +2691,7 @@ namespace libtorrent size_type done = 0; while (size > 0) { - size_type bytes_step = std::min(m_torrent_file.piece_size(ret.piece) + size_type bytes_step = (std::min)(m_torrent_file.piece_size(ret.piece) - ret.start, size); if (m_have_pieces[ret.piece]) done += bytes_step; ++ret.piece; @@ -2775,7 +2775,7 @@ namespace libtorrent // TODO: add a progress member to the torrent that will be used in this case // and that may be set by a plugin // if (m_metadata_size == 0) st.progress = 0.f; -// else st.progress = std::min(1.f, m_metadata_progress / (float)m_metadata_size); +// else st.progress = (std::min)(1.f, m_metadata_progress / (float)m_metadata_size); st.progress = 0.f; st.block_size = 0; diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 4538e66e8..e0e9f29e6 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -561,12 +561,12 @@ namespace libtorrent std::string bitmask; const int num_bitmask_bytes - = std::max(num_blocks_per_piece / 8, 1); + = (std::max)(num_blocks_per_piece / 8, 1); for (int j = 0; j < num_bitmask_bytes; ++j) { unsigned char v = 0; - int bits = std::min(num_blocks_per_piece - j*8, 8); + int bits = (std::min)(num_blocks_per_piece - j*8, 8); for (int k = 0; k < bits; ++k) v |= (i->info[j*8+k].state == piece_picker::block_info::state_finished) ? (1 << k) : 0; diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index 7bd511588..358ac3838 100755 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -256,7 +256,7 @@ namespace libtorrent { // available input is 1,2 or 3 bytes // since we read 3 bytes at a time at most - int available_input = std::min(3, (int)std::distance(i, s.end())); + int available_input = (std::min)(3, (int)std::distance(i, s.end())); // clear input buffer std::fill(inbuf, inbuf+3, 0); @@ -305,7 +305,7 @@ namespace libtorrent m_start_time = time_now(); m_read_time = time_now(); - m_timeout.expires_at(std::min( + m_timeout.expires_at((std::min)( m_read_time + seconds(m_read_timeout) , m_start_time + seconds(m_completion_timeout))); m_timeout.async_wait(m_strand.wrap(bind( @@ -341,7 +341,7 @@ namespace libtorrent return; } - m_timeout.expires_at(std::min( + m_timeout.expires_at((std::min)( m_read_time + seconds(m_read_timeout) , m_start_time + seconds(m_completion_timeout))); m_timeout.async_wait(m_strand.wrap( diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index 6c6745f30..efd9633e7 100755 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -180,7 +180,7 @@ namespace libtorrent const int block_size = t->block_size(); while (size > 0) { - int request_size = std::min(block_size, size); + int request_size = (std::min)(block_size, size); peer_request pr = {r.piece, r.start + r.length - size , request_size}; m_requests.push_back(pr); @@ -510,7 +510,7 @@ namespace libtorrent // m_piece as buffer. int piece_size = int(m_piece.size()); - int copy_size = std::min(std::min(front_request.length - piece_size + int copy_size = (std::min)(std::min(front_request.length - piece_size , recv_buffer.left()), int(range_end - range_start - m_received_body)); m_piece.resize(piece_size + copy_size); assert(copy_size > 0); @@ -568,7 +568,7 @@ namespace libtorrent && (m_received_body + recv_buffer.left() >= range_end - range_start)) { int piece_size = int(m_piece.size()); - int copy_size = std::min(std::min(m_requests.front().length - piece_size + int copy_size = (std::min)(std::min(m_requests.front().length - piece_size , recv_buffer.left()), int(range_end - range_start - m_received_body)); assert(copy_size >= 0); if (copy_size > 0)