Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubospica committed Jan 24, 2025
1 parent 933f6f5 commit b702170
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 8 additions & 1 deletion cpp/support/dynamic_bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include <cstring>
#include <vector>

// For __popcnt
#ifdef _MSC_VER
#include <intrin.h>
#endif

#include "logging.h"

namespace xgrammar {
Expand Down Expand Up @@ -177,8 +182,10 @@ class DynamicBitset {
}

static int PopCount(uint32_t value) {
#if defined(__GNUC__) || defined(_MSC_VER)
#ifdef __GNUC__
return __builtin_popcount(value);
#elif defined(_MSC_VER)
return __popcnt(value);
#else
XGRAMMAR_LOG(FATAL) << "PopCount is not supported on this platform";
#endif
Expand Down
6 changes: 0 additions & 6 deletions cpp/support/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
#include <functional>
#include <tuple>

// Define __builtin_popcount for MSVC
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

namespace xgrammar {

/*!
Expand Down

0 comments on commit b702170

Please sign in to comment.