added parenthesis around std::min and std::max for msvc compatibility

This commit is contained in:
Arvid Norberg 2007-08-16 22:14:17 +00:00
parent a3d32dad4c
commit b05500570c
8 changed files with 19 additions and 19 deletions

View File

@ -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;

View File

@ -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::string>(
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"))

View File

@ -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<std::string>(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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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(

View File

@ -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)