diff --git a/ww/eventloop/event/hevent.c b/ww/eventloop/event/hevent.c index 49d7d11..b22641c 100644 --- a/ww/eventloop/event/hevent.c +++ b/ww/eventloop/event/hevent.c @@ -480,7 +480,7 @@ void hio_set_write_timeout(hio_t* io, int timeout_ms) { static void __keepalive_timeout_cb(htimer_t* timer) { hio_t* io = (hio_t*)timer->privdata; - uint64_t last_rw_hrtime = MAX(io->last_read_hrtime, io->last_write_hrtime); + uint64_t last_rw_hrtime = max(io->last_read_hrtime, io->last_write_hrtime); uint64_t inactive_ms = (io->loop->cur_hrtime - last_rw_hrtime) / 1000; if (inactive_ms + 100 < (uint64_t)io->keepalive_timeout) { htimer_reset(io->keepalive_timer, io->keepalive_timeout - inactive_ms); diff --git a/ww/eventloop/event/hloop.c b/ww/eventloop/event/hloop.c index c6f7529..3ee62e7 100644 --- a/ww/eventloop/event/hloop.c +++ b/ww/eventloop/event/hloop.c @@ -148,15 +148,15 @@ int hloop_process_events(hloop_t* loop, int timeout_ms) { int64_t blocktime_us = blocktime_ms * 1000; if (loop->timers.root) { int64_t min_timeout = TIMER_ENTRY(loop->timers.root)->next_timeout - loop->cur_hrtime; - blocktime_us = MIN(blocktime_us, min_timeout); + blocktime_us = min(blocktime_us, min_timeout); } if (loop->realtimers.root) { int64_t min_timeout = TIMER_ENTRY(loop->realtimers.root)->next_timeout - hloop_now_us(loop); - blocktime_us = MIN(blocktime_us, min_timeout); + blocktime_us = min(blocktime_us, min_timeout); } if (blocktime_us < 0) goto process_timers; blocktime_ms = blocktime_us / 1000 + 1; - blocktime_ms = MIN(blocktime_ms, timeout_ms); + blocktime_ms = min(blocktime_ms, timeout_ms); } if (loop->nios) { @@ -717,7 +717,7 @@ const char* hio_engine(void) { static inline hio_t* __hio_get(hloop_t* loop, int fd) { if (fd >= (int)loop->ios.maxsize) { int newsize = ceil2e(fd); - newsize = MAX(newsize, IO_ARRAY_INIT_SIZE); + newsize = max(newsize, IO_ARRAY_INIT_SIZE); io_array_resize(&loop->ios, newsize > fd ? newsize : 2 * fd); } return loop->ios.ptr[fd]; diff --git a/ww/eventloop/event/hloop.h b/ww/eventloop/event/hloop.h index 4e8b440..47e3536 100644 --- a/ww/eventloop/event/hloop.h +++ b/ww/eventloop/event/hloop.h @@ -4,6 +4,7 @@ #include "hexport.h" #include "hplatform.h" #include "hdef.h" +#include "utils/mathutils.h" #include "buffer_pool.h" typedef struct hloop_s hloop_t; @@ -471,8 +472,8 @@ HV_INLINE uint32_t reconn_setting_calc_delay(reconn_setting_t* reconn) { // exponential reconn->cur_delay *= reconn->delay_policy; } - reconn->cur_delay = MAX(reconn->cur_delay, reconn->min_delay); - reconn->cur_delay = MIN(reconn->cur_delay, reconn->max_delay); + reconn->cur_delay = max(reconn->cur_delay, reconn->min_delay); + reconn->cur_delay = min(reconn->cur_delay, reconn->max_delay); return reconn->cur_delay; }