From 241af017e432320cf927e2638741c65acee2dd6e Mon Sep 17 00:00:00 2001 From: Zifeng Deng Date: Thu, 9 Nov 2023 21:08:01 +0800 Subject: [PATCH 1/4] feat(net): use INADDR_ANY by default --- include/co_context/config.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/co_context/config.hpp b/include/co_context/config.hpp index e55b9d2..e1e87c8 100644 --- a/include/co_context/config.hpp +++ b/include/co_context/config.hpp @@ -108,8 +108,7 @@ namespace config { // ======================================================================== // ========================== net configuration =========================== - inline constexpr bool is_loopback_only = true; - // inline constexpr bool is_loopback_only = false; + inline constexpr bool is_loopback_only = false; // ======================================================================== // =========================== co configuration =========================== From 5d5f92da7747b4d1f5ee03285e56964ed6b6cfee Mon Sep 17 00:00:00 2001 From: Zifeng Deng Date: Thu, 9 Nov 2023 21:54:02 +0800 Subject: [PATCH 2/4] build(cmake): disable -march=native when cross-compiling --- cmake/CompileOption.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CompileOption.cmake b/cmake/CompileOption.cmake index 12d5b0c..52e92dd 100644 --- a/cmake/CompileOption.cmake +++ b/cmake/CompileOption.cmake @@ -14,7 +14,7 @@ if(NOT CMAKE_BUILD_TYPE) message(NOTICE "Setting default CMAKE_BUILD_TYPE to Release") endif() -if(CMAKE_BUILD_TYPE MATCHES Release) +if(CMAKE_BUILD_TYPE MATCHES Release AND NOT CMAKE_CROSSCOMPILING) target_compile_options(co_context PUBLIC -march=native) endif() From e9ff6a2b4d19045b8783e6a13a153d449fdc7eae Mon Sep 17 00:00:00 2001 From: Zifeng Deng Date: Thu, 9 Nov 2023 21:59:17 +0800 Subject: [PATCH 3/4] feat(compat): support riscv. Thanks wangzhankun https://github.com/wangzhankun --- include/co_context/detail/compat.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/co_context/detail/compat.hpp b/include/co_context/detail/compat.hpp index 815dfe6..51bc367 100644 --- a/include/co_context/detail/compat.hpp +++ b/include/co_context/detail/compat.hpp @@ -9,11 +9,15 @@ #endif #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) -#define CO_CONTEXT_PAUSE __builtin_ia32_pause +#if defined(__i386__) || defined(__x86_64__) +#define CO_CONTEXT_PAUSE() __builtin_ia32_pause() +#elif defined(__riscv) +#define CO_CONTEXT_PAUSE() __asm__ volatile("fence iorw, iorw") +#endif #elif defined(_MSC_VER) -#define CO_CONTEXT_PAUSE _mm_pause +#define CO_CONTEXT_PAUSE() _mm_pause() #else -#define CO_CONTEXT_PAUSE __builtin_ia32_pause +#define CO_CONTEXT_PAUSE() __builtin_ia32_pause() #endif #if (defined(__GNUC__) || defined(__GNUG__)) \ From 1334c5b52fab0ca789395669f466c5fdd71fb7f3 Mon Sep 17 00:00:00 2001 From: Zifeng Deng Date: Thu, 9 Nov 2023 22:15:12 +0800 Subject: [PATCH 4/4] feat(io_context): no require lock_free in local spsc_cursor --- include/co_context/detail/spsc_cursor.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/co_context/detail/spsc_cursor.hpp b/include/co_context/detail/spsc_cursor.hpp index cebcf3f..c84feb4 100644 --- a/include/co_context/detail/spsc_cursor.hpp +++ b/include/co_context/detail/spsc_cursor.hpp @@ -14,7 +14,7 @@ template< bool is_blocking = is_thread_safe> struct spsc_cursor { static_assert(std::has_single_bit(capacity)); - static_assert(std::atomic::is_always_lock_free); + static_assert(!is_thread_safe || std::atomic::is_always_lock_free); static_assert( is_thread_safe || !is_blocking, "a thread-unsafe instance "