提交 68b69be5 编写于 作者: wafwerar's avatar wafwerar

fix(os): centos pthread spinlock error.

上级 63b0e304
......@@ -22,6 +22,10 @@
extern "C" {
#endif
#ifndef __USE_XOPEN2K
typedef pthread_mutex_t pthread_spinlock_t;
#endif
typedef pthread_t TdThread;
typedef pthread_spinlock_t TdThreadSpinlock;
typedef pthread_mutex_t TdThreadMutex;
......@@ -33,8 +37,6 @@ typedef pthread_rwlockattr_t TdThreadRwlockAttr;
typedef pthread_cond_t TdThreadCond;
typedef pthread_condattr_t TdThreadCondAttr;
typedef pthread_key_t TdThreadKey;
typedef pthread_barrier_t TdThreadBarrier;
typedef pthread_barrierattr_t TdThreadBarrierAttr;
#define taosThreadCleanupPush pthread_cleanup_push
#define taosThreadCleanupPop pthread_cleanup_pop
......@@ -156,13 +158,6 @@ int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_para
int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy);
int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope);
int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize);
int32_t taosThreadBarrierDestroy(TdThreadBarrier * barrier);
int32_t taosThreadBarrierInit(TdThreadBarrier * barrier, const TdThreadBarrierAttr * attr, uint32_t count);
int32_t taosThreadBarrierWait(TdThreadBarrier * barrier);
int32_t taosThreadBarrierAttrDestroy(TdThreadBarrierAttr * attr);
int32_t taosThreadBarrierAttrGetPshared(const TdThreadBarrierAttr * attr, int32_t *pshared);
int32_t taosThreadBarrierAttrInit(TdThreadBarrierAttr * attr);
int32_t taosThreadBarrierAttrSetPshared(TdThreadBarrierAttr * attr, int32_t pshared);
int32_t taosThreadCancel(TdThread thread);
int32_t taosThreadCondDestroy(TdThreadCond * cond);
int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr);
......
......@@ -77,34 +77,6 @@ int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) {
return pthread_attr_setstacksize(attr, stacksize);
}
int32_t taosThreadBarrierDestroy(TdThreadBarrier * barrier) {
return pthread_barrier_destroy(barrier);
}
int32_t taosThreadBarrierInit(TdThreadBarrier * barrier, const TdThreadBarrierAttr * attr, uint32_t count) {
return pthread_barrier_init(barrier, attr, count);
}
int32_t taosThreadBarrierWait(TdThreadBarrier * barrier) {
return pthread_barrier_wait(barrier);
}
int32_t taosThreadBarrierAttrDestroy(TdThreadBarrierAttr * attr) {
return pthread_barrierattr_destroy(attr);
}
int32_t taosThreadBarrierAttrGetPshared(const TdThreadBarrierAttr * attr, int32_t *pshared) {
return pthread_barrierattr_getpshared(attr, pshared);
}
int32_t taosThreadBarrierAttrInit(TdThreadBarrierAttr * attr) {
return pthread_barrierattr_init(attr);
}
int32_t taosThreadBarrierAttrSetPshared(TdThreadBarrierAttr * attr, int32_t pshared) {
return pthread_barrierattr_setpshared(attr, pshared);
}
int32_t taosThreadCancel(TdThread thread) {
return pthread_cancel(thread);
}
......@@ -322,23 +294,43 @@ int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) {
}
int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock) {
return pthread_spin_destroy(lock);
#ifndef __USE_XOPEN2K
return pthread_mutex_destroy((pthread_mutex_t*)lock);
#else
return pthread_spin_destroy((pthread_spinlock_t*)lock);
#endif
}
int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared) {
return pthread_spin_init(lock, pshared);
#ifndef __USE_XOPEN2K
return pthread_mutex_init((pthread_mutex_t*)lock, pshared);
#else
return pthread_spin_init((pthread_spinlock_t*)lock, pshared);
#endif
}
int32_t taosThreadSpinLock(TdThreadSpinlock * lock) {
return pthread_spin_lock(lock);
#ifndef __USE_XOPEN2K
return pthread_mutex_lock((pthread_mutex_t*)lock);
#else
return pthread_spin_lock((pthread_spinlock_t*)lock);
#endif
}
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock) {
return pthread_spin_trylock(lock);
#ifndef __USE_XOPEN2K
return pthread_mutex_trylock((pthread_mutex_t*)lock);
#else
return pthread_spin_trylock((pthread_spinlock_t*)lock);
#endif
}
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock) {
return pthread_spin_unlock(lock);
#ifndef __USE_XOPEN2K
return pthread_mutex_unlock((pthread_mutex_t*)lock);
#else
return pthread_spin_unlock((pthread_spinlock_t*)lock);
#endif
}
void taosThreadTestCancel(void) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册