Skip to content
Snippets Groups Projects
Commit 576f2d47 authored by James M Snell's avatar James M Snell Committed by Tatsuhiro Tsujikawa
Browse files

Implement popcnt and lzcnt for windows arm64

Fixes: https://github.com/ngtcp2/ngtcp2/issues/261
parent 6e02c26c
No related merge requests found
......@@ -244,6 +244,14 @@ static uint64_t ngtcp2_cbrt(uint64_t n) {
#if defined(_MSC_VER)
# if defined(_M_X64)
d = (int)__lzcnt64(n);
# elif defined(_M_ARM64)
{
unsigned long index;
d = sizeof(uint64_t) * CHAR_BIT;
if (_BitScanReverse64(&index, n)) {
d = d - 1 - index;
}
}
# else
if ((n >> 32) != 0) {
d = __lzcnt((unsigned int)(n >> 32));
......
......@@ -31,6 +31,16 @@
#include "ngtcp2_macro.h"
#if defined(_MSC_VER) && defined(_M_ARM64)
unsigned int __popcnt(unsigned int x) {
unsigned int c = 0;
for (; x; ++c) {
x &= x - 1;
}
return c;
}
#endif
int ngtcp2_ringbuf_init(ngtcp2_ringbuf *rb, size_t nmemb, size_t size,
const ngtcp2_mem *mem) {
#ifdef WIN32
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment