Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
d18431b4
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
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看板
提交
d18431b4
编写于
4月 20, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move hb_reference_count_t from macros to inline methods
上级
c57d454a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
14 deletion
+11
-14
src/hb-object-private.hh
src/hb-object-private.hh
+11
-14
未找到文件。
src/hb-object-private.hh
浏览文件 @
d18431b4
...
@@ -35,24 +35,21 @@
...
@@ -35,24 +35,21 @@
HB_BEGIN_DECLS
HB_BEGIN_DECLS
/* Encapsulate operations on the object's reference count */
typedef
struct
{
typedef
struct
{
hb_atomic_int_t
ref_count
;
hb_atomic_int_t
ref_count
;
}
hb_reference_count_t
;
#define hb_reference_count_inc(RC) hb_atomic_int_fetch_and_add ((RC).ref_count, 1)
#define hb_reference_count_dec(RC) hb_atomic_int_fetch_and_add ((RC).ref_count, -1)
#define HB_REFERENCE_COUNT_INIT(RC, VALUE) ((RC).ref_count = (VALUE))
inline
void
init
(
int
v
)
{
ref_count
=
v
;
/* non-atomic is fine */
}
inline
int
inc
(
void
)
{
return
hb_atomic_int_fetch_and_add
(
ref_count
,
1
);
}
inline
int
dec
(
void
)
{
return
hb_atomic_int_fetch_and_add
(
ref_count
,
-
1
);
}
inline
void
set
(
int
v
)
{
return
hb_atomic_int_set
(
ref_count
,
v
);
}
inline
int
get
(
void
)
{
return
hb_atomic_int_get
(
ref_count
);
}
#define HB_REFERENCE_COUNT_GET_VALUE(RC) hb_atomic_int_get ((RC).ref_count)
}
hb_reference_count_t
;
#define HB_REFERENCE_COUNT_SET_VALUE(RC, VALUE) hb_atomic_int_set ((RC).ref_count, (VALUE))
#define HB_REFERENCE_COUNT_INVALID_VALUE ((hb_atomic_int_t) -1)
#define HB_REFERENCE_COUNT_INVALID_VALUE ((hb_atomic_int_t) -1)
#define HB_REFERENCE_COUNT_INVALID {HB_REFERENCE_COUNT_INVALID_VALUE}
#define HB_REFERENCE_COUNT_INVALID {HB_REFERENCE_COUNT_INVALID_VALUE}
#define HB_REFERENCE_COUNT_IS_INVALID(RC) (HB_REFERENCE_COUNT_GET_VALUE (RC) == HB_REFERENCE_COUNT_INVALID_VALUE)
#define HB_REFERENCE_COUNT_IS_INVALID(RC) ((RC).get () == HB_REFERENCE_COUNT_INVALID_VALUE)
/* Debug */
/* Debug */
...
@@ -69,7 +66,7 @@ _hb_trace_object (const void *obj,
...
@@ -69,7 +66,7 @@ _hb_trace_object (const void *obj,
(
void
)
(
HB_DEBUG_OBJECT
&&
(
void
)
(
HB_DEBUG_OBJECT
&&
fprintf
(
stderr
,
"OBJECT(%p) refcount=%d %s
\n
"
,
fprintf
(
stderr
,
"OBJECT(%p) refcount=%d %s
\n
"
,
obj
,
obj
,
HB_REFERENCE_COUNT_GET_VALUE
(
*
ref_count
),
ref_count
->
get
(
),
function
));
function
));
}
}
...
@@ -83,7 +80,7 @@ _hb_trace_object (const void *obj,
...
@@ -83,7 +80,7 @@ _hb_trace_object (const void *obj,
(unlikely (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count)))
(unlikely (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count)))
#define HB_OBJECT_DO_INIT_EXPR(obj) \
#define HB_OBJECT_DO_INIT_EXPR(obj) \
HB_REFERENCE_COUNT_INIT (obj->ref_count,
1)
obj->ref_count.init (
1)
#define HB_OBJECT_DO_INIT(obj) \
#define HB_OBJECT_DO_INIT(obj) \
HB_STMT_START { \
HB_STMT_START { \
...
@@ -109,7 +106,7 @@ _hb_trace_object (const void *obj,
...
@@ -109,7 +106,7 @@ _hb_trace_object (const void *obj,
if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return obj; \
return obj; \
TRACE_OBJECT (obj); \
TRACE_OBJECT (obj); \
old_count =
hb_reference_count_inc (obj->ref_count
); \
old_count =
obj->ref_count.inc (
); \
assert (old_count > 0); \
assert (old_count > 0); \
return obj; \
return obj; \
} HB_STMT_END
} HB_STMT_END
...
@@ -120,7 +117,7 @@ _hb_trace_object (const void *obj,
...
@@ -120,7 +117,7 @@ _hb_trace_object (const void *obj,
if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return; \
return; \
TRACE_OBJECT (obj); \
TRACE_OBJECT (obj); \
old_count =
hb_reference_count_dec (obj->ref_count
); \
old_count =
obj->ref_count.dec (
); \
assert (old_count > 0); \
assert (old_count > 0); \
if (old_count != 1) \
if (old_count != 1) \
return; \
return; \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录