鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

Fetch_add

原子加

  • x86平台
    static inline uint64
    pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
    {
            uint64 res;
            __asm__ __volatile__(
                    "       lock                            \n"
                    "       xaddq   %0,%1           \n"
    :               "=q"(res), "=m"(ptr->value)
    :               "0" (add_), "m"(ptr->value)
    :               "memory", "cc");
            return res;
    }
  • AArch64平台
    static inline uint64
    pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
    {
            return __sync_fetch_and_add(&ptr->value, add_);
    }