Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ foreach(name
configure_file("${name}.in" "${name}" @ONLY)
endforeach()

if(NOT ENABLE_POPCNT)
add_definitions(-DDISABLE_POPCNT)
endif()

if(ENABLE_SHARED_LIB AND ENABLE_STATIC_LIB AND MSVC AND NOT STATIC_LIB_SUFFIX)
set(STATIC_LIB_SUFFIX "_static")
endif()
Expand Down Expand Up @@ -213,6 +217,8 @@ message(STATUS "summary of build options:
CXXFLAGS: ${CMAKE_CXX_FLAGS_${_build_type}} ${CMAKE_CXX_FLAGS}
WARNCFLAGS: ${WARNCFLAGS}
WARNCXXFLAGS: ${WARNCXXFLAGS}
SIMD instruction:
Enable popcnt: ${ENABLE_POPCNT}
Library:
Shared: ${ENABLE_SHARED_LIB}
Static: ${ENABLE_STATIC_LIB}
Expand Down
1 change: 1 addition & 0 deletions CMakeOptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option(ENABLE_LIB_ONLY "Build libnghttp3 only" OFF)
option(ENABLE_STATIC_LIB "Build libnghttp3 as a static library" ON)
option(ENABLE_SHARED_LIB "Build libnghttp3 as a shared library" ON)
option(ENABLE_STATIC_CRT "Build libnghttp3 against the MS LIBCMT[d]")
option(ENABLE_POPCNT "Enable popcnt instruction" ON)
cmake_dependent_option(BUILD_TESTING "Enable tests" ON "ENABLE_STATIC_LIB" OFF)

# vim: ft=cmake:
5 changes: 3 additions & 2 deletions lib/nghttp3_ringbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@

#ifndef NDEBUG
static int ispow2(size_t n) {
# if defined(_MSC_VER) && !defined(__clang__) && \
(defined(_M_ARM) || (defined(_M_ARM64) && _MSC_VER < 1941))
# if defined(DISABLE_POPCNT) || \
(defined(_MSC_VER) && !defined(__clang__) && \
(defined(_M_ARM) || (defined(_M_ARM64) && _MSC_VER < 1941)))
return n && !(n & (n - 1));
# elif defined(WIN32)
return 1 == __popcnt((unsigned int)n);
Expand Down
Loading