Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
ec743fce
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ec743fce
编写于
9月 26, 2018
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more atomic intrinsics
上级
d183b33c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
3 deletion
+18
-3
src/hb-atomic.hh
src/hb-atomic.hh
+18
-3
未找到文件。
src/hb-atomic.hh
浏览文件 @
ec743fce
...
...
@@ -49,17 +49,21 @@
/* Defined externally, i.e. in config.h. */
#elif !defined(HB_NO_MT) && defined(__ATOMIC_
CONSUM
E)
#elif !defined(HB_NO_MT) && defined(__ATOMIC_
ACQUIR
E)
/* C++11-style GCC primitives. */
#define _hb_memory_barrier() __sync_synchronize ()
#define hb_atomic_int_impl_add(AI, V) __atomic_fetch_add ((AI), (V), __ATOMIC_ACQ_REL)
#define hb_atomic_int_impl_set_relaxed(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELAXED)
#define hb_atomic_int_impl_set(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELEASE)
#define hb_atomic_int_impl_get_relaxed(AI) __atomic_load_n ((AI), __ATOMIC_RELAXED)
#define hb_atomic_int_impl_get(AI) __atomic_load_n ((AI), __ATOMIC_ACQUIRE)
#define hb_atomic_ptr_impl_set_relaxed(P, V) __atomic_store_n ((P), (V), __ATOMIC_RELAXED)
#define hb_atomic_ptr_impl_get_relaxed(P) __atomic_load_n ((P), __ATOMIC_RELAXED)
#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_
CONSUM
E)
#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_
ACQUIR
E)
static
inline
bool
_hb_atomic_ptr_impl_cmplexch
(
const
void
**
P
,
const
void
*
O_
,
const
void
*
N
)
{
...
...
@@ -74,13 +78,19 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
#include <atomic>
#define _hb_memory_barrier() std::atomic_thread_fence(std::memory_order_ack_rel)
#define _hb_memory_r_barrier() std::atomic_thread_fence(std::memory_order_acquire)
#define _hb_memory_w_barrier() std::atomic_thread_fence(std::memory_order_release)
#define hb_atomic_int_impl_add(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->fetch_add ((V), std::memory_order_acq_rel))
#define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->store ((V), std::memory_order_relaxed))
#define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->store ((V), std::memory_order_release))
#define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast<std::atomic<int> *> (AI)->load (std::memory_order_relaxed))
#define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast<std::atomic<int> *> (AI)->load (std::memory_order_acquire))
#define hb_atomic_ptr_impl_set_relaxed(P, V) (reinterpret_cast<std::atomic<void*> *> (P)->store ((V), std::memory_order_relaxed))
#define hb_atomic_ptr_impl_get_relaxed(P) (reinterpret_cast<std::atomic<void*> *> (P)->load (std::memory_order_relaxed))
#define hb_atomic_ptr_impl_get(P) (reinterpret_cast<std::atomic<void*> *> (P)->load (std::memory_order_
consum
e))
#define hb_atomic_ptr_impl_get(P) (reinterpret_cast<std::atomic<void*> *> (P)->load (std::memory_order_
acquir
e))
static
inline
bool
_hb_atomic_ptr_impl_cmplexch
(
const
void
**
P
,
const
void
*
O_
,
const
void
*
N
)
{
...
...
@@ -243,6 +253,9 @@ static_assert ((sizeof (long) == sizeof (void *)), "");
#ifndef hb_atomic_ptr_impl_get_relaxed
#define hb_atomic_ptr_impl_get_relaxed(P) (*(P))
#endif
#ifndef hb_atomic_int_impl_get
inline
int
hb_atomic_int_impl_get
(
int
*
AI
)
{
int
v
=
*
AI
;
_hb_memory_r_barrier
();
return
v
;
}
#endif
#ifndef hb_atomic_ptr_impl_get
inline
void
*
hb_atomic_ptr_impl_get
(
void
**
P
)
{
void
*
v
=
*
P
;
_hb_memory_r_barrier
();
return
v
;
}
#endif
...
...
@@ -252,7 +265,9 @@ inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barr
struct
hb_atomic_int_t
{
inline
void
set_relaxed
(
int
v_
)
const
{
hb_atomic_int_impl_set_relaxed
(
&
v
,
v_
);
}
inline
void
set
(
int
v_
)
const
{
hb_atomic_int_impl_set
(
&
v
,
v_
);
}
inline
int
get_relaxed
(
void
)
const
{
return
hb_atomic_int_impl_get_relaxed
(
&
v
);
}
inline
int
get
(
void
)
const
{
return
hb_atomic_int_impl_get
(
&
v
);
}
inline
int
inc
(
void
)
{
return
hb_atomic_int_impl_add
(
&
v
,
1
);
}
inline
int
dec
(
void
)
{
return
hb_atomic_int_impl_add
(
&
v
,
-
1
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录