Skip to content

Commit

Permalink
Put std::min and std::max in parenthesis to avoid clashing with min/m…
Browse files Browse the repository at this point in the history
…ax in windows.h
  • Loading branch information
anujkaliaiitd committed Sep 10, 2021
1 parent 448bf24 commit ca10412
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/cc/timely.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Timely {
((1 - kEwmaAlpha) * avg_rtt_diff_) + (kEwmaAlpha * rtt_diff);

double delta_factor = (_rdtsc - last_update_tsc_) / min_rtt_tsc_; // fdiv
delta_factor = std::min(delta_factor, 1.0);
delta_factor = (std::min)(delta_factor, 1.0);

double ai_factor = kAddRate * delta_factor;

Expand Down Expand Up @@ -157,9 +157,9 @@ class Timely {
}
}

rate_ = std::max(new_rate, rate_ * 0.5);
rate_ = std::min(rate_, link_bandwidth_);
rate_ = std::max(rate_, double(kMinRate));
rate_ = (std::max)(new_rate, rate_ * 0.5);
rate_ = (std::min)(rate_, link_bandwidth_);
rate_ = (std::max)(rate_, double(kMinRate));

prev_rtt_ = sample_rtt;
last_update_tsc_ = _rdtsc;
Expand Down
2 changes: 1 addition & 1 deletion src/msg_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MsgBuffer {
template <size_t kMaxDataPerPkt>
inline size_t get_pkt_size(size_t pkt_idx) const {
size_t offset = pkt_idx * kMaxDataPerPkt;
return sizeof(pkthdr_t) + std::min(kMaxDataPerPkt, data_size_ - offset);
return sizeof(pkthdr_t) + (std::min)(kMaxDataPerPkt, data_size_ - offset);
}

/// Return a string representation of this MsgBuffer
Expand Down
3 changes: 2 additions & 1 deletion src/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,8 @@ class Rpc {
static inline void copy_data_to_msgbuf(MsgBuffer *msgbuf, size_t pkt_idx,
const pkthdr_t *pkthdr) {
size_t offset = pkt_idx * TTr::kMaxDataPerPkt;
size_t to_copy = std::min(TTr::kMaxDataPerPkt, pkthdr->msg_size_ - offset);
size_t to_copy =
(std::min)(TTr::kMaxDataPerPkt, pkthdr->msg_size_ - offset);
memcpy(&msgbuf->buf_[offset], pkthdr + 1, to_copy); // From end of pkthdr
}

Expand Down
5 changes: 3 additions & 2 deletions src/rpc_impl/rpc_kick.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ void Rpc<TTr>::kick_req_st(SSlot *sslot) {
assert(credits > 0); // Precondition

auto &ci = sslot->client_info_;
size_t sending = std::min(credits, sslot->tx_msgbuf_->num_pkts_ - ci.num_tx_);
size_t sending =
(std::min)(credits, sslot->tx_msgbuf_->num_pkts_ - ci.num_tx_);
bool bypass = can_bypass_wheel(sslot);

for (size_t x = 0; x < sending; x++) {
Expand Down Expand Up @@ -40,7 +41,7 @@ void Rpc<TTr>::kick_rfr_st(SSlot *sslot) {

// TODO: Pace RFRs
size_t rfr_pndng = wire_pkts(sslot->tx_msgbuf_, ci.resp_msgbuf_) - ci.num_tx_;
size_t sending = std::min(credits, rfr_pndng); // > 0
size_t sending = (std::min)(credits, rfr_pndng); // > 0
for (size_t x = 0; x < sending; x++) {
enqueue_rfr_st(sslot, ci.resp_msgbuf_->get_pkthdr_0());
ci.num_tx_++;
Expand Down
2 changes: 1 addition & 1 deletion src/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Session {
double cycle_delta = ns_to_cycles(ns_delta, freq_ghz_);

size_t desired_tx_tsc = client_info_.cc_.prev_desired_tx_tsc_ + cycle_delta;
desired_tx_tsc = std::max(desired_tx_tsc, ref_tsc);
desired_tx_tsc = (std::max)(desired_tx_tsc, ref_tsc);

client_info_.cc_.prev_desired_tx_tsc_ = desired_tx_tsc;

Expand Down
3 changes: 2 additions & 1 deletion src/transport_impl/infiniband/ib_transport_datapath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void IBTransport::tx_burst(const tx_burst_item_t* tx_burst_arr,

size_t offset = item.pkt_idx_ * kMaxDataPerPkt;
sgl[1].addr = reinterpret_cast<uint64_t>(&msg_buffer->buf_[offset]);
sgl[1].length = std::min(kMaxDataPerPkt, msg_buffer->data_size_ - offset);
sgl[1].length =
(std::min)(kMaxDataPerPkt, msg_buffer->data_size_ - offset);
sgl[1].lkey = msg_buffer->buffer_.lkey_;

wr.num_sge = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/transport_impl/raw/raw_transport_datapath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void RawTransport::tx_burst(const tx_burst_item_t* tx_burst_arr,

size_t offset = item.pkt_idx * kMaxDataPerPkt;
sgl[1].addr = reinterpret_cast<uint64_t>(&msg_buffer->buf[offset]);
sgl[1].length = std::min(kMaxDataPerPkt, msg_buffer->data_size - offset);
sgl[1].length = (std::min)(kMaxDataPerPkt, msg_buffer->data_size - offset);
sgl[1].lkey = msg_buffer->buffer.lkey;

pkt_size = sgl[0].length + sgl[1].length;
Expand Down
2 changes: 1 addition & 1 deletion src/util/latency.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Latency {
/// Return the (approximate) average sample
double avg() const {
return static_cast<double>(sum()) /
static_cast<double>(std::max(size_t(1), count()));
static_cast<double>((std::max)(size_t(1), count()));
}

/// Return the (approximate) minimum sample
Expand Down

0 comments on commit ca10412

Please sign in to comment.