Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
82ce093a
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
82ce093a
编写于
11月 08, 2019
作者:
weixin_48148422
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TBASE-870: fix link error in windows
上级
128a49fc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
29 deletion
+34
-29
src/os/darwin/inc/os.h
src/os/darwin/inc/os.h
+1
-1
src/os/linux/inc/os.h
src/os/linux/inc/os.h
+1
-1
src/os/windows/inc/os.h
src/os/windows/inc/os.h
+9
-6
src/os/windows/src/twindows.c
src/os/windows/src/twindows.c
+13
-2
src/util/src/ttimer.c
src/util/src/ttimer.c
+10
-19
未找到文件。
src/os/darwin/inc/os.h
浏览文件 @
82ce093a
...
...
@@ -84,8 +84,8 @@
#define __sync_add_and_fetch_64 __sync_add_and_fetch
#define __sync_add_and_fetch_32 __sync_add_and_fetch
#define __sync_add_and_fetch_16 __sync_add_and_fetch
#define __sync_add_and_fetch_ptr __sync_add_and_fetch
#define __sync_add_and_fetch_8 __sync_add_and_fetch
#define __sync_add_and_fetch_ptr __sync_add_and_fetch
#define __sync_sub_and_fetch_64 __sync_sub_and_fetch
#define __sync_sub_and_fetch_32 __sync_sub_and_fetch
...
...
src/os/linux/inc/os.h
浏览文件 @
82ce093a
...
...
@@ -100,8 +100,8 @@ extern "C" {
#define __sync_add_and_fetch_64 __sync_add_and_fetch
#define __sync_add_and_fetch_32 __sync_add_and_fetch
#define __sync_add_and_fetch_16 __sync_add_and_fetch
#define __sync_add_and_fetch_ptr __sync_add_and_fetch
#define __sync_add_and_fetch_8 __sync_add_and_fetch
#define __sync_add_and_fetch_ptr __sync_add_and_fetch
#define __sync_sub_and_fetch_64 __sync_sub_and_fetch
#define __sync_sub_and_fetch_32 __sync_sub_and_fetch
...
...
src/os/windows/inc/os.h
浏览文件 @
82ce093a
...
...
@@ -127,16 +127,19 @@ extern "C" {
#define __sync_val_compare_and_swap_64(ptr, oldval, newval) _InterlockedCompareExchange64((__int64 volatile*)(ptr), (__int64)(newval), (__int64)(oldval))
#define __sync_val_compare_and_swap_ptr(ptr, oldval, newval) _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval))
char
interlocked_add_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_add_16
(
short
volatile
*
ptr
,
short
val
);
char
interlocked_add_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_add_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_add_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_add_64
(
__int64
volatile
*
ptr
,
__int64
val
);
#define __sync_add_and_fetch_8(ptr, val) interlocked_add_8((char volatile*)(ptr), (char)(val))
#define __sync_add_and_fetch_16(ptr, val) interlocked_add_16((short volatile*)(ptr), (short)(val))
#define __sync_add_and_fetch_32(ptr, val)
_InterlockedAdd
((long volatile*)(ptr), (long)(val))
#define __sync_add_and_fetch_64(ptr, val)
_InterlockedAdd
64((__int64 volatile*)(ptr), (__int64)(val))
#define __sync_add_and_fetch_32(ptr, val)
interlocked_add_32
((long volatile*)(ptr), (long)(val))
#define __sync_add_and_fetch_64(ptr, val)
interlocked_add_
64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _WIN64
#define __sync_add_and_fetch_ptr
atomic_ad
d_fetch_64
#define __sync_add_and_fetch_ptr
__sync_add_an
d_fetch_64
#else
#define __sync_add_and_fetch_ptr
atomic_ad
d_fetch_32
#define __sync_add_and_fetch_ptr
__sync_add_an
d_fetch_32
#endif
#define __sync_sub_and_fetch_8(ptr, val) __sync_add_and_fetch_8((ptr), -(val))
...
...
src/os/windows/src/twindows.c
浏览文件 @
82ce093a
...
...
@@ -43,8 +43,11 @@ void taosResetPthread(pthread_t *thread) {
}
int64_t
taosGetPthreadId
()
{
pthread_t
id
=
pthread_self
();
return
(
int64_t
)
id
.
p
;
#ifdef PTW32_VERSION
return
pthread_getw32threadid_np
(
pthread_self
());
#else
return
(
int64_t
)
pthread_self
();
#endif
}
int
taosSetSockOpt
(
int
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
...
...
@@ -72,6 +75,14 @@ short interlocked_add_16(short volatile* ptr, short val) {
return
_InterlockedExchangeAdd16
(
ptr
,
val
)
+
val
;
}
long
interlocked_add_32
(
long
volatile
*
ptr
,
long
val
)
{
return
_InterlockedExchangeAdd
(
ptr
,
val
)
+
val
;
}
__int64
interlocked_add_64
(
__int64
volatile
*
ptr
,
__int64
val
)
{
return
_InterlockedExchangeAdd64
(
ptr
,
val
)
+
val
;
}
int32_t
__sync_val_load_32
(
int32_t
*
ptr
)
{
return
InterlockedOr
(
ptr
,
0
);
}
...
...
src/util/src/ttimer.c
浏览文件 @
82ce093a
...
...
@@ -27,15 +27,6 @@
#include "tutil.h"
static
uintptr_t
pthreadGetId
()
{
#ifdef PTW32_VERSION
return
pthread_getw32threadid_np
(
pthread_self
());
#else
assert
(
sizeof
(
pthread_t
)
==
sizeof
(
uintptr_t
));
return
(
uintptr_t
)
pthread_self
();
#endif
}
#define TIMER_STATE_WAITING 0
#define TIMER_STATE_EXPIRED 1
#define TIMER_STATE_STOPPED 2
...
...
@@ -63,15 +54,15 @@ typedef struct tmr_obj_t {
uint8_t
reserved1
;
uint16_t
reserved2
;
union
{
int64_t
expireAt
;
uintptr
_t
executedBy
;
int64_t
expireAt
;
int64
_t
executedBy
;
};
TAOS_TMR_CALLBACK
fp
;
void
*
param
;
}
tmr_obj_t
;
typedef
struct
timer_list_t
{
uintptr_t
lockedBy
;
int64_t
lockedBy
;
tmr_obj_t
*
timers
;
}
timer_list_t
;
...
...
@@ -125,9 +116,9 @@ static void timerDecRef(tmr_obj_t* timer) {
}
static
void
lockTimerList
(
timer_list_t
*
list
)
{
uintptr_t
tid
=
pthreadGet
Id
();
int64_t
tid
=
taosGetPthread
Id
();
int
i
=
0
;
while
(
__sync_val_compare_and_swap_
ptr
(
&
(
list
->
lockedBy
),
0
,
tid
)
!=
0
)
{
while
(
__sync_val_compare_and_swap_
64
(
&
(
list
->
lockedBy
),
0
,
tid
)
!=
0
)
{
if
(
++
i
%
1000
==
0
)
{
sched_yield
();
}
...
...
@@ -135,8 +126,8 @@ static void lockTimerList(timer_list_t* list) {
}
static
void
unlockTimerList
(
timer_list_t
*
list
)
{
uintptr_t
tid
=
pthreadGet
Id
();
if
(
__sync_val_compare_and_swap_
ptr
(
&
(
list
->
lockedBy
),
tid
,
0
)
!=
tid
)
{
int64_t
tid
=
taosGetPthread
Id
();
if
(
__sync_val_compare_and_swap_
64
(
&
(
list
->
lockedBy
),
tid
,
0
)
!=
tid
)
{
assert
(
false
);
tmrError
(
"trying to unlock a timer list not locked by current thread."
);
}
...
...
@@ -262,7 +253,7 @@ static bool removeFromWheel(tmr_obj_t* timer) {
static
void
processExpiredTimer
(
void
*
handle
,
void
*
arg
)
{
tmr_obj_t
*
timer
=
(
tmr_obj_t
*
)
handle
;
timer
->
executedBy
=
pthreadGet
Id
();
timer
->
executedBy
=
taosGetPthread
Id
();
uint8_t
state
=
__sync_val_compare_and_swap_8
(
&
timer
->
state
,
TIMER_STATE_WAITING
,
TIMER_STATE_EXPIRED
);
if
(
state
==
TIMER_STATE_WAITING
)
{
const
char
*
fmt
=
"timer[label=%s, id=%lld, fp=%p, param=%p] execution start."
;
...
...
@@ -402,12 +393,12 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
tmrTrace
(
fmt
,
timer
->
ctrl
->
label
,
timer
->
id
,
timer
->
fp
,
timer
->
param
);
}
else
if
(
state
!=
TIMER_STATE_EXPIRED
)
{
// timer already stopped or cancelled, has nothing to do in this case
}
else
if
(
timer
->
executedBy
==
pthreadGet
Id
())
{
}
else
if
(
timer
->
executedBy
==
taosGetPthread
Id
())
{
// taosTmrReset is called in the timer callback, should do nothing in this
// case to avoid dead lock. note taosTmrReset must be the last statement
// of the callback funtion, will be a bug otherwise.
}
else
{
assert
(
timer
->
executedBy
!=
pthreadGet
Id
());
assert
(
timer
->
executedBy
!=
taosGetPthread
Id
());
const
char
*
fmt
=
"timer[label=%s, id=%lld, fp=%p, param=%p] fired, waiting..."
;
tmrTrace
(
fmt
,
timer
->
ctrl
->
label
,
timer
->
id
,
timer
->
fp
,
timer
->
param
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录