Skip to content

Commit

Permalink
win: fix visual studio 2008 build
Browse files Browse the repository at this point in the history
Fixes: libuv#2861
PR-URL: libuv#2869
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
Arenoros authored and JeffroMF committed May 16, 2022
1 parent 4645622 commit af86d16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/win/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ int uv__udp_set_source_membership6(uv_udp_t* handle,
int optname;
int err;

STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr));
STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr));

if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6))
return UV_EINVAL;

Expand All @@ -774,8 +777,6 @@ int uv__udp_set_source_membership6(uv_udp_t* handle,
mreq.gsr_interface = 0;
}

STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr));
STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr));
memcpy(&mreq.gsr_group, multicast_addr, sizeof(*multicast_addr));
memcpy(&mreq.gsr_source, source_addr, sizeof(*source_addr));

Expand Down
6 changes: 4 additions & 2 deletions src/win/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ uint64_t uv_hrtime(void) {

uint64_t uv__hrtime(unsigned int scale) {
LARGE_INTEGER counter;
double scaled_freq;
double result;

assert(hrtime_frequency_ != 0);
assert(scale != 0);
Expand All @@ -504,8 +506,8 @@ uint64_t uv__hrtime(unsigned int scale) {
* performance counter interval, integer math could cause this computation
* to overflow. Therefore we resort to floating point math.
*/
double scaled_freq = (double)hrtime_frequency_ / scale;
double result = (double) counter.QuadPart / scaled_freq;
scaled_freq = (double) hrtime_frequency_ / scale;
result = (double) counter.QuadPart / scaled_freq;
return (uint64_t) result;
}

Expand Down

0 comments on commit af86d16

Please sign in to comment.