Skip to content

Commit 097e960

Browse files
committed
deps: fixup win arm64 build for ngtcp2/nghttp3
1 parent aaaa51f commit 097e960

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

deps/nghttp3/lib/nghttp3_ringbuf.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,25 @@
3333

3434
#include "nghttp3_macro.h"
3535

36-
#if defined(_MSC_VER) && defined(_M_ARM64)
37-
unsigned int __popcnt(unsigned int x) {
36+
#if defined(_WIN32)
37+
# if defined(_M_ARM64)
38+
unsigned int __nghttp3_popcnt(unsigned int x) {
3839
unsigned int c = 0;
3940
for (; x; ++c) {
4041
x &= x - 1;
4142
}
4243
return c;
4344
}
45+
# else
46+
# define __nghttp3_popcnt __popcnt
47+
# endif
4448
#endif
4549

4650
int nghttp3_ringbuf_init(nghttp3_ringbuf *rb, size_t nmemb, size_t size,
4751
const nghttp3_mem *mem) {
4852
if (nmemb) {
4953
#ifdef WIN32
50-
assert(1 == __popcnt((unsigned int)nmemb));
54+
assert(1 == __nghttp3_popcnt((unsigned int)nmemb));
5155
#else
5256
assert(1 == __builtin_popcount((unsigned int)nmemb));
5357
#endif
@@ -127,7 +131,7 @@ int nghttp3_ringbuf_reserve(nghttp3_ringbuf *rb, size_t nmemb) {
127131
}
128132

129133
#ifdef WIN32
130-
assert(1 == __popcnt((unsigned int)nmemb));
134+
assert(1 == __nghttp3_popcnt((unsigned int)nmemb));
131135
#else
132136
assert(1 == __builtin_popcount((unsigned int)nmemb));
133137
#endif

deps/ngtcp2/lib/ngtcp2_ringbuf.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,24 @@
3131

3232
#include "ngtcp2_macro.h"
3333

34-
#if defined(_MSC_VER) && defined(_M_ARM64)
35-
unsigned int __popcnt(unsigned int x) {
34+
#if defined(_WIN32)
35+
# if defined(_M_ARM64)
36+
unsigned int __ngtcp2_popcnt(unsigned int x) {
3637
unsigned int c = 0;
3738
for (; x; ++c) {
3839
x &= x - 1;
3940
}
4041
return c;
4142
}
43+
# else
44+
# define __ngtcp2_popcnt __popcnt
45+
# endif
4246
#endif
4347

4448
int ngtcp2_ringbuf_init(ngtcp2_ringbuf *rb, size_t nmemb, size_t size,
4549
const ngtcp2_mem *mem) {
4650
#ifdef WIN32
47-
assert(1 == __popcnt((unsigned int)nmemb));
51+
assert(1 == __ngtcp2_popcnt((unsigned int)nmemb));
4852
#else
4953
assert(1 == __builtin_popcount((unsigned int)nmemb));
5054
#endif

0 commit comments

Comments
 (0)