From 23bef711fca8a687246a42296c91467c1a14df58 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 15 Mar 2022 21:35:04 +0800 Subject: [PATCH] Feature/sangshuduo/td 13063 3.0 windows (#10720) * [TD-13063]: 3.0 on Windows * add pthread in contrib * fix linux compile * fix osSemaphore * add gnu regex for Windows * fix compile error for Windows * support arm platform * port more OS files * fix for Windows compile * port more files * fix macOS on x86_64 * port osFile * port osSemaphone.h * port osSocket.c * port tconfig.c * port ttimer.c * add couple files --- Jenkinsfile2 | 3 +- cmake/cmake.define | 11 ++- cmake/cmake.platform | 57 +++++++++---- include/os/os.h | 10 +++ include/os/osEok.h | 93 ++++++++++++++++++++++ include/os/osFile.h | 19 ++++- include/os/osSemaphore.h | 12 +-- include/os/osSocket.h | 35 +++++++- include/os/osSysinfo.h | 3 +- source/common/src/tdatablock.c | 9 ++- source/common/src/ttszip.c | 4 + source/libs/catalog/src/catalog.c | 8 +- source/libs/index/src/index.c | 1 + source/libs/index/src/index_cache.c | 3 + source/libs/index/src/index_fst.c | 6 ++ source/libs/parser/src/parInsert.c | 2 + source/libs/planner/src/planLogicCreater.c | 1 + source/libs/scalar/src/filter.c | 4 +- source/libs/scalar/src/scalar.c | 3 + source/libs/scheduler/src/schFlowCtrl.c | 4 +- source/libs/sync/src/syncRaftEntry.c | 16 ++-- source/libs/sync/src/syncVoteMgr.c | 22 ++--- source/libs/tfs/src/tfs.c | 4 +- source/libs/transport/src/transCli.c | 3 + source/libs/transport/src/transComm.c | 6 +- source/libs/transport/src/transSrv.c | 4 + source/libs/wal/src/walRead.c | 2 +- source/os/src/osFile.c | 17 ++-- source/os/src/osSocket.c | 12 ++- source/util/src/tconfig.c | 3 +- source/util/src/ttimer.c | 2 +- 31 files changed, 297 insertions(+), 82 deletions(-) create mode 100644 include/os/osEok.h diff --git a/Jenkinsfile2 b/Jenkinsfile2 index ad62fa7044..bf55e016b6 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -60,8 +60,9 @@ def pre_test(){ sh ''' cd ${WKC} git checkout 3.0 + [ -d contrib/bdb ] && cd contrib/bdb && git clean -fxd && cd ../.. ''' - } + } else{ sh ''' cd ${WKC} diff --git a/cmake/cmake.define b/cmake/cmake.define index b97c10a4b7..9c2d5dc04c 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -36,7 +36,14 @@ IF (TD_WINDOWS) ENDIF () ELSE () - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -g3") + +MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") +IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") + ADD_DEFINITIONS("-D_TD_ARM_") +ELSE () + ADD_DEFINITIONS("-msse4.2 -mfma") +ENDIF () ENDIF () diff --git a/cmake/cmake.platform b/cmake/cmake.platform index 7ef259ba54..0312f92a5b 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -7,30 +7,52 @@ SET(TD_LINUX FALSE) SET(TD_WINDOWS FALSE) SET(TD_DARWIN FALSE) -IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +MESSAGE("Compiler ID: ${CMAKE_CXX_COMPILER_ID}") +if(CMAKE_COMPILER_IS_GNUCXX MATCHES 1) + set(CXX_COMPILER_IS_GNU TRUE) +else() + set(CXX_COMPILER_IS_GNU FALSE) +endif() - SET(TD_LINUX TRUE) - SET(OSTYPE "Linux") - ADD_DEFINITIONS("-DLINUX") +MESSAGE("Current system name is ${CMAKE_SYSTEM_NAME}.") - IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - SET(TD_LINUX_64 TRUE) +IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + + IF (${CXX_COMPILER_IS_GNU}) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") ELSE () - SET(TD_LINUX_32 TRUE) + ADD_DEFINITIONS("-Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-unknown-warning-option") + set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") + set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") ENDIF () -ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - SET(TD_DARWIN TRUE) - SET(OSTYPE "macOS") - ADD_DEFINITIONS("-DDARWIN") - IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") - MESSAGE("Current system arch is arm64") - SET(TD_DARWIN_64 TRUE) - ADD_DEFINITIONS("-D_TD_DARWIN_64") - ENDIF () + SET(TD_LINUX TRUE) + SET(OSTYPE "Linux") + ADD_DEFINITIONS("-DLINUX") + + IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) + SET(TD_LINUX_64 TRUE) + ELSE () + SET(TD_LINUX_32 TRUE) + ENDIF () + + ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - ADD_DEFINITIONS("-DHAVE_UNISTD_H") + SET(TD_DARWIN TRUE) + SET(OSTYPE "macOS") + ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare") + + MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") + IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") + MESSAGE("Current system arch is arm64") + SET(TD_DARWIN_64 TRUE) + ADD_DEFINITIONS("-D_TD_DARWIN_64") + ENDIF () + + ADD_DEFINITIONS("-DHAVE_UNISTD_H") + ENDIF () ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") @@ -45,6 +67,7 @@ ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") SET(TD_WINDOWS_32 TRUE) ADD_DEFINITIONS("-D_TD_WINDOWS_32") ENDIF () + ENDIF() MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}") diff --git a/include/os/os.h b/include/os/os.h index fd272b15a3..12f4e733c2 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -22,6 +22,8 @@ extern "C" { #include #include +#include +#include #if !defined(WINDOWS) #include @@ -34,7 +36,12 @@ extern "C" { #include #include #include + +#if defined(DARWIN) +#else #include +#include +#endif #endif @@ -54,9 +61,12 @@ extern "C" { #include #include #include +#include #include +#include #include #include +#include #include diff --git a/include/os/osEok.h b/include/os/osEok.h new file mode 100644 index 0000000000..3ca476f840 --- /dev/null +++ b/include/os/osEok.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_OS_EOK_H +#define TDENGINE_OS_EOK_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ + +enum EPOLL_EVENTS + { + EPOLLIN = 0x001, +#define EPOLLIN EPOLLIN + EPOLLPRI = 0x002, +#define EPOLLPRI EPOLLPRI + EPOLLOUT = 0x004, +#define EPOLLOUT EPOLLOUT + EPOLLRDNORM = 0x040, +#define EPOLLRDNORM EPOLLRDNORM + EPOLLRDBAND = 0x080, +#define EPOLLRDBAND EPOLLRDBAND + EPOLLWRNORM = 0x100, +#define EPOLLWRNORM EPOLLWRNORM + EPOLLWRBAND = 0x200, +#define EPOLLWRBAND EPOLLWRBAND + EPOLLMSG = 0x400, +#define EPOLLMSG EPOLLMSG + EPOLLERR = 0x008, +#define EPOLLERR EPOLLERR + EPOLLHUP = 0x010, +#define EPOLLHUP EPOLLHUP + EPOLLRDHUP = 0x2000, +#define EPOLLRDHUP EPOLLRDHUP + EPOLLEXCLUSIVE = 1u << 28, +#define EPOLLEXCLUSIVE EPOLLEXCLUSIVE + EPOLLWAKEUP = 1u << 29, +#define EPOLLWAKEUP EPOLLWAKEUP + EPOLLONESHOT = 1u << 30, +#define EPOLLONESHOT EPOLLONESHOT + EPOLLET = 1u << 31 +#define EPOLLET EPOLLET + }; + +/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ +#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ +#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ +#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ + + +typedef union epoll_data +{ + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event +{ + uint32_t events; /* Epoll events */ + epoll_data_t data; /* User data variable */ +}; + +int epoll_create(int size); +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); +int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); +int epoll_close(int epfd); + +#endif // __APPLE__ + +#ifdef __cplusplus +} +#endif + +#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_ + diff --git a/include/os/osFile.h b/include/os/osFile.h index b0e97e7b54..58a9df2504 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -49,6 +49,15 @@ int64_t taosRead(FileFd fd, void *buf, int64_t count); #define PATH_MAX 256 #endif +typedef int32_t FileFd; + +typedef struct TdFile { + pthread_rwlock_t rwlock; + int refId; + FileFd fd; + FILE *fp; +} * TdFilePtr, TdFile; + typedef struct TdFile *TdFilePtr; #define TD_FILE_CTEATE 0x0001 @@ -101,8 +110,16 @@ int64_t taosCopyFile(const char *from, const char *to); int32_t taosRemoveFile(const char *path); void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath); - + +#if defined(_TD_DARWIN_64) +typedef int32_t SocketFd; + +int64_t taosSendFile(SocketFd fdDst, FileFd pFileSrc, int64_t *offset, int64_t size); +int64_t taosFSendFile(FILE *pFileOut, FILE *pFileIn, int64_t *offset, int64_t size); +#else +int64_t taosSendFile(SocketFd fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size); int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size); +#endif void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length); bool taosValidFile(TdFilePtr pFile); diff --git a/include/os/osSemaphore.h b/include/os/osSemaphore.h index 9904170d61..4bac81754d 100644 --- a/include/os/osSemaphore.h +++ b/include/os/osSemaphore.h @@ -38,12 +38,12 @@ extern "C" { #endif #if defined (_TD_DARWIN_64) - #define pthread_rwlock_t pthread_mutex_t - #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) - #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) - #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) - #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock) - #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) +// #define pthread_rwlock_t pthread_mutex_t +// #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) +// #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) +// #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) +// #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock) +// #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) #define pthread_spinlock_t pthread_mutex_t #define pthread_spin_init(lock, NULL) pthread_mutex_init(lock, NULL) diff --git a/include/os/osSocket.h b/include/os/osSocket.h index 3faed855ba..520d3af331 100644 --- a/include/os/osSocket.h +++ b/include/os/osSocket.h @@ -33,8 +33,15 @@ #include #include #else - #include - #include + #include + #include + + #if defined(_TD_DARWIN_64) + #include + #else + #include + #include + #endif #endif #ifdef __cplusplus @@ -49,7 +56,29 @@ extern "C" { #endif #if defined(_TD_DARWIN_64) - #define htobe64 htonll +// #define htobe64 htonll + +# include + +# define htobe16(x) OSSwapHostToBigInt16(x) +# define htole16(x) OSSwapHostToLittleInt16(x) +# define be16toh(x) OSSwapBigToHostInt16(x) +# define le16toh(x) OSSwapLittleToHostInt16(x) + +# define htobe32(x) OSSwapHostToBigInt32(x) +# define htole32(x) OSSwapHostToLittleInt32(x) +# define be32toh(x) OSSwapBigToHostInt32(x) +# define le32toh(x) OSSwapLittleToHostInt32(x) + +# define htobe64(x) OSSwapHostToBigInt64(x) +# define htole64(x) OSSwapHostToLittleInt64(x) +# define be64toh(x) OSSwapBigToHostInt64(x) +# define le64toh(x) OSSwapLittleToHostInt64(x) + +# define __BYTE_ORDER BYTE_ORDER +# define __BIG_ENDIAN BIG_ENDIAN +# define __LITTLE_ENDIAN LITTLE_ENDIAN +# define __PDP_ENDIAN PDP_ENDIAN #endif #define TAOS_EPOLL_WAIT_TIME 500 diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index d7cf05a594..7777466973 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -16,6 +16,7 @@ #ifndef _TD_OS_SYSINFO_H_ #define _TD_OS_SYSINFO_H_ +#include #include "os.h" #ifdef __cplusplus @@ -52,7 +53,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen); char *taosGetCmdlineByPID(int32_t pid); void taosSetCoreDump(bool enable); -#if defined(WINDOWS) +#if !defined(LINUX) #define _UTSNAME_LENGTH 65 #define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 7e4f1d9025..0d1f762db6 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -864,7 +864,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs qsort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn); int64_t p1 = taosGetTimestampUs(); - printf("sort:%ld, rows:%d\n", p1 - p0, pDataBlock->info.rows); + printf("sort:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows); return TSDB_CODE_SUCCESS; } else { // var data type @@ -912,7 +912,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs copyBackToBlock(pDataBlock, pCols); int64_t p4 = taosGetTimestampUs(); - printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows); + printf("sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows); destroyTupleIndex(index); return TSDB_CODE_SUCCESS; @@ -1017,7 +1017,7 @@ int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) { } int32_t varColSort(SColumnInfoData* pColumnInfoData, SBlockOrderInfo* pOrder) { - + return 0; } int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst) { @@ -1055,8 +1055,9 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF copyBackToBlock(pDataBlock, pCols); int64_t p4 = taosGetTimestampUs(); - printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows); + printf("sort:%" PRId64 ", create:%" PRId64", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows); // destroyTupleIndex(index); + return 0; } void blockDataClearup(SSDataBlock* pDataBlock) { diff --git a/source/common/src/ttszip.c b/source/common/src/ttszip.c index 464c29d287..5f0a353226 100644 --- a/source/common/src/ttszip.c +++ b/source/common/src/ttszip.c @@ -845,7 +845,11 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { int64_t offset = getDataStartOffset(); int32_t size = (int32_t)pSrcBuf->fileSize - (int32_t)offset; +#if defined(_TD_DARWIN_64) + int64_t written = taosFSendFile(pDestBuf->pFile->fp, pSrcBuf->pFile->fp, &offset, size); +#else int64_t written = taosFSendFile(pDestBuf->pFile, pSrcBuf->pFile, &offset, size); +#endif if (written == -1 || written != size) { return -1; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index e1ccb03c66..80a0b3554c 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -1062,7 +1062,7 @@ int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) { int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; @@ -1092,11 +1092,11 @@ _return: } int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; - + CTG_LOCK(CTG_WRITE, &slot->lock); if (NULL == slot->meta) { qError("empty meta slot, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); @@ -1133,7 +1133,7 @@ _return: } int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 744f6ca70b..d25fed6816 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -240,6 +240,7 @@ int indexRebuild(SIndex* index, SIndexOpts* opts){ #ifdef USE_INVERTED_INDEX #endif + return 0; } SIndexOpts* indexOptsCreate() { diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c index b40ded9e9a..34f009dd7e 100644 --- a/source/libs/index/src/index_cache.c +++ b/source/libs/index/src/index_cache.c @@ -190,7 +190,10 @@ int indexCacheSchedToMerge(IndexCache* pCache) { schedMsg.msg = NULL; taosScheduleTask(indexQhandle, &schedMsg); + + return 0; } + static void indexCacheMakeRoomForWrite(IndexCache* cache) { while (true) { if (cache->occupiedMem * MEM_ESTIMATE_RADIO < MEM_THRESHOLD) { diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index a6cabbd439..18cde151d2 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -571,6 +571,8 @@ uint64_t fstStateFindInput(FstState* s, FstNode* node, uint8_t b, bool* null) { } fstSliceDestroy(&t); } + + return 0; } // fst node function @@ -1027,6 +1029,8 @@ Fst* fstCreate(FstSlice* slice) { FST_CREAT_FAILED: free(fst->meta); free(fst); + + return NULL; } void fstDestroy(Fst* fst) { if (fst) { @@ -1286,6 +1290,8 @@ bool streamWithStateSeekMin(StreamWithState* sws, FstBoundWithData* min) { } return false; } + + return false; } StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallback callback) { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 43cc308483..28f680cfbb 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -763,6 +763,8 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema, // todo construct payload tfree(row); + + return 0; } // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 3fae580de9..cd9857c7f6 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -425,6 +425,7 @@ static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt) { default: break; } + return NULL; // to avoid compiler error } int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) { diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index a7aea5a7e5..33ec8ab6ef 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -792,7 +792,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { } SFilterGroup *gp = NULL; - while (gp = (SFilterGroup *)taosArrayPop(right)) { + while ((gp = (SFilterGroup *)taosArrayPop(right)) != NULL) { taosArrayPush(group, gp); } @@ -801,7 +801,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { if (taosArrayGetSize(right) <= 0) { SFilterGroup *gp = NULL; - while (gp = (SFilterGroup *)taosArrayPop(left)) { + while ((gp = (SFilterGroup *)taosArrayPop(left)) != NULL) { taosArrayPush(group, gp); } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b8cdda9ed1..8e7eaa0f8c 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -239,6 +239,9 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t break; } + + default: + break; } if (param->num > *rowNum) { diff --git a/source/libs/scheduler/src/schFlowCtrl.c b/source/libs/scheduler/src/schFlowCtrl.c index 9fba6523b6..993521da87 100644 --- a/source/libs/scheduler/src/schFlowCtrl.c +++ b/source/libs/scheduler/src/schFlowCtrl.c @@ -282,8 +282,10 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) { SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - SCH_ERR_RET(schLaunchTasksInFlowCtrlListImpl(pJob, ctrl)); + int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl);; + SCH_ERR_RET(code); + return code; // to avoid compiler error } diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index f29b3022d8..7ececf285a 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -74,12 +74,12 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) { cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->seqNum); cJSON_AddStringToObject(pRoot, "seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->index); cJSON_AddStringToObject(pRoot, "index", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); @@ -107,26 +107,26 @@ char* syncEntry2Str(const SSyncRaftEntry* pEntry) { // for debug ---------------------- void syncEntryPrint(const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - printf("syncEntryPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncEntryPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void syncEntryPrint2(char* s, const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - printf("syncEntryPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncEntryPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void syncEntryLog(const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - sTrace("syncEntryLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncEntryLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - sTrace("syncEntryLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncEntryLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 5c8e70979c..6cb6a28805 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -97,7 +97,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesGranted->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); @@ -122,27 +122,27 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) { // for debug ------------------- void voteGrantedPrint(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("voteGrantedPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void voteGrantedPrint2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("voteGrantedPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void voteGrantedLog(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("voteGrantedLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void voteGrantedLog2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("voteGrantedLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); } @@ -222,7 +222,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesRespond->term); cJSON_AddStringToObject(pRoot, "term", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); @@ -242,26 +242,26 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) { // for debug ------------------- void votesRespondPrint(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("votesRespondPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void votesRespondPrint2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("votesRespondPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void votesRespondLog(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("votesRespondLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void votesRespondLog2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("votesRespondLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index c46989dc5d..01e9808aa6 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -558,4 +558,6 @@ int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) { } } tfsUnLock(pTfs); -} \ No newline at end of file + + return 0; +} diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2f6ff3763f..5be1b7ea90 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -291,6 +291,7 @@ void* destroyConnPool(void* pool) { connList = taosHashIterate((SHashObj*)pool, connList); } taosHashCleanup(pool); + return NULL; } static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { @@ -576,6 +577,8 @@ static void* cliWorkThread(void* arg) { SCliThrdObj* pThrd = (SCliThrdObj*)arg; setThreadName("trans-cli-work"); uv_run(pThrd->loop, UV_RUN_DEFAULT); + + return NULL; } void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 367cb33fc9..7123593a33 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -155,14 +155,16 @@ bool transReadComplete(SConnBuffer* connBuf) { } return false; } -int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {} +int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {return 0;} -int transUnpackMsg(STransMsgHead* msgHead) {} +int transUnpackMsg(STransMsgHead* msgHead) {return 0;} int transDestroyBuffer(SConnBuffer* buf) { if (buf->cap > 0) { tfree(buf->buf); } transClearBuffer(buf); + + return 0; } int transSetConnOption(uv_tcp_t* stream) { diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index cb3bbaefec..d26c5ec0f4 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -538,6 +538,8 @@ void* acceptThread(void* arg) { setThreadName("trans-accept"); SServerObj* srv = (SServerObj*)arg; uv_run(srv->loop, UV_RUN_DEFAULT); + + return NULL; } static bool addHandleToWorkloop(void* arg) { SWorkThrdObj* pThrd = arg; @@ -593,6 +595,8 @@ void* workerThread(void* arg) { setThreadName("trans-worker"); SWorkThrdObj* pThrd = (SWorkThrdObj*)arg; uv_run(pThrd->loop, UV_RUN_DEFAULT); + + return NULL; } static SSrvConn* createConn(void* hThrd) { diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 9e1ffeae7f..8d3acef9e7 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -169,7 +169,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { } if (pRead->pHead->head.version != ver) { - wError("unexpected wal log version: %ld, read request version:%ld", pRead->pHead->head.version, ver); + wError("unexpected wal log version: %" PRId64 ", read request version:%" PRId64 "", pRead->pHead->head.version, ver); pRead->curVersion = -1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 6472202bf9..bcbd95e160 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -14,6 +14,7 @@ */ #define ALLOW_FORBID_FUNC #include "os.h" +#include "osSemaphore.h" #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #include @@ -35,26 +36,18 @@ extern int openU(const char *, int, ...); /* MsvcLibX UTF-8 version of open */ #else #include #include -#include + +#if !defined(_TD_DARWIN_64) + #include +#endif #include #include #define LINUX_FILE_NO_TEXT_OPTION 0 #define O_TEXT LINUX_FILE_NO_TEXT_OPTION #endif -typedef int32_t FileFd; - #define FILE_WITH_LOCK 1 -typedef struct TdFile { -#if FILE_WITH_LOCK - pthread_rwlock_t rwlock; -#endif - int refId; - FileFd fd; - FILE *fp; -} * TdFilePtr, TdFile; - void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) { #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) const char *tdengineTmpFileNamePrefix = "tdengine-"; diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 698ceded16..e3b1015d88 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -17,7 +17,7 @@ #define ALLOW_FORBID_FUNC #include "os.h" -#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) +#if defined(WINDOWS) #include #include #include @@ -37,8 +37,14 @@ #include #include #include -#include #include + +#if defined(DARWIN) + #include + #include "osEok.h" +#else + #include +#endif #endif typedef int32_t SocketFd; @@ -210,7 +216,7 @@ int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer) { #endif } -#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) +#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 diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index d4bcc27f60..404c9c8f71 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -570,6 +570,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: case CFG_DTYPE_TIMEZONE: + case CFG_DTYPE_NONE: if (dump) { printf("%s %s %s", src, name, pItem->str); printf("\n"); @@ -655,4 +656,4 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { uInfo("load from apoll url %s", url); return 0; -} \ No newline at end of file +} diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c index 7bdcf3cc64..46bca6e6cb 100644 --- a/source/util/src/ttimer.c +++ b/source/util/src/ttimer.c @@ -628,7 +628,7 @@ void taosTmrCleanUp(void* handle) { tmrCtrls = NULL; unusedTmrCtrl = NULL; -#if !defined(WINDOWS) +#if defined(LINUX) tmrModuleInit = PTHREAD_ONCE_INIT; // to support restart #endif } -- GitLab