网站内容框架,做网站亏本,seo分析及优化建议,免费seo推广计划它的问题跟这个是相同的#xff1b;
RISC-V平台 std::atomic#xff1c;T#xff1e; 编译失败问题解决-CSDN博客 区别是自己写的代码#xff0c;能改掉#xff0c;但是 Jemalloc 编译好的静态库。 比如#xff1a;我们是在其它平台上面交叉编译的 RISC-V程序#xff0…它的问题跟这个是相同的
RISC-V平台 std::atomicT 编译失败问题解决-CSDN博客 区别是自己写的代码能改掉但是 Jemalloc 编译好的静态库。 比如我们是在其它平台上面交叉编译的 RISC-V程序静态库是从 Ubuntu或 Debian 官方源仓库之中获取的 libjemalloc.dep 包里面带的静态库就没法编译。 当然你自己编译的也行一样的问题动态库出不来要不然你自己去改 jemalloc 代码要不然你就打补丁或者换个内存分配池库。 如nedmalloc、tcmalloc 这类的。 否则就在自己程序里面打补丁把建议在自己程序之中打补丁提高程序兼容各种平台的可编译性能在自己的工程代码内做补丁是最容易控制的。 补丁
/* risv: undefined reference to __atomic_compare_exchange_1、__atomic_fetch_add_2... */
#if defined(JEMALLOC)
#if defined(__riscv) || defined(__riscv__) || defined(__riscv32__) || defined(__riscv64__)
/* patch: jemalloc-risv */
static struct __ATOMIC final {
public:typedef std::mutex SynchronizedObject;typedef std::lock_guardSynchronizedObject SynchronizedObjectScope;public:SynchronizedObject Lock;
} __ATOMIC_;// LLVM-CC:
// GUNL-CC:
// https://doc.dpdk.org/api-18.11/rte__atomic_8h_source.html
#ifdef __cplusplus
extern C {
#endif/* * __atomic_exchange_n(dst, val, __ATOMIC_SEQ_CST);* __atomic_exchange_4(dst, val, __ATOMIC_SEQ_CST);*/__attribute__((visibility(default))) unsigned char __atomic_exchange_1(volatile void* ptr, unsigned char value, int memorder) noexcept {__ATOMIC::SynchronizedObjectScope scope(__ATOMIC_.Lock);unsigned char* dst (unsigned char*)ptr;unsigned char old *dst;*dst value;return old;}/*volatile void *ptr: Pointer to the variable to be operated on.void *expected: Pointer to the value to be compared.void *desired: expected new value.bool weak: Indicates whether to use weak memory order (true indicates weak memory order, false indicates strong memory order).int success_memorder: Memory order upon success.int failure_memorder: Memory sequence of failure.*/__attribute__((visibility(default))) bool __atomic_compare_exchange_1(volatile void* ptr, void* expected, unsigned char desired, bool weak, int success_memorder, int failure_memorder) noexcept {__ATOMIC::SynchronizedObjectScope scope(__ATOMIC_.Lock);unsigned char* dst (unsigned char*)ptr;unsigned char* exchange (unsigned char*)expected;unsigned char old *dst;if (old ! *exchange) {return false;}*dst desired;*exchange old;return true;}
#ifdef __cplusplus
}
#endif
#endif
#endif