File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,10 @@ foreach(name
179179 configure_file ("${name} .in" "${name} " @ONLY)
180180endforeach ()
181181
182+ if (NOT ENABLE_POPCNT)
183+ add_definitions (-DDISABLE_POPCNT)
184+ endif ()
185+
182186if (ENABLE_SHARED_LIB AND ENABLE_STATIC_LIB AND MSVC AND NOT STATIC_LIB_SUFFIX)
183187 set (STATIC_LIB_SUFFIX "_static" )
184188endif ()
@@ -213,6 +217,8 @@ message(STATUS "summary of build options:
213217 CXXFLAGS: ${CMAKE_CXX_FLAGS_${_build_type} } ${CMAKE_CXX_FLAGS}
214218 WARNCFLAGS: ${WARNCFLAGS}
215219 WARNCXXFLAGS: ${WARNCXXFLAGS}
220+ SIMD instruction:
221+ Enable popcnt: ${ENABLE_POPCNT}
216222 Library:
217223 Shared: ${ENABLE_SHARED_LIB}
218224 Static: ${ENABLE_STATIC_LIB}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ option(ENABLE_LIB_ONLY "Build libnghttp3 only" OFF)
77option (ENABLE_STATIC_LIB "Build libnghttp3 as a static library" ON )
88option (ENABLE_SHARED_LIB "Build libnghttp3 as a shared library" ON )
99option (ENABLE_STATIC_CRT "Build libnghttp3 against the MS LIBCMT[d]" )
10+ option (ENABLE_POPCNT "Enable popcnt instruction" ON )
1011cmake_dependent_option(BUILD_TESTING "Enable tests" ON "ENABLE_STATIC_LIB" OFF )
1112
1213# vim: ft=cmake:
Original file line number Diff line number Diff line change 3535
3636#ifndef NDEBUG
3737static int ispow2 (size_t n ) {
38- # if defined(_MSC_VER ) && !defined(__clang__ ) && \
39- (defined(_M_ARM ) || (defined(_M_ARM64 ) && _MSC_VER < 1941 ))
38+ # if defined(DISABLE_POPCNT ) || \
39+ (defined(_MSC_VER ) && !defined(__clang__ ) && \
40+ (defined(_M_ARM ) || (defined(_M_ARM64 ) && _MSC_VER < 1941 )))
4041 return n && !(n & (n - 1 ));
4142# elif defined(WIN32 )
4243 return 1 == __popcnt ((unsigned int )n );
You can’t perform that action at this time.
0 commit comments