From 097e9602602dfb421dee0f00c4cd2c65ed699b17 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 24 Aug 2020 09:48:45 -0700 Subject: [PATCH] deps: fixup win arm64 build for ngtcp2/nghttp3 --- deps/nghttp3/lib/nghttp3_ringbuf.c | 12 ++++++++---- deps/ngtcp2/lib/ngtcp2_ringbuf.c | 10 +++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/deps/nghttp3/lib/nghttp3_ringbuf.c b/deps/nghttp3/lib/nghttp3_ringbuf.c index 9ea91c81c8a1b9..a9d68680bbde19 100644 --- a/deps/nghttp3/lib/nghttp3_ringbuf.c +++ b/deps/nghttp3/lib/nghttp3_ringbuf.c @@ -33,21 +33,25 @@ #include "nghttp3_macro.h" -#if defined(_MSC_VER) && defined(_M_ARM64) -unsigned int __popcnt(unsigned int x) { +#if defined(_WIN32) +# if defined(_M_ARM64) +unsigned int __nghttp3_popcnt(unsigned int x) { unsigned int c = 0; for (; x; ++c) { x &= x - 1; } return c; } +# else +# define __nghttp3_popcnt __popcnt +# endif #endif int nghttp3_ringbuf_init(nghttp3_ringbuf *rb, size_t nmemb, size_t size, const nghttp3_mem *mem) { if (nmemb) { #ifdef WIN32 - assert(1 == __popcnt((unsigned int)nmemb)); + assert(1 == __nghttp3_popcnt((unsigned int)nmemb)); #else assert(1 == __builtin_popcount((unsigned int)nmemb)); #endif @@ -127,7 +131,7 @@ int nghttp3_ringbuf_reserve(nghttp3_ringbuf *rb, size_t nmemb) { } #ifdef WIN32 - assert(1 == __popcnt((unsigned int)nmemb)); + assert(1 == __nghttp3_popcnt((unsigned int)nmemb)); #else assert(1 == __builtin_popcount((unsigned int)nmemb)); #endif diff --git a/deps/ngtcp2/lib/ngtcp2_ringbuf.c b/deps/ngtcp2/lib/ngtcp2_ringbuf.c index e4deab1ff76b83..c11ed317b083fd 100644 --- a/deps/ngtcp2/lib/ngtcp2_ringbuf.c +++ b/deps/ngtcp2/lib/ngtcp2_ringbuf.c @@ -31,20 +31,24 @@ #include "ngtcp2_macro.h" -#if defined(_MSC_VER) && defined(_M_ARM64) -unsigned int __popcnt(unsigned int x) { +#if defined(_WIN32) +# if defined(_M_ARM64) +unsigned int __ngtcp2_popcnt(unsigned int x) { unsigned int c = 0; for (; x; ++c) { x &= x - 1; } return c; } +# else +# define __ngtcp2_popcnt __popcnt +# endif #endif int ngtcp2_ringbuf_init(ngtcp2_ringbuf *rb, size_t nmemb, size_t size, const ngtcp2_mem *mem) { #ifdef WIN32 - assert(1 == __popcnt((unsigned int)nmemb)); + assert(1 == __ngtcp2_popcnt((unsigned int)nmemb)); #else assert(1 == __builtin_popcount((unsigned int)nmemb)); #endif