From 0de4a471695a490e55553b1cbbc2c4e644e7b474 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 30 Jan 2019 13:29:41 -0500 Subject: [PATCH] qemu/host-utils: Handle ctpop8/16/32/64 on MSVC Maybe not the most platform friendly way of doing so --- qemu/include/qemu/host-utils.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qemu/include/qemu/host-utils.h b/qemu/include/qemu/host-utils.h index ff80be17..89ec4b43 100644 --- a/qemu/include/qemu/host-utils.h +++ b/qemu/include/qemu/host-utils.h @@ -292,7 +292,11 @@ static inline int clrsb64(uint64_t val) */ static inline int ctpop8(uint8_t val) { +#ifdef _MSC_VER + return __popcnt(val); +#else return __builtin_popcount(val); +#endif } /** @@ -301,7 +305,11 @@ static inline int ctpop8(uint8_t val) */ static inline int ctpop16(uint16_t val) { +#ifdef _MSC_VER + return __popcnt(val); +#else return __builtin_popcount(val); +#endif } /** @@ -310,7 +318,11 @@ static inline int ctpop16(uint16_t val) */ static inline int ctpop32(uint32_t val) { +#ifdef _MSC_VER + return __popcnt(val); +#else return __builtin_popcount(val); +#endif } /** @@ -319,7 +331,11 @@ static inline int ctpop32(uint32_t val) */ static inline int ctpop64(uint64_t val) { +#ifdef _MSC_VER + return __popcnt64(val); +#else return __builtin_popcountll(val); +#endif } /**