Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: compat for cross-compiling & RISC-V #92

Merged
merged 4 commits into from
Nov 9, 2023
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
2 changes: 1 addition & 1 deletion cmake/CompileOption.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions include/co_context/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===========================
Expand Down
10 changes: 7 additions & 3 deletions include/co_context/detail/compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__)) \
Expand Down
2 changes: 1 addition & 1 deletion include/co_context/detail/spsc_cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>::is_always_lock_free);
static_assert(!is_thread_safe || std::atomic<T>::is_always_lock_free);
static_assert(
is_thread_safe || !is_blocking,
"a thread-unsafe instance "
Expand Down
Loading