diff --git a/include/util/taoserror.h b/include/util/taoserror.h index c6eccae1d3..751e35b482 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -18,6 +18,8 @@ #include +#include "osDef.h" + #ifdef __cplusplus extern "C" { #endif @@ -46,11 +48,11 @@ const char* terrstr(); char* taosGetErrMsgReturn(); char* taosGetErrMsg(); int32_t* taosGetErrno(); -int32_t* taosGetErrln(); int32_t taosGetErrSize(); -#define terrno (*taosGetErrno()) -#define terrln (*taosGetErrln()) -#define terrMsg (taosGetErrMsg()) + +extern threadlocal int32_t terrno; +extern threadlocal int32_t terrln; +extern threadlocal char terrMsg[ERR_MSG_LEN]; #define SET_ERROR_MSG(MSG, ...) \ snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__) diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 14ea448731..bb8c30380f 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -21,14 +21,14 @@ #define TAOS_ERROR_C -static threadlocal int32_t tsErrno; -static threadlocal int32_t tsErrln; -static threadlocal char tsErrMsgDetail[ERR_MSG_LEN] = {0}; +threadlocal int32_t terrno; +threadlocal int32_t terrln; +threadlocal char terrMsg[ERR_MSG_LEN]; + static threadlocal char tsErrMsgReturn[ERR_MSG_LEN] = {0}; -int32_t* taosGetErrno() { return &tsErrno; } -int32_t* taosGetErrln() { return &tsErrln; } -char* taosGetErrMsg() { return tsErrMsgDetail; } +int32_t* taosGetErrno() { return &terrno; } +char* taosGetErrMsg() { return terrMsg; } char* taosGetErrMsgReturn() { return tsErrMsgReturn; } #ifdef TAOS_ERROR_C