From db5a76c212537d4f9714f64ac0d5b40f0bc54927 Mon Sep 17 00:00:00 2001 From: owent Date: Sun, 24 Mar 2019 21:57:27 +0800 Subject: [PATCH] fix some waning in MSVC 2019 --- .travis.yml | 2 +- cmake_dev.bat | 14 +++++++++++--- cmake_dev.sh | 2 +- .../coroutine/coroutine_context_container.h | 12 ++++++------ include/libcopp/utils/config/compiler_features.h | 4 +++- include/libcotask/task.h | 2 +- include/libcotask/task_manager.h | 4 ++-- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a229d0..dd443b9 100755 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ env: global: - LANG="zh_CN.UTF-8" - CMAKE_PREFIX=$HOME/prebuilt/cmake ; - - CMAKE_LINUX_URL=https://cmake.org/files/v3.13/cmake-3.13.1-Linux-x86_64.sh ; + - CMAKE_LINUX_URL=https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh ; - PANDOC_PREFIX=$HOME/prebuilt/pandoc ; - PANDOC_LINUX_URL=https://github.com/jgm/pandoc/releases/download/2.5/pandoc-2.5-linux.tar.gz - DOXYGEN_PREFIX=$HOME/prebuilt/doxygen diff --git a/cmake_dev.bat b/cmake_dev.bat index 4183e09..e103b14 100755 --- a/cmake_dev.bat +++ b/cmake_dev.bat @@ -1,4 +1,12 @@ -mkdir build_windows_msvc -cd build_windows_msvc +@echo off -cmake .. -G "Visual Studio 15 2017 Win64" -DLIBCOPP_FCONTEXT_USE_TSX=ON -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON \ No newline at end of file +mkdir %~dp0\build_jobs_vs2019 +cd %~dp0\build_jobs_vs2019 + +cmake .. -G "Visual Studio 16 2019" -A x64 -DLIBCOPP_FCONTEXT_USE_TSX=ON -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON + +if %ERRORLEVEL% == 0 GOTO no_error + +pause + +:no_error diff --git a/cmake_dev.sh b/cmake_dev.sh index 9a28942..8917602 100755 --- a/cmake_dev.sh +++ b/cmake_dev.sh @@ -10,7 +10,7 @@ CMAKE_OPTIONS="-DLIBCOPP_FCONTEXT_USE_TSX=ON -DPROJECT_ENABLE_UNITTEST=ON -DPROJ CMAKE_CLANG_TIDY=""; CMAKE_CLANG_ANALYZER=0; CMAKE_CLANG_ANALYZER_PATH=""; -BUILD_DIR=$(echo "build_$SYS_NAME" | tr '[:upper:]' '[:lower:]'); +BUILD_DIR=$(echo "build_jobs_$SYS_NAME" | tr '[:upper:]' '[:lower:]'); CMAKE_BUILD_TYPE=Debug; CPPCHECK_PLATFORM=unix64; diff --git a/include/libcopp/coroutine/coroutine_context_container.h b/include/libcopp/coroutine/coroutine_context_container.h index 6afffde..baf5eb9 100755 --- a/include/libcopp/coroutine/coroutine_context_container.h +++ b/include/libcopp/coroutine/coroutine_context_container.h @@ -57,7 +57,7 @@ namespace copp { /** * @brief create and init coroutine with specify runner and specify stack size * @param runner runner - * @param stack_size stack size + * @param stack_sz stack size * @param private_buffer_size private buffer size * @param coroutine_size extend buffer before coroutine * @return COPP_EC_SUCCESS or error code @@ -68,10 +68,10 @@ namespace copp { #else const callback_t &runner, #endif - allocator_type &alloc, size_t stack_size = 0, size_t private_buffer_size = 0, size_t coroutine_size = 0) UTIL_CONFIG_NOEXCEPT { + allocator_type &alloc, size_t stack_sz = 0, size_t private_buffer_size = 0, size_t coroutine_size = 0) UTIL_CONFIG_NOEXCEPT { ptr_t ret; - if (0 == stack_size) { - stack_size = stack_traits::default_size(); + if (0 == stack_sz) { + stack_sz = stack_traits::default_size(); } // padding to sizeof size_t @@ -80,12 +80,12 @@ namespace copp { coroutine_size += this_align_size; private_buffer_size = coroutine_context::align_private_data_size(private_buffer_size); - if (stack_size <= coroutine_size + private_buffer_size) { + if (stack_sz <= coroutine_size + private_buffer_size) { return ret; } stack_context callee_stack; - alloc.allocate(callee_stack, stack_size); + alloc.allocate(callee_stack, stack_sz); if (NULL == callee_stack.sp) { return ret; diff --git a/include/libcopp/utils/config/compiler_features.h b/include/libcopp/utils/config/compiler_features.h index 29f92cc..948b98e 100644 --- a/include/libcopp/utils/config/compiler_features.h +++ b/include/libcopp/utils/config/compiler_features.h @@ -77,7 +77,7 @@ # undef UTIL_CONFIG_COMPILER_IS_zOS # define UTIL_CONFIG_COMPILER_IS_zOS 1 -#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800 +#elif defined(__ibmxl__) || (defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800) # undef UTIL_CONFIG_COMPILER_IS_XL # define UTIL_CONFIG_COMPILER_IS_XL 1 @@ -642,6 +642,8 @@ # if defined(UTIL_CONFIG_COMPILER_CXX_NULLPTR) && UTIL_CONFIG_COMPILER_CXX_NULLPTR # define UTIL_CONFIG_NULLPTR nullptr +# elif UTIL_CONFIG_COMPILER_IS_GNU +# define UTIL_CONFIG_NULLPTR __null # else # define UTIL_CONFIG_NULLPTR 0 # endif diff --git a/include/libcotask/task.h b/include/libcotask/task.h index 1963a5f..f72408b 100755 --- a/include/libcotask/task.h +++ b/include/libcotask/task.h @@ -50,7 +50,7 @@ namespace cotask { * @brief constuctor * @note should not be called directly */ - task(size_t stack_size) : stack_size_(stack_size), action_destroy_fn_(UTIL_CONFIG_NULLPTR) { + task(size_t stack_sz) : stack_size_(stack_sz), action_destroy_fn_(UTIL_CONFIG_NULLPTR) { id_allocator_t id_alloc_; id_ = id_alloc_.allocate(); ref_count_.store(0); diff --git a/include/libcotask/task_manager.h b/include/libcotask/task_manager.h index e1b909c..82b8b3c 100755 --- a/include/libcotask/task_manager.h +++ b/include/libcotask/task_manager.h @@ -190,8 +190,8 @@ namespace cotask { // add timeout controller if (0 != timeout_sec || 0 != timeout_nsec) { - typedef typename std::multimap::value_type pair_type; - task_timeout_checkpoints_.insert(pair_type(task_node.expired_time_, task_id)); + typedef typename std::multimap::value_type timer_pair_type; + task_timeout_checkpoints_.insert(timer_pair_type(task_node.expired_time_, task_id)); } return copp::COPP_EC_SUCCESS;