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

[TD-13762]<fix>: redefine atomic api.

上级 a409c076
...@@ -85,11 +85,7 @@ typedef struct taosField { ...@@ -85,11 +85,7 @@ typedef struct taosField {
int32_t bytes; int32_t bytes;
} TAOS_FIELD; } TAOS_FIELD;
#ifdef _TD_GO_DLL_
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT #define DLL_EXPORT
#endif
typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code); typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code);
......
此差异已折叠。
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define _TD_OS_DIR_H_ #define _TD_OS_DIR_H_
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define opendir OPENDIR_FUNC_TAOS_FORBID #define opendir OPENDIR_FUNC_TAOS_FORBID
#define readdir READDIR_FUNC_TAOS_FORBID #define readdir READDIR_FUNC_TAOS_FORBID
......
...@@ -23,6 +23,7 @@ extern "C" { ...@@ -23,6 +23,7 @@ extern "C" {
#include "osSocket.h" #include "osSocket.h"
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following sectio
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define open OPEN_FUNC_TAOS_FORBID #define open OPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID #define fopen FOPEN_FUNC_TAOS_FORBID
......
...@@ -23,6 +23,7 @@ extern "C" { ...@@ -23,6 +23,7 @@ extern "C" {
#endif #endif
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define setlocale SETLOCALE_FUNC_TAOS_FORBID #define setlocale SETLOCALE_FUNC_TAOS_FORBID
#endif #endif
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#endif #endif
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define rand RAND_FUNC_TAOS_FORBID #define rand RAND_FUNC_TAOS_FORBID
#define srand SRAND_FUNC_TAOS_FORBID #define srand SRAND_FUNC_TAOS_FORBID
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#endif #endif
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define Sleep SLEEP_FUNC_TAOS_FORBID #define Sleep SLEEP_FUNC_TAOS_FORBID
#define sleep SLEEP_FUNC_TAOS_FORBID #define sleep SLEEP_FUNC_TAOS_FORBID
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define _TD_OS_SOCKET_H_ #define _TD_OS_SOCKET_H_
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define socket SOCKET_FUNC_TAOS_FORBID #define socket SOCKET_FUNC_TAOS_FORBID
#define bind BIND_FUNC_TAOS_FORBID #define bind BIND_FUNC_TAOS_FORBID
...@@ -52,9 +53,6 @@ extern "C" { ...@@ -52,9 +53,6 @@ extern "C" {
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) #if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
#define htobe64 htonll #define htobe64 htonll
#if defined(_TD_GO_DLL_)
uint64_t htonll(uint64_t val);
#endif
#endif #endif
#if defined(_TD_DARWIN_64) #if defined(_TD_DARWIN_64)
......
...@@ -24,6 +24,7 @@ typedef wchar_t TdWchar; ...@@ -24,6 +24,7 @@ typedef wchar_t TdWchar;
typedef int32_t TdUcs4; typedef int32_t TdUcs4;
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID #define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID
#define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID #define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#endif #endif
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define popen POPEN_FUNC_TAOS_FORBID #define popen POPEN_FUNC_TAOS_FORBID
#define pclose PCLOSE_FUNC_TAOS_FORBID #define pclose PCLOSE_FUNC_TAOS_FORBID
......
...@@ -37,6 +37,7 @@ typedef pthread_condattr_t TdThreadCondAttr; ...@@ -37,6 +37,7 @@ typedef pthread_condattr_t TdThreadCondAttr;
#define taosThreadCleanupPop pthread_cleanup_pop #define taosThreadCleanupPop pthread_cleanup_pop
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define pthread_t PTHREAD_T_TYPE_TAOS_FORBID #define pthread_t PTHREAD_T_TYPE_TAOS_FORBID
#define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID #define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#endif #endif
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define strptime STRPTIME_FUNC_TAOS_FORBID #define strptime STRPTIME_FUNC_TAOS_FORBID
#define gettimeofday GETTIMEOFDAY_FUNC_TAOS_FORBID #define gettimeofday GETTIMEOFDAY_FUNC_TAOS_FORBID
...@@ -33,11 +34,7 @@ extern "C" { ...@@ -33,11 +34,7 @@ extern "C" {
#define CLOCK_REALTIME 0 #define CLOCK_REALTIME 0
#ifdef _TD_GO_DLL_ #define MILLISECOND_PER_SECOND (1000i64)
#define MILLISECOND_PER_SECOND (1000LL)
#else
#define MILLISECOND_PER_SECOND (1000i64)
#endif
#else #else
#define MILLISECOND_PER_SECOND ((int64_t)1000L) #define MILLISECOND_PER_SECOND ((int64_t)1000L)
#endif #endif
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#endif #endif
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define timer_create TIMER_CREATE_FUNC_TAOS_FORBID #define timer_create TIMER_CREATE_FUNC_TAOS_FORBID
#define timer_settime TIMER_SETTIME_FUNC_TAOS_FORBID #define timer_settime TIMER_SETTIME_FUNC_TAOS_FORBID
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#endif #endif
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define tzset TZSET_FUNC_TAOS_FORBID #define tzset TZSET_FUNC_TAOS_FORBID
#endif #endif
......
...@@ -48,8 +48,8 @@ static void registerRequest(SRequestObj *pRequest) { ...@@ -48,8 +48,8 @@ static void registerRequest(SRequestObj *pRequest) {
if (pTscObj->pAppInfo) { if (pTscObj->pAppInfo) {
SInstanceSummary *pSummary = &pTscObj->pAppInfo->summary; SInstanceSummary *pSummary = &pTscObj->pAppInfo->summary;
int32_t total = atomic_add_fetch_32(&pSummary->totalRequests, 1); int32_t total = atomic_add_fetch_64(&pSummary->totalRequests, 1);
int32_t currentInst = atomic_add_fetch_32(&pSummary->currentRequests, 1); int32_t currentInst = atomic_add_fetch_64(&pSummary->currentRequests, 1);
tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64 tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64
", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64, ", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64,
pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId); pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
...@@ -62,7 +62,7 @@ static void deregisterRequest(SRequestObj *pRequest) { ...@@ -62,7 +62,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
STscObj * pTscObj = pRequest->pTscObj; STscObj * pTscObj = pRequest->pTscObj;
SInstanceSummary *pActivity = &pTscObj->pAppInfo->summary; SInstanceSummary *pActivity = &pTscObj->pAppInfo->summary;
int32_t currentInst = atomic_sub_fetch_32(&pActivity->currentRequests, 1); int32_t currentInst = atomic_sub_fetch_64(&pActivity->currentRequests, 1);
int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1); int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1);
int64_t duration = taosGetTimestampMs() - pRequest->metric.start; int64_t duration = taosGetTimestampMs() - pRequest->metric.start;
......
...@@ -166,7 +166,7 @@ static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream) { ...@@ -166,7 +166,7 @@ static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream) {
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream) { static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream) {
mTrace("stream:%s, perform update action", pOldStream->name); mTrace("stream:%s, perform update action", pOldStream->name);
atomic_exchange_32(&pOldStream->updateTime, pNewStream->updateTime); atomic_exchange_64(&pOldStream->updateTime, pNewStream->updateTime);
atomic_exchange_32(&pOldStream->version, pNewStream->version); atomic_exchange_32(&pOldStream->version, pNewStream->version);
taosWLockLatch(&pOldStream->lock); taosWLockLatch(&pOldStream->lock);
......
...@@ -176,7 +176,7 @@ static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic) { ...@@ -176,7 +176,7 @@ static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic) {
static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pOldTopic, SMqTopicObj *pNewTopic) { static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pOldTopic, SMqTopicObj *pNewTopic) {
mTrace("topic:%s, perform update action", pOldTopic->name); mTrace("topic:%s, perform update action", pOldTopic->name);
atomic_exchange_32(&pOldTopic->updateTime, pNewTopic->updateTime); atomic_exchange_64(&pOldTopic->updateTime, pNewTopic->updateTime);
atomic_exchange_32(&pOldTopic->version, pNewTopic->version); atomic_exchange_32(&pOldTopic->version, pNewTopic->version);
taosWLockLatch(&pOldTopic->lock); taosWLockLatch(&pOldTopic->lock);
......
...@@ -278,7 +278,7 @@ typedef struct SCtgAction { ...@@ -278,7 +278,7 @@ typedef struct SCtgAction {
#define CTG_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #define CTG_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#define CTG_API_LEAVE(c) do { int32_t __code = c; CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); CTG_RET(__code); } while (0) #define CTG_API_LEAVE(c) do { int32_t __code = c; CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); CTG_RET(__code); } while (0)
#define CTG_API_ENTER() do { CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); if (atomic_load_8(&gCtgMgmt.exit)) { CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); } } while (0) #define CTG_API_ENTER() do { CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); } } while (0)
......
...@@ -2044,7 +2044,7 @@ void* ctgUpdateThreadFunc(void* param) { ...@@ -2044,7 +2044,7 @@ void* ctgUpdateThreadFunc(void* param) {
while (true) { while (true) {
tsem_wait(&gCtgMgmt.sem); tsem_wait(&gCtgMgmt.sem);
if (atomic_load_8(&gCtgMgmt.exit)) { if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) {
break; break;
} }
...@@ -2090,7 +2090,7 @@ int32_t catalogInit(SCatalogCfg *cfg) { ...@@ -2090,7 +2090,7 @@ int32_t catalogInit(SCatalogCfg *cfg) {
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
} }
atomic_store_8(&gCtgMgmt.exit, false); atomic_store_8((int8_t*)&gCtgMgmt.exit, false);
if (cfg) { if (cfg) {
memcpy(&gCtgMgmt.cfg, cfg, sizeof(*cfg)); memcpy(&gCtgMgmt.cfg, cfg, sizeof(*cfg));
...@@ -2705,11 +2705,11 @@ int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbVgVersion **dbs, uint32_t *num) ...@@ -2705,11 +2705,11 @@ int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbVgVersion **dbs, uint32_t *num)
void catalogDestroy(void) { void catalogDestroy(void) {
qInfo("start to destroy catalog"); qInfo("start to destroy catalog");
if (NULL == gCtgMgmt.pCluster || atomic_load_8(&gCtgMgmt.exit)) { if (NULL == gCtgMgmt.pCluster || atomic_load_8((int8_t*)&gCtgMgmt.exit)) {
return; return;
} }
atomic_store_8(&gCtgMgmt.exit, true); atomic_store_8((int8_t*)&gCtgMgmt.exit, true);
tsem_post(&gCtgMgmt.sem); tsem_post(&gCtgMgmt.sem);
......
...@@ -40,7 +40,7 @@ typedef struct SHNode { ...@@ -40,7 +40,7 @@ typedef struct SHNode {
typedef struct SSHashObj { typedef struct SSHashObj {
SHNode **hashList; SHNode **hashList;
size_t capacity; // number of slots size_t capacity; // number of slots
size_t size; // number of elements in hash table int64_t size; // number of elements in hash table
_hash_fn_t hashFp; // hash function _hash_fn_t hashFp; // hash function
_equal_fn_t equalFp; // equal function _equal_fn_t equalFp; // equal function
int32_t keyLen; int32_t keyLen;
...@@ -91,7 +91,7 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) { ...@@ -91,7 +91,7 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) {
if (pHashObj == NULL) { if (pHashObj == NULL) {
return 0; return 0;
} }
return (int32_t)atomic_load_64(&pHashObj->size); return (int32_t)atomic_load_64((int64_t*)&pHashObj->size);
} }
static SHNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, size_t dsize, uint32_t hashVal) { static SHNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, size_t dsize, uint32_t hashVal) {
......
...@@ -97,7 +97,7 @@ bool fmIsAggFunc(int32_t funcId) { ...@@ -97,7 +97,7 @@ bool fmIsAggFunc(int32_t funcId) {
void fmFuncMgtDestroy() { void fmFuncMgtDestroy() {
void* m = gFunMgtService.pFuncNameHashTable; void* m = gFunMgtService.pFuncNameHashTable;
if (m != NULL && atomic_val_compare_exchange_ptr(&gFunMgtService.pFuncNameHashTable, m, 0) == m) { if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) {
taosHashCleanup(m); taosHashCleanup(m);
} }
} }
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include "tdatablock.h"
#include "mockCatalogService.h" #include "mockCatalogService.h"
#include "tdatablock.h"
#include "tname.h" #include "tname.h"
#include "ttypes.h" #include "ttypes.h"
......
...@@ -50,7 +50,7 @@ namespace { ...@@ -50,7 +50,7 @@ namespace {
int32_t qwtTestMaxExecTaskUsec = 2; int32_t qwtTestMaxExecTaskUsec = 2;
int32_t qwtTestReqMaxDelayUsec = 2; int32_t qwtTestReqMaxDelayUsec = 2;
uint64_t qwtTestQueryId = 0; int64_t qwtTestQueryId = 0;
bool qwtTestEnableSleep = true; bool qwtTestEnableSleep = true;
bool qwtTestStop = false; bool qwtTestStop = false;
bool qwtTestDeadLoop = false; bool qwtTestDeadLoop = false;
......
此差异已折叠。
...@@ -216,12 +216,6 @@ int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer) { ...@@ -216,12 +216,6 @@ int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer) {
#endif #endif
} }
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
#if defined(_TD_GO_DLL_)
uint64_t htonll(uint64_t val) { return (((uint64_t)htonl(val)) << 32) + htonl(val >> 32); }
#endif
#endif
void taosWinSocketInit1() { void taosWinSocketInit1() {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
static char flag = 0; static char flag = 0;
......
...@@ -456,7 +456,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen ...@@ -456,7 +456,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
} }
if (pCacheObj->numOfElems == 0) { if (pCacheObj->numOfElems == 0) {
atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); atomic_add_fetch_64(&pCacheObj->statistics.missCount, 1);
return NULL; return NULL;
} }
...@@ -475,15 +475,15 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen ...@@ -475,15 +475,15 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
void *pData = (pNode != NULL) ? pNode->data : NULL; void *pData = (pNode != NULL) ? pNode->data : NULL;
if (pData != NULL) { if (pData != NULL) {
atomic_add_fetch_32(&pCacheObj->statistics.hitCount, 1); atomic_add_fetch_64(&pCacheObj->statistics.hitCount, 1);
uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, pData, uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, pData,
T_REF_VAL_GET(pNode)); T_REF_VAL_GET(pNode));
} else { } else {
atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); atomic_add_fetch_64(&pCacheObj->statistics.missCount, 1);
uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key);
} }
atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1); atomic_add_fetch_64(&pCacheObj->statistics.totalAccess, 1);
return pData; return pData;
} }
......
...@@ -55,7 +55,7 @@ typedef struct SHashEntry { ...@@ -55,7 +55,7 @@ typedef struct SHashEntry {
struct SHashObj { struct SHashObj {
SHashEntry ** hashList; SHashEntry ** hashList;
size_t capacity; // number of slots size_t capacity; // number of slots
size_t size; // number of elements in hash table int64_t size; // number of elements in hash table
_hash_fn_t hashFp; // hash function _hash_fn_t hashFp; // hash function
_equal_fn_t equalFp; // equal function _equal_fn_t equalFp; // equal function
_hash_free_fn_t freeFp; // hash node free callback function _hash_free_fn_t freeFp; // hash node free callback function
...@@ -186,7 +186,7 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p ...@@ -186,7 +186,7 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p
static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry* pe, SHashNode* prev, SHashNode *pNode, SHashNode *pNewNode) { static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry* pe, SHashNode* prev, SHashNode *pNode, SHashNode *pNewNode) {
assert(pNode->keyLen == pNewNode->keyLen); assert(pNode->keyLen == pNewNode->keyLen);
atomic_sub_fetch_32(&pNode->refCount, 1); atomic_sub_fetch_16(&pNode->refCount, 1);
if (prev != NULL) { if (prev != NULL) {
prev->next = pNewNode; prev->next = pNewNode;
} else { } else {
...@@ -302,7 +302,7 @@ int32_t taosHashGetSize(const SHashObj *pHashObj) { ...@@ -302,7 +302,7 @@ int32_t taosHashGetSize(const SHashObj *pHashObj) {
if (pHashObj == NULL) { if (pHashObj == NULL) {
return 0; return 0;
} }
return (int32_t)atomic_load_64(&pHashObj->size); return (int32_t)atomic_load_64((int64_t*)&pHashObj->size);
} }
int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *data, size_t size) { int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *data, size_t size) {
...@@ -508,7 +508,7 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) { ...@@ -508,7 +508,7 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
pNode->removed == 0) { pNode->removed == 0) {
code = 0; // it is found code = 0; // it is found
atomic_sub_fetch_32(&pNode->refCount, 1); atomic_sub_fetch_16(&pNode->refCount, 1);
pNode->removed = 1; pNode->removed = 1;
if (pNode->refCount <= 0) { if (pNode->refCount <= 0) {
if (prevNode == NULL) { if (prevNode == NULL) {
...@@ -755,7 +755,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { ...@@ -755,7 +755,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) {
pNode = pNode->next; pNode = pNode->next;
} }
atomic_sub_fetch_32(&pOld->refCount, 1); atomic_sub_fetch_16(&pOld->refCount, 1);
if (pOld->refCount <=0) { if (pOld->refCount <=0) {
if (prevNode) { if (prevNode) {
prevNode->next = pOld->next; prevNode->next = pOld->next;
......
...@@ -132,7 +132,7 @@ static timer_map_t timerMap; ...@@ -132,7 +132,7 @@ static timer_map_t timerMap;
static uintptr_t getNextTimerId() { static uintptr_t getNextTimerId() {
uintptr_t id; uintptr_t id;
do { do {
id = atomic_add_fetch_ptr(&nextTimerId, 1); id = (uintptr_t)atomic_add_fetch_ptr((void **)&nextTimerId, 1);
} while (id == 0); } while (id == 0);
return id; return id;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册