TD-992 cmake file for w64
This commit is contained in:
parent
d012c3eb8e
commit
ee82eb602c
|
|
@ -183,7 +183,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, in
|
||||||
pSupporter->uid = pTableMetaInfo->pTableMeta->id.uid;
|
pSupporter->uid = pTableMetaInfo->pTableMeta->id.uid;
|
||||||
assert (pSupporter->uid != 0);
|
assert (pSupporter->uid != 0);
|
||||||
|
|
||||||
getTmpfilePath("join-", pSupporter->path);
|
taosGetTmpfilePath("join-", pSupporter->path);
|
||||||
pSupporter->f = fopen(pSupporter->path, "w");
|
pSupporter->f = fopen(pSupporter->path, "w");
|
||||||
|
|
||||||
// todo handle error
|
// todo handle error
|
||||||
|
|
@ -773,7 +773,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
|
|
||||||
// continue to retrieve ts-comp data from vnode
|
// continue to retrieve ts-comp data from vnode
|
||||||
if (!pRes->completed) {
|
if (!pRes->completed) {
|
||||||
getTmpfilePath("ts-join", pSupporter->path);
|
taosGetTmpfilePath("ts-join", pSupporter->path);
|
||||||
pSupporter->f = fopen(pSupporter->path, "w");
|
pSupporter->f = fopen(pSupporter->path, "w");
|
||||||
pRes->row = pRes->numOfRows;
|
pRes->row = pRes->numOfRows;
|
||||||
|
|
||||||
|
|
@ -797,7 +797,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
tscResetForNextRetrieve(&pSql->res);
|
tscResetForNextRetrieve(&pSql->res);
|
||||||
|
|
||||||
assert(pSupporter->f == NULL);
|
assert(pSupporter->f == NULL);
|
||||||
getTmpfilePath("ts-join", pSupporter->path);
|
taosGetTmpfilePath("ts-join", pSupporter->path);
|
||||||
|
|
||||||
// TODO check for failure
|
// TODO check for failure
|
||||||
pSupporter->f = fopen(pSupporter->path, "w");
|
pSupporter->f = fopen(pSupporter->path, "w");
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ void taosRandStr(char* str, int32_t size);
|
||||||
uint32_t trand(void);
|
uint32_t trand(void);
|
||||||
|
|
||||||
// TAOS_OS_FUNC_FILE
|
// TAOS_OS_FUNC_FILE
|
||||||
void getTmpfilePath(const char *fileNamePrefix, char *dstPath);
|
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath);
|
||||||
int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstPath);
|
int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstPath);
|
||||||
|
|
||||||
// USE_LIBICONV
|
// USE_LIBICONV
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,68 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TAOS_OS_FUNC_WCHAR
|
#define TAOS_OS_FUNC_WCHAR
|
||||||
|
#define TAOS_OS_FUNC_FILE
|
||||||
|
#define TAOS_OS_FUNC_SLEEP
|
||||||
|
#define TAOS_OS_FUNC_TIMER
|
||||||
|
#define TAOS_OS_FUNC_SOCKET
|
||||||
|
#define TAOS_OS_FUNC_PTHREAD
|
||||||
|
|
||||||
|
#define TAOS_OS_FUNC_FILEOP
|
||||||
|
#define taosFSendFile(outfile, infile, offset, count) taosFSendFileImp(outfile, infile, offset, size)
|
||||||
|
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
|
||||||
|
|
||||||
|
#define TAOS_OS_FUNC_LZ4
|
||||||
|
int32_t BUILDIN_CLZL(uint64_t val);
|
||||||
|
int32_t BUILDIN_CLZ(uint32_t val);
|
||||||
|
int32_t BUILDIN_CTZL(uint64_t val);
|
||||||
|
int32_t BUILDIN_CTZ(uint32_t val);
|
||||||
|
|
||||||
|
#define TAOS_OS_FUNC_UTIL
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
int64_t tsosStr2int64(char *str);
|
||||||
|
uint64_t htonll(uint64_t val);
|
||||||
|
#else
|
||||||
|
#define tsosStr2int64 _atoi64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TAOS_OS_FUNC_MATH
|
||||||
|
#define SWAP(a, b, c) \
|
||||||
|
do { \
|
||||||
|
c __tmp = (c)(a); \
|
||||||
|
(a) = (c)(b); \
|
||||||
|
(b) = __tmp; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||||
|
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||||
|
|
||||||
|
#define TAOS_OS_FUNC_NETWORK
|
||||||
|
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
|
||||||
|
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, buf, len, flags, dest_addr, addrlen)
|
||||||
|
#define taosWriteSocket(fd, buf, len) send(fd, buf, len, 0)
|
||||||
|
#define taosReadSocket(fd, buf, len) recv(fd, buf, len, 0)
|
||||||
|
#define taosCloseSocket(fd) closesocket(fd)
|
||||||
|
|
||||||
|
#define TAOS_OS_DEF_TIME
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
#define MILLISECOND_PER_SECOND (1000LL)
|
||||||
|
#else
|
||||||
|
#define MILLISECOND_PER_SECOND (1000i64)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int (*__compar_fn_t)(const void *, const void *);
|
||||||
|
int getline(char **lineptr, size_t *n, FILE *stream);
|
||||||
|
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||||
|
struct tm *localtime_r(const time_t *timep, struct tm *result);
|
||||||
|
char * strptime(const char *buf, const char *fmt, struct tm *tm);
|
||||||
|
char * strsep(char **stringp, const char *delim);
|
||||||
|
char * getpass(const char *prefix);
|
||||||
|
int flock(int fd, int option);
|
||||||
|
int fsync(int filedes);
|
||||||
|
char * strndup(const char *s, size_t n);
|
||||||
|
|
||||||
|
#define strdup _strdup
|
||||||
|
#define ssize_t int
|
||||||
|
|
||||||
// for function open in stat.h
|
// for function open in stat.h
|
||||||
#define S_IRWXU _S_IREAD
|
#define S_IRWXU _S_IREAD
|
||||||
|
|
@ -79,12 +141,6 @@ extern "C" {
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define wcsncasecmp _wcsnicmp
|
#define wcsncasecmp _wcsnicmp
|
||||||
#define strtok_r strtok_s
|
#define strtok_r strtok_s
|
||||||
#ifdef _TD_GO_DLL_
|
|
||||||
int64_t tsosStr2int64(char *str);
|
|
||||||
uint64_t htonll(uint64_t val);
|
|
||||||
#else
|
|
||||||
#define tsosStr2int64 _atoi64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define in_addr_t unsigned long
|
#define in_addr_t unsigned long
|
||||||
|
|
@ -96,327 +152,212 @@ extern "C" {
|
||||||
#define PATH_MAX 256
|
#define PATH_MAX 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define taosCloseSocket(fd) closesocket(fd)
|
|
||||||
#define taosWriteSocket(fd, buf, len) send(fd, buf, len, 0)
|
|
||||||
#define taosReadSocket(fd, buf, len) recv(fd, buf, len, 0)
|
|
||||||
|
|
||||||
#if defined(_M_ARM) || defined(_M_ARM64)
|
|
||||||
|
|
||||||
/* the '__iso_volatile' functions does not use a memory fence, so these
|
|
||||||
* definitions are incorrect, comment out as we don't support Windows on
|
|
||||||
* ARM at present.
|
|
||||||
|
|
||||||
#define atomic_load_8(ptr) __iso_volatile_load8((const volatile __int8*)(ptr))
|
|
||||||
#define atomic_load_16(ptr) __iso_volatile_load16((const volatile __int16*)(ptr))
|
|
||||||
#define atomic_load_32(ptr) __iso_volatile_load32((const volatile __int32*)(ptr))
|
|
||||||
#define atomic_load_64(ptr) __iso_volatile_load64((const volatile __int64*)(ptr))
|
|
||||||
|
|
||||||
#define atomic_store_8(ptr, val) __iso_volatile_store8((volatile __int8*)(ptr), (__int8)(val))
|
|
||||||
#define atomic_store_16(ptr, val) __iso_volatile_store16((volatile __int16*)(ptr), (__int16)(val))
|
|
||||||
#define atomic_store_32(ptr, val) __iso_volatile_store32((volatile __int32*)(ptr), (__int32)(val))
|
|
||||||
#define atomic_store_64(ptr, val) __iso_volatile_store64((volatile __int64*)(ptr), (__int64)(val))
|
|
||||||
|
|
||||||
#ifdef _M_ARM64
|
|
||||||
#define atomic_load_ptr atomic_load_64
|
|
||||||
#define atomic_store_ptr atomic_store_64
|
|
||||||
#else
|
|
||||||
#define atomic_load_ptr atomic_load_32
|
|
||||||
#define atomic_store_ptr atomic_store_32
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define atomic_load_8(ptr) (*(char volatile*)(ptr))
|
|
||||||
#define atomic_load_16(ptr) (*(short volatile*)(ptr))
|
|
||||||
#define atomic_load_32(ptr) (*(long volatile*)(ptr))
|
|
||||||
#define atomic_load_64(ptr) (*(__int64 volatile*)(ptr))
|
|
||||||
#define atomic_load_ptr(ptr) (*(void* volatile*)(ptr))
|
|
||||||
|
|
||||||
#define atomic_store_8(ptr, val) ((*(char volatile*)(ptr)) = (char)(val))
|
|
||||||
#define atomic_store_16(ptr, val) ((*(short volatile*)(ptr)) = (short)(val))
|
|
||||||
#define atomic_store_32(ptr, val) ((*(long volatile*)(ptr)) = (long)(val))
|
|
||||||
#define atomic_store_64(ptr, val) ((*(__int64 volatile*)(ptr)) = (__int64)(val))
|
|
||||||
#define atomic_store_ptr(ptr, val) ((*(void* volatile*)(ptr)) = (void*)(val))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define atomic_exchange_8(ptr, val) _InterlockedExchange8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_exchange_16(ptr, val) _InterlockedExchange16((short volatile*)(ptr), (short)(val))
|
|
||||||
#define atomic_exchange_32(ptr, val) _InterlockedExchange((long volatile*)(ptr), (long)(val))
|
|
||||||
#define atomic_exchange_64(ptr, val) _InterlockedExchange64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#define atomic_exchange_ptr(ptr, val) _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val))
|
|
||||||
|
|
||||||
#ifdef _TD_GO_DLL_
|
|
||||||
#define atomic_val_compare_exchange_8 __sync_val_compare_and_swap
|
|
||||||
#else
|
|
||||||
#define atomic_val_compare_exchange_8(ptr, oldval, newval) _InterlockedCompareExchange8((char volatile*)(ptr), (char)(newval), (char)(oldval))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define atomic_val_compare_exchange_16(ptr, oldval, newval) _InterlockedCompareExchange16((short volatile*)(ptr), (short)(newval), (short)(oldval))
|
|
||||||
#define atomic_val_compare_exchange_32(ptr, oldval, newval) _InterlockedCompareExchange((long volatile*)(ptr), (long)(newval), (long)(oldval))
|
|
||||||
#define atomic_val_compare_exchange_64(ptr, oldval, newval) _InterlockedCompareExchange64((__int64 volatile*)(ptr), (__int64)(newval), (__int64)(oldval))
|
|
||||||
#define atomic_val_compare_exchange_ptr(ptr, oldval, newval) _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval))
|
|
||||||
|
|
||||||
char interlocked_add_fetch_8(char volatile *ptr, char val);
|
|
||||||
short interlocked_add_fetch_16(short volatile *ptr, short val);
|
|
||||||
long interlocked_add_fetch_32(long volatile *ptr, long val);
|
|
||||||
__int64 interlocked_add_fetch_64(__int64 volatile *ptr, __int64 val);
|
|
||||||
|
|
||||||
#define atomic_add_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_add_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), (short)(val))
|
|
||||||
#define atomic_add_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), (long)(val))
|
|
||||||
#define atomic_add_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_add_fetch_ptr atomic_add_fetch_64
|
|
||||||
#else
|
|
||||||
#define atomic_add_fetch_ptr atomic_add_fetch_32
|
|
||||||
#endif
|
|
||||||
#ifdef _TD_GO_DLL_
|
|
||||||
#define atomic_fetch_add_8 __sync_fetch_and_ad
|
|
||||||
#define atomic_fetch_add_16 __sync_fetch_and_add
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_add_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_fetch_add_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), (short)(val))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define atomic_fetch_add_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), (long)(val))
|
|
||||||
#define atomic_fetch_add_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_fetch_add_ptr atomic_fetch_add_64
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_add_ptr atomic_fetch_add_32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define atomic_sub_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), -(char)(val))
|
|
||||||
#define atomic_sub_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), -(short)(val))
|
|
||||||
#define atomic_sub_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), -(long)(val))
|
|
||||||
#define atomic_sub_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), -(__int64)(val))
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_sub_fetch_ptr atomic_sub_fetch_64
|
|
||||||
#else
|
|
||||||
#define atomic_sub_fetch_ptr atomic_sub_fetch_32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define atomic_fetch_sub_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), -(char)(val))
|
|
||||||
#define atomic_fetch_sub_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), -(short)(val))
|
|
||||||
#define atomic_fetch_sub_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), -(long)(val))
|
|
||||||
#define atomic_fetch_sub_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), -(__int64)(val))
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_fetch_sub_ptr atomic_fetch_sub_64
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_sub_ptr atomic_fetch_sub_32
|
|
||||||
#endif
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
char interlocked_and_fetch_8(char volatile* ptr, char val);
|
|
||||||
short interlocked_and_fetch_16(short volatile* ptr, short val);
|
|
||||||
#endif
|
|
||||||
long interlocked_and_fetch_32(long volatile* ptr, long val);
|
|
||||||
__int64 interlocked_and_fetch_64(__int64 volatile* ptr, __int64 val);
|
|
||||||
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
#define atomic_and_fetch_8(ptr, val) interlocked_and_fetch_8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_and_fetch_16(ptr, val) interlocked_and_fetch_16((short volatile*)(ptr), (short)(val))
|
|
||||||
#endif
|
|
||||||
#define atomic_and_fetch_32(ptr, val) interlocked_and_fetch_32((long volatile*)(ptr), (long)(val))
|
|
||||||
#define atomic_and_fetch_64(ptr, val) interlocked_and_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_and_fetch_ptr atomic_and_fetch_64
|
|
||||||
#else
|
|
||||||
#define atomic_and_fetch_ptr atomic_and_fetch_32
|
|
||||||
#endif
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
#define atomic_fetch_and_8(ptr, val) _InterlockedAnd8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_fetch_and_16(ptr, val) _InterlockedAnd16((short volatile*)(ptr), (short)(val))
|
|
||||||
#endif
|
|
||||||
#define atomic_fetch_and_32(ptr, val) _InterlockedAnd((long volatile*)(ptr), (long)(val))
|
|
||||||
|
|
||||||
#ifdef _M_IX86
|
|
||||||
__int64 interlocked_fetch_and_64(__int64 volatile* ptr, __int64 val);
|
|
||||||
#define atomic_fetch_and_64(ptr, val) interlocked_fetch_and_64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_and_64(ptr, val) _InterlockedAnd64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_fetch_and_ptr atomic_fetch_and_64
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_and_ptr atomic_fetch_and_32
|
|
||||||
#endif
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
char interlocked_or_fetch_8(char volatile* ptr, char val);
|
|
||||||
short interlocked_or_fetch_16(short volatile* ptr, short val);
|
|
||||||
#endif
|
|
||||||
long interlocked_or_fetch_32(long volatile* ptr, long val);
|
|
||||||
__int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val);
|
|
||||||
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
#define atomic_or_fetch_8(ptr, val) interlocked_or_fetch_8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_or_fetch_16(ptr, val) interlocked_or_fetch_16((short volatile*)(ptr), (short)(val))
|
|
||||||
#endif
|
|
||||||
#define atomic_or_fetch_32(ptr, val) interlocked_or_fetch_32((long volatile*)(ptr), (long)(val))
|
|
||||||
#define atomic_or_fetch_64(ptr, val) interlocked_or_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_or_fetch_ptr atomic_or_fetch_64
|
|
||||||
#else
|
|
||||||
#define atomic_or_fetch_ptr atomic_or_fetch_32
|
|
||||||
#endif
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
#define atomic_fetch_or_8(ptr, val) _InterlockedOr8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_fetch_or_16(ptr, val) _InterlockedOr16((short volatile*)(ptr), (short)(val))
|
|
||||||
#endif
|
|
||||||
#define atomic_fetch_or_32(ptr, val) _InterlockedOr((long volatile*)(ptr), (long)(val))
|
|
||||||
|
|
||||||
#ifdef _M_IX86
|
|
||||||
__int64 interlocked_fetch_or_64(__int64 volatile* ptr, __int64 val);
|
|
||||||
#define atomic_fetch_or_64(ptr, val) interlocked_fetch_or_64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_or_64(ptr, val) _InterlockedOr64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_fetch_or_ptr atomic_fetch_or_64
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_or_ptr atomic_fetch_or_32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
char interlocked_xor_fetch_8(char volatile* ptr, char val);
|
|
||||||
short interlocked_xor_fetch_16(short volatile* ptr, short val);
|
|
||||||
#endif
|
|
||||||
long interlocked_xor_fetch_32(long volatile* ptr, long val);
|
|
||||||
__int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val);
|
|
||||||
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
#define atomic_xor_fetch_8(ptr, val) interlocked_xor_fetch_8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_xor_fetch_16(ptr, val) interlocked_xor_fetch_16((short volatile*)(ptr), (short)(val))
|
|
||||||
#endif
|
|
||||||
#define atomic_xor_fetch_32(ptr, val) interlocked_xor_fetch_32((long volatile*)(ptr), (long)(val))
|
|
||||||
#define atomic_xor_fetch_64(ptr, val) interlocked_xor_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_xor_fetch_ptr atomic_xor_fetch_64
|
|
||||||
#else
|
|
||||||
#define atomic_xor_fetch_ptr atomic_xor_fetch_32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
#define atomic_fetch_xor_8(ptr, val) _InterlockedXor8((char volatile*)(ptr), (char)(val))
|
|
||||||
#define atomic_fetch_xor_16(ptr, val) _InterlockedXor16((short volatile*)(ptr), (short)(val))
|
|
||||||
#endif
|
|
||||||
#define atomic_fetch_xor_32(ptr, val) _InterlockedXor((long volatile*)(ptr), (long)(val))
|
|
||||||
|
|
||||||
#ifdef _M_IX86
|
|
||||||
__int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val);
|
|
||||||
#define atomic_fetch_xor_64(ptr, val) interlocked_fetch_xor_64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_xor_64(ptr, val) _InterlockedXor64((__int64 volatile*)(ptr), (__int64)(val))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_fetch_xor_ptr atomic_fetch_xor_64
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_xor_ptr atomic_fetch_xor_32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SWAP(a, b, c) \
|
|
||||||
do { \
|
|
||||||
c __tmp = (c)(a); \
|
|
||||||
(a) = (c)(b); \
|
|
||||||
(b) = __tmp; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
|
||||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
|
||||||
|
|
||||||
#ifdef _TD_GO_DLL_
|
|
||||||
#define MILLISECOND_PER_SECOND (1000LL)
|
|
||||||
#else
|
|
||||||
#define MILLISECOND_PER_SECOND (1000i64)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define tsem_t sem_t
|
|
||||||
#define tsem_init sem_init
|
|
||||||
#define tsem_wait sem_wait
|
|
||||||
#define tsem_post sem_post
|
|
||||||
#define tsem_destroy sem_destroy
|
|
||||||
|
|
||||||
void osInit();
|
|
||||||
|
|
||||||
int getline(char **lineptr, size_t *n, FILE *stream);
|
|
||||||
|
|
||||||
int taosWinSetTimer(int ms, void(*callback)(int));
|
|
||||||
|
|
||||||
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
|
||||||
|
|
||||||
struct tm *localtime_r(const time_t *timep, struct tm *result);
|
|
||||||
|
|
||||||
char *strptime(const char *buf, const char *fmt, struct tm *tm);
|
|
||||||
|
|
||||||
bool taosCheckPthreadValid(pthread_t thread);
|
|
||||||
|
|
||||||
void taosResetPthread(pthread_t *thread);
|
|
||||||
|
|
||||||
int64_t taosGetPthreadId();
|
|
||||||
|
|
||||||
int taosSetNonblocking(int sock, int on);
|
|
||||||
|
|
||||||
int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optlen);
|
|
||||||
|
|
||||||
|
|
||||||
void taosPrintOsInfo();
|
|
||||||
|
|
||||||
void taosGetSystemInfo();
|
|
||||||
|
|
||||||
void taosKillSystem();
|
|
||||||
|
|
||||||
int32_t BUILDIN_CLZL(uint64_t val);
|
|
||||||
int32_t BUILDIN_CLZ(uint32_t val);
|
|
||||||
int32_t BUILDIN_CTZL(uint64_t val);
|
|
||||||
int32_t BUILDIN_CTZ(uint32_t val);
|
|
||||||
|
|
||||||
//for signal, not dispose
|
//for signal, not dispose
|
||||||
#define SIGALRM 1234
|
#define SIGALRM 1234
|
||||||
typedef int sigset_t;
|
typedef int sigset_t;
|
||||||
|
|
||||||
struct sigaction {
|
struct sigaction {
|
||||||
void (*sa_handler)(int);
|
void (*sa_handler)(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int we_wordc;
|
|
||||||
char **we_wordv;
|
|
||||||
int we_offs;
|
|
||||||
char wordPos[20];
|
|
||||||
} wordexp_t;
|
|
||||||
|
|
||||||
int wordexp(const char *words, wordexp_t *pwordexp, int flags);
|
|
||||||
|
|
||||||
void wordfree(wordexp_t *pwordexp);
|
|
||||||
|
|
||||||
int flock(int fd, int option);
|
|
||||||
|
|
||||||
int fsync(int filedes);
|
|
||||||
|
|
||||||
char *getpass(const char *prefix);
|
|
||||||
|
|
||||||
char *strsep(char **stringp, const char *delim);
|
|
||||||
|
|
||||||
typedef int(*__compar_fn_t)(const void *, const void *);
|
|
||||||
|
|
||||||
int sigaction(int, struct sigaction *, void *);
|
int sigaction(int, struct sigaction *, void *);
|
||||||
|
|
||||||
void sleep(int mseconds);
|
typedef struct {
|
||||||
|
int we_wordc;
|
||||||
|
char **we_wordv;
|
||||||
|
int we_offs;
|
||||||
|
char wordPos[20];
|
||||||
|
} wordexp_t;
|
||||||
|
int wordexp(const char *words, wordexp_t *pwordexp, int flags);
|
||||||
|
void wordfree(wordexp_t *pwordexp);
|
||||||
|
|
||||||
bool taosSkipSocketCheck();
|
#define TAOS_OS_FUNC_ATOMIC
|
||||||
|
#define atomic_load_8(ptr) (*(char volatile*)(ptr))
|
||||||
|
#define atomic_load_16(ptr) (*(short volatile*)(ptr))
|
||||||
|
#define atomic_load_32(ptr) (*(long volatile*)(ptr))
|
||||||
|
#define atomic_load_64(ptr) (*(__int64 volatile*)(ptr))
|
||||||
|
#define atomic_load_ptr(ptr) (*(void* volatile*)(ptr))
|
||||||
|
|
||||||
int fsendfile(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count);
|
#define atomic_store_8(ptr, val) ((*(char volatile*)(ptr)) = (char)(val))
|
||||||
|
#define atomic_store_16(ptr, val) ((*(short volatile*)(ptr)) = (short)(val))
|
||||||
|
#define atomic_store_32(ptr, val) ((*(long volatile*)(ptr)) = (long)(val))
|
||||||
|
#define atomic_store_64(ptr, val) ((*(__int64 volatile*)(ptr)) = (__int64)(val))
|
||||||
|
#define atomic_store_ptr(ptr, val) ((*(void* volatile*)(ptr)) = (void*)(val))
|
||||||
|
|
||||||
#define ssize_t int
|
#define atomic_exchange_8(ptr, val) _InterlockedExchange8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_exchange_16(ptr, val) _InterlockedExchange16((short volatile*)(ptr), (short)(val))
|
||||||
|
#define atomic_exchange_32(ptr, val) _InterlockedExchange((long volatile*)(ptr), (long)(val))
|
||||||
|
#define atomic_exchange_64(ptr, val) _InterlockedExchange64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#define atomic_exchange_ptr(ptr, val) _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val))
|
||||||
|
|
||||||
#define strdup _strdup
|
#ifdef _TD_GO_DLL_
|
||||||
|
#define atomic_val_compare_exchange_8 __sync_val_compare_and_swap
|
||||||
|
#else
|
||||||
|
#define atomic_val_compare_exchange_8(ptr, oldval, newval) _InterlockedCompareExchange8((char volatile*)(ptr), (char)(newval), (char)(oldval))
|
||||||
|
#endif
|
||||||
|
#define atomic_val_compare_exchange_16(ptr, oldval, newval) _InterlockedCompareExchange16((short volatile*)(ptr), (short)(newval), (short)(oldval))
|
||||||
|
#define atomic_val_compare_exchange_32(ptr, oldval, newval) _InterlockedCompareExchange((long volatile*)(ptr), (long)(newval), (long)(oldval))
|
||||||
|
#define atomic_val_compare_exchange_64(ptr, oldval, newval) _InterlockedCompareExchange64((__int64 volatile*)(ptr), (__int64)(newval), (__int64)(oldval))
|
||||||
|
#define atomic_val_compare_exchange_ptr(ptr, oldval, newval) _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval))
|
||||||
|
|
||||||
char *strndup(const char *s, size_t n);
|
char interlocked_add_fetch_8(char volatile *ptr, char val);
|
||||||
|
short interlocked_add_fetch_16(short volatile *ptr, short val);
|
||||||
|
long interlocked_add_fetch_32(long volatile *ptr, long val);
|
||||||
|
__int64 interlocked_add_fetch_64(__int64 volatile *ptr, __int64 val);
|
||||||
|
|
||||||
void taosSetCoreDump();
|
#define atomic_add_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_add_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), (short)(val))
|
||||||
|
#define atomic_add_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), (long)(val))
|
||||||
|
#define atomic_add_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_add_fetch_ptr atomic_add_fetch_64
|
||||||
|
#else
|
||||||
|
#define atomic_add_fetch_ptr atomic_add_fetch_32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
#define atomic_fetch_add_8 __sync_fetch_and_ad
|
||||||
|
#define atomic_fetch_add_16 __sync_fetch_and_add
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_add_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_fetch_add_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), (short)(val))
|
||||||
|
#endif
|
||||||
|
#define atomic_fetch_add_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), (long)(val))
|
||||||
|
#define atomic_fetch_add_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_fetch_add_ptr atomic_fetch_add_64
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_add_ptr atomic_fetch_add_32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define atomic_sub_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), -(char)(val))
|
||||||
|
#define atomic_sub_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), -(short)(val))
|
||||||
|
#define atomic_sub_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), -(long)(val))
|
||||||
|
#define atomic_sub_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), -(__int64)(val))
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_sub_fetch_ptr atomic_sub_fetch_64
|
||||||
|
#else
|
||||||
|
#define atomic_sub_fetch_ptr atomic_sub_fetch_32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define atomic_fetch_sub_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), -(char)(val))
|
||||||
|
#define atomic_fetch_sub_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), -(short)(val))
|
||||||
|
#define atomic_fetch_sub_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), -(long)(val))
|
||||||
|
#define atomic_fetch_sub_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), -(__int64)(val))
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_fetch_sub_ptr atomic_fetch_sub_64
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_sub_ptr atomic_fetch_sub_32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
char interlocked_and_fetch_8(char volatile* ptr, char val);
|
||||||
|
short interlocked_and_fetch_16(short volatile* ptr, short val);
|
||||||
|
#endif
|
||||||
|
long interlocked_and_fetch_32(long volatile* ptr, long val);
|
||||||
|
__int64 interlocked_and_fetch_64(__int64 volatile* ptr, __int64 val);
|
||||||
|
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
#define atomic_and_fetch_8(ptr, val) interlocked_and_fetch_8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_and_fetch_16(ptr, val) interlocked_and_fetch_16((short volatile*)(ptr), (short)(val))
|
||||||
|
#endif
|
||||||
|
#define atomic_and_fetch_32(ptr, val) interlocked_and_fetch_32((long volatile*)(ptr), (long)(val))
|
||||||
|
#define atomic_and_fetch_64(ptr, val) interlocked_and_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_and_fetch_ptr atomic_and_fetch_64
|
||||||
|
#else
|
||||||
|
#define atomic_and_fetch_ptr atomic_and_fetch_32
|
||||||
|
#endif
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
#define atomic_fetch_and_8(ptr, val) _InterlockedAnd8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_fetch_and_16(ptr, val) _InterlockedAnd16((short volatile*)(ptr), (short)(val))
|
||||||
|
#endif
|
||||||
|
#define atomic_fetch_and_32(ptr, val) _InterlockedAnd((long volatile*)(ptr), (long)(val))
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
|
__int64 interlocked_fetch_and_64(__int64 volatile* ptr, __int64 val);
|
||||||
|
#define atomic_fetch_and_64(ptr, val) interlocked_fetch_and_64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_and_64(ptr, val) _InterlockedAnd64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_fetch_and_ptr atomic_fetch_and_64
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_and_ptr atomic_fetch_and_32
|
||||||
|
#endif
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
char interlocked_or_fetch_8(char volatile* ptr, char val);
|
||||||
|
short interlocked_or_fetch_16(short volatile* ptr, short val);
|
||||||
|
#endif
|
||||||
|
long interlocked_or_fetch_32(long volatile* ptr, long val);
|
||||||
|
__int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val);
|
||||||
|
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
#define atomic_or_fetch_8(ptr, val) interlocked_or_fetch_8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_or_fetch_16(ptr, val) interlocked_or_fetch_16((short volatile*)(ptr), (short)(val))
|
||||||
|
#endif
|
||||||
|
#define atomic_or_fetch_32(ptr, val) interlocked_or_fetch_32((long volatile*)(ptr), (long)(val))
|
||||||
|
#define atomic_or_fetch_64(ptr, val) interlocked_or_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_or_fetch_ptr atomic_or_fetch_64
|
||||||
|
#else
|
||||||
|
#define atomic_or_fetch_ptr atomic_or_fetch_32
|
||||||
|
#endif
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
#define atomic_fetch_or_8(ptr, val) _InterlockedOr8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_fetch_or_16(ptr, val) _InterlockedOr16((short volatile*)(ptr), (short)(val))
|
||||||
|
#endif
|
||||||
|
#define atomic_fetch_or_32(ptr, val) _InterlockedOr((long volatile*)(ptr), (long)(val))
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
|
__int64 interlocked_fetch_or_64(__int64 volatile* ptr, __int64 val);
|
||||||
|
#define atomic_fetch_or_64(ptr, val) interlocked_fetch_or_64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_or_64(ptr, val) _InterlockedOr64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_fetch_or_ptr atomic_fetch_or_64
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_or_ptr atomic_fetch_or_32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
char interlocked_xor_fetch_8(char volatile* ptr, char val);
|
||||||
|
short interlocked_xor_fetch_16(short volatile* ptr, short val);
|
||||||
|
#endif
|
||||||
|
long interlocked_xor_fetch_32(long volatile* ptr, long val);
|
||||||
|
__int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val);
|
||||||
|
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
#define atomic_xor_fetch_8(ptr, val) interlocked_xor_fetch_8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_xor_fetch_16(ptr, val) interlocked_xor_fetch_16((short volatile*)(ptr), (short)(val))
|
||||||
|
#endif
|
||||||
|
#define atomic_xor_fetch_32(ptr, val) interlocked_xor_fetch_32((long volatile*)(ptr), (long)(val))
|
||||||
|
#define atomic_xor_fetch_64(ptr, val) interlocked_xor_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_xor_fetch_ptr atomic_xor_fetch_64
|
||||||
|
#else
|
||||||
|
#define atomic_xor_fetch_ptr atomic_xor_fetch_32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
#define atomic_fetch_xor_8(ptr, val) _InterlockedXor8((char volatile*)(ptr), (char)(val))
|
||||||
|
#define atomic_fetch_xor_16(ptr, val) _InterlockedXor16((short volatile*)(ptr), (short)(val))
|
||||||
|
#endif
|
||||||
|
#define atomic_fetch_xor_32(ptr, val) _InterlockedXor((long volatile*)(ptr), (long)(val))
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
|
__int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val);
|
||||||
|
#define atomic_fetch_xor_64(ptr, val) interlocked_fetch_xor_64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_xor_64(ptr, val) _InterlockedXor64((__int64 volatile*)(ptr), (__int64)(val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define atomic_fetch_xor_ptr atomic_fetch_xor_64
|
||||||
|
#else
|
||||||
|
#define atomic_fetch_xor_ptr atomic_fetch_xor_32
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#ifndef TAOS_OS_FUNC_FILE
|
#ifndef TAOS_OS_FUNC_FILE
|
||||||
|
|
||||||
void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
||||||
const char* tdengineTmpFileNamePrefix = "tdengine-";
|
const char* tdengineTmpFileNamePrefix = "tdengine-";
|
||||||
|
|
||||||
char tmpPath[PATH_MAX];
|
char tmpPath[PATH_MAX];
|
||||||
|
|
@ -37,6 +37,8 @@ void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
||||||
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand);
|
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// rename file name
|
// rename file name
|
||||||
int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstPath) {
|
int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstPath) {
|
||||||
int32_t ts = taosGetTimestampSec();
|
int32_t ts = taosGetTimestampSec();
|
||||||
|
|
@ -64,5 +66,3 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
|
||||||
|
|
||||||
return rename(fullPath, *dstPath);
|
return rename(fullPath, *dstPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -102,6 +102,7 @@ void taosUninitTimer() {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TAOS_OS_FUNC_SLEEP
|
||||||
/*
|
/*
|
||||||
to make taosMsleep work,
|
to make taosMsleep work,
|
||||||
signal SIGALRM shall be blocked in the calling thread,
|
signal SIGALRM shall be blocked in the calling thread,
|
||||||
|
|
@ -128,4 +129,6 @@ void taosMsleep(int mseconds) {
|
||||||
select(0, NULL, NULL, NULL, &timeout);
|
select(0, NULL, NULL, NULL, &timeout);
|
||||||
|
|
||||||
/* pthread_sigmask(SIG_UNBLOCK, &set, NULL); */
|
/* pthread_sigmask(SIG_UNBLOCK, &set, NULL); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,410 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
#include "os.h"
|
|
||||||
#include "taosdef.h"
|
|
||||||
#include "tglobal.h"
|
|
||||||
#include "ttimer.h"
|
|
||||||
#include "tulog.h"
|
|
||||||
#include "tutil.h"
|
|
||||||
|
|
||||||
bool taosCheckPthreadValid(pthread_t thread) {
|
|
||||||
return thread.p != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosResetPthread(pthread_t *thread) {
|
|
||||||
thread->p = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t taosGetPthreadId() {
|
|
||||||
#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) {
|
|
||||||
if (level == SOL_SOCKET && optname == TCP_KEEPCNT) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (level == SOL_TCP && optname == TCP_KEEPIDLE) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (level == SOL_TCP && optname == TCP_KEEPINTVL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return setsockopt(socketfd, level, optname, optval, optlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add
|
|
||||||
char interlocked_add_fetch_8(char volatile* ptr, char val) {
|
|
||||||
#ifdef _TD_GO_DLL_
|
|
||||||
return __sync_fetch_and_add(ptr, val) + val;
|
|
||||||
#else
|
|
||||||
return _InterlockedExchangeAdd8(ptr, val) + val;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
short interlocked_add_fetch_16(short volatile* ptr, short val) {
|
|
||||||
#ifdef _TD_GO_DLL_
|
|
||||||
return __sync_fetch_and_add(ptr, val) + val;
|
|
||||||
#else
|
|
||||||
return _InterlockedExchangeAdd16(ptr, val) + val;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
long interlocked_add_fetch_32(long volatile* ptr, long val) {
|
|
||||||
return _InterlockedExchangeAdd(ptr, val) + val;
|
|
||||||
}
|
|
||||||
|
|
||||||
__int64 interlocked_add_fetch_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
return _InterlockedExchangeAdd64(ptr, val) + val;
|
|
||||||
}
|
|
||||||
|
|
||||||
// and
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
char interlocked_and_fetch_8(char volatile* ptr, char val) {
|
|
||||||
return _InterlockedAnd8(ptr, val) & val;
|
|
||||||
}
|
|
||||||
|
|
||||||
short interlocked_and_fetch_16(short volatile* ptr, short val) {
|
|
||||||
return _InterlockedAnd16(ptr, val) & val;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
long interlocked_and_fetch_32(long volatile* ptr, long val) {
|
|
||||||
return _InterlockedAnd(ptr, val) & val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef _M_IX86
|
|
||||||
|
|
||||||
__int64 interlocked_and_fetch_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
return _InterlockedAnd64(ptr, val) & val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
__int64 interlocked_and_fetch_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
__int64 old, res;
|
|
||||||
do {
|
|
||||||
old = *ptr;
|
|
||||||
res = old & val;
|
|
||||||
} while(_InterlockedCompareExchange64(ptr, res, old) != old);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
__int64 interlocked_fetch_and_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
__int64 old;
|
|
||||||
do {
|
|
||||||
old = *ptr;
|
|
||||||
} while(_InterlockedCompareExchange64(ptr, old & val, old) != old);
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// or
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
char interlocked_or_fetch_8(char volatile* ptr, char val) {
|
|
||||||
return _InterlockedOr8(ptr, val) | val;
|
|
||||||
}
|
|
||||||
|
|
||||||
short interlocked_or_fetch_16(short volatile* ptr, short val) {
|
|
||||||
return _InterlockedOr16(ptr, val) | val;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
long interlocked_or_fetch_32(long volatile* ptr, long val) {
|
|
||||||
return _InterlockedOr(ptr, val) | val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef _M_IX86
|
|
||||||
|
|
||||||
__int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
return _InterlockedOr64(ptr, val) & val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
__int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
__int64 old, res;
|
|
||||||
do {
|
|
||||||
old = *ptr;
|
|
||||||
res = old | val;
|
|
||||||
} while(_InterlockedCompareExchange64(ptr, res, old) != old);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
__int64 interlocked_fetch_or_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
__int64 old;
|
|
||||||
do {
|
|
||||||
old = *ptr;
|
|
||||||
} while(_InterlockedCompareExchange64(ptr, old | val, old) != old);
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// xor
|
|
||||||
#ifndef _TD_GO_DLL_
|
|
||||||
char interlocked_xor_fetch_8(char volatile* ptr, char val) {
|
|
||||||
return _InterlockedXor8(ptr, val) ^ val;
|
|
||||||
}
|
|
||||||
|
|
||||||
short interlocked_xor_fetch_16(short volatile* ptr, short val) {
|
|
||||||
return _InterlockedXor16(ptr, val) ^ val;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
long interlocked_xor_fetch_32(long volatile* ptr, long val) {
|
|
||||||
return _InterlockedXor(ptr, val) ^ val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef _M_IX86
|
|
||||||
|
|
||||||
__int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
return _InterlockedXor64(ptr, val) ^ val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
__int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
__int64 old, res;
|
|
||||||
do {
|
|
||||||
old = *ptr;
|
|
||||||
res = old ^ val;
|
|
||||||
} while(_InterlockedCompareExchange64(ptr, res, old) != old);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
__int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val) {
|
|
||||||
__int64 old;
|
|
||||||
do {
|
|
||||||
old = *ptr;
|
|
||||||
} while(_InterlockedCompareExchange64(ptr, old ^ val, old) != old);
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void taosPrintOsInfo() {}
|
|
||||||
|
|
||||||
void taosGetSystemTimezone() {
|
|
||||||
// get and set default timezone
|
|
||||||
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
|
|
||||||
if (cfg_timezone && cfg_timezone->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
|
||||||
char *tz = getenv("TZ");
|
|
||||||
if (tz == NULL || strlen(tz) == 0) {
|
|
||||||
strcpy(tsTimezone, "not configured");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
strcpy(tsTimezone, tz);
|
|
||||||
}
|
|
||||||
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
|
||||||
uInfo("timezone not configured, use default");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosGetSystemLocale() {
|
|
||||||
// get and set default locale
|
|
||||||
SGlobalCfg *cfg_locale = taosGetConfigOption("locale");
|
|
||||||
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
|
||||||
char *locale = setlocale(LC_CTYPE, "chs");
|
|
||||||
if (locale != NULL) {
|
|
||||||
tstrncpy(tsLocale, locale, sizeof(tsLocale));
|
|
||||||
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
|
||||||
uInfo("locale not configured, set to default:%s", tsLocale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SGlobalCfg *cfg_charset = taosGetConfigOption("charset");
|
|
||||||
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
|
||||||
strcpy(tsCharset, "cp936");
|
|
||||||
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
|
||||||
uInfo("charset not configured, set to default:%s", tsCharset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosGetSystemInfo() {
|
|
||||||
taosGetSystemTimezone();
|
|
||||||
taosGetSystemLocale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosKillSystem() {
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get next token from string *stringp, where tokens are possibly-empty
|
|
||||||
* strings separated by characters from delim.
|
|
||||||
*
|
|
||||||
* Writes NULs into the string at *stringp to end tokens.
|
|
||||||
* delim need not remain constant from call to call.
|
|
||||||
* On return, *stringp points past the last NUL written (if there might
|
|
||||||
* be further tokens), or is NULL (if there are definitely no moretokens).
|
|
||||||
*
|
|
||||||
* If *stringp is NULL, strsep returns NULL.
|
|
||||||
*/
|
|
||||||
char *strsep(char **stringp, const char *delim) {
|
|
||||||
char *s;
|
|
||||||
const char *spanp;
|
|
||||||
int c, sc;
|
|
||||||
char *tok;
|
|
||||||
if ((s = *stringp) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
for (tok = s;;) {
|
|
||||||
c = *s++;
|
|
||||||
spanp = delim;
|
|
||||||
do {
|
|
||||||
if ((sc = *spanp++) == c) {
|
|
||||||
if (c == 0)
|
|
||||||
s = NULL;
|
|
||||||
else
|
|
||||||
s[-1] = 0;
|
|
||||||
*stringp = s;
|
|
||||||
return (tok);
|
|
||||||
}
|
|
||||||
} while (sc != 0);
|
|
||||||
}
|
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
|
||||||
|
|
||||||
char *getpass(const char *prefix) {
|
|
||||||
static char passwd[TSDB_KEY_LEN] = {0};
|
|
||||||
|
|
||||||
printf("%s", prefix);
|
|
||||||
scanf("%s", passwd);
|
|
||||||
|
|
||||||
char n = getchar();
|
|
||||||
return passwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
int flock(int fd, int option) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fsync(int filedes) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sigaction(int sig, struct sigaction *d, void *p) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wordexp(const char *words, wordexp_t *pwordexp, int flags) {
|
|
||||||
pwordexp->we_offs = 0;
|
|
||||||
pwordexp->we_wordc = 1;
|
|
||||||
pwordexp->we_wordv = (char **)(pwordexp->wordPos);
|
|
||||||
pwordexp->we_wordv[0] = (char *)words;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wordfree(wordexp_t *pwordexp) {}
|
|
||||||
|
|
||||||
void taosGetDisk() {}
|
|
||||||
|
|
||||||
bool taosSkipSocketCheck() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _SEND_FILE_STEP_ 1000
|
|
||||||
|
|
||||||
int fsendfile(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count) {
|
|
||||||
fseek(in_file, (int32_t)(*offset), 0);
|
|
||||||
int writeLen = 0;
|
|
||||||
uint8_t buffer[_SEND_FILE_STEP_] = { 0 };
|
|
||||||
|
|
||||||
for (int len = 0; len < (count - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
|
||||||
size_t rlen = fread(buffer, 1, _SEND_FILE_STEP_, in_file);
|
|
||||||
if (rlen <= 0) {
|
|
||||||
return writeLen;
|
|
||||||
}
|
|
||||||
else if (rlen < _SEND_FILE_STEP_) {
|
|
||||||
fwrite(buffer, 1, rlen, out_file);
|
|
||||||
return (int)(writeLen + rlen);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fwrite(buffer, 1, _SEND_FILE_STEP_, in_file);
|
|
||||||
writeLen += _SEND_FILE_STEP_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int remain = count - writeLen;
|
|
||||||
if (remain > 0) {
|
|
||||||
size_t rlen = fread(buffer, 1, remain, in_file);
|
|
||||||
if (rlen <= 0) {
|
|
||||||
return writeLen;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fwrite(buffer, 1, remain, out_file);
|
|
||||||
writeLen += remain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return writeLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t BUILDIN_CLZL(uint64_t val) {
|
|
||||||
unsigned long r = 0;
|
|
||||||
_BitScanReverse64(&r, val);
|
|
||||||
return (int)(r >> 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t BUILDIN_CLZ(uint32_t val) {
|
|
||||||
unsigned long r = 0;
|
|
||||||
_BitScanReverse(&r, val);
|
|
||||||
return (int)(r >> 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t BUILDIN_CTZL(uint64_t val) {
|
|
||||||
unsigned long r = 0;
|
|
||||||
_BitScanForward64(&r, val);
|
|
||||||
return (int)(r >> 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t BUILDIN_CTZ(uint32_t val) {
|
|
||||||
unsigned long r = 0;
|
|
||||||
_BitScanForward(&r, val);
|
|
||||||
return (int)(r >> 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *strndup(const char *s, size_t n) {
|
|
||||||
int len = strlen(s);
|
|
||||||
if (len >= n) {
|
|
||||||
len = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *r = calloc(len + 1, 1);
|
|
||||||
memcpy(r, s, len);
|
|
||||||
r[len] = 0;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosSetCoreDump() {}
|
|
||||||
|
|
||||||
#ifdef _TD_GO_DLL_
|
|
||||||
int64_t tsosStr2int64(char *str) {
|
|
||||||
char *endptr = NULL;
|
|
||||||
return strtoll(str, &endptr, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t htonll(uint64_t val)
|
|
||||||
{
|
|
||||||
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <WS2tcpip.h>
|
|
||||||
#include <IPHlpApi.h>
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ws2def.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
void taosWinSocketInit() {
|
|
||||||
static char flag = 0;
|
|
||||||
if (flag == 0) {
|
|
||||||
WORD wVersionRequested;
|
|
||||||
WSADATA wsaData;
|
|
||||||
wVersionRequested = MAKEWORD(1, 1);
|
|
||||||
if (WSAStartup(wVersionRequested, &wsaData) == 0) {
|
|
||||||
flag = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int taosSetNonblocking(SOCKET sock, int on) {
|
|
||||||
u_long mode;
|
|
||||||
if (on) {
|
|
||||||
mode = 1;
|
|
||||||
ioctlsocket(sock, FIONBIO, &mode);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mode = 0;
|
|
||||||
ioctlsocket(sock, FIONBIO, &mode);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int taosGetPrivateIp(char *const ip) {
|
|
||||||
PIP_ADAPTER_ADDRESSES pAddresses = 0;
|
|
||||||
IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = 0;
|
|
||||||
ULONG outBufLen = 0;
|
|
||||||
DWORD dwRetVal = 0;
|
|
||||||
char buff[100];
|
|
||||||
DWORD bufflen = 100;
|
|
||||||
int i;
|
|
||||||
int flag = -1;
|
|
||||||
|
|
||||||
taosWinSocketInit();
|
|
||||||
GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAddresses, &outBufLen);
|
|
||||||
pAddresses = (IP_ADAPTER_ADDRESSES *)malloc(outBufLen);
|
|
||||||
if ((dwRetVal = GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_ANYCAST, NULL, pAddresses, &outBufLen)) == NO_ERROR) {
|
|
||||||
while (pAddresses) {
|
|
||||||
if (wcsstr(pAddresses->FriendlyName, L"Loopback") != 0) {
|
|
||||||
pAddresses = pAddresses->Next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (pAddresses->OperStatus == IfOperStatusUp) {
|
|
||||||
//printf("%s, Status: active\n", pAddresses->FriendlyName);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//printf("%s, Status: deactive\n", pAddresses->FriendlyName);
|
|
||||||
pAddresses = pAddresses->Next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = pAddresses->FirstUnicastAddress;
|
|
||||||
for (i = 0; pUnicast != NULL; i++) {
|
|
||||||
if (pUnicast->Address.lpSockaddr->sa_family == AF_INET) {
|
|
||||||
struct sockaddr_in *sa_in = (struct sockaddr_in *)pUnicast->Address.lpSockaddr;
|
|
||||||
strcpy(ip, inet_ntop(AF_INET, &(sa_in->sin_addr), buff, bufflen));
|
|
||||||
flag = 0;
|
|
||||||
//printf("%s\n", ip);
|
|
||||||
}
|
|
||||||
else if (pUnicast->Address.lpSockaddr->sa_family == AF_INET6) {
|
|
||||||
struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)pUnicast->Address.lpSockaddr;
|
|
||||||
strcpy(ip, inet_ntop(AF_INET6, &(sa_in6->sin6_addr), buff, bufflen));
|
|
||||||
flag = 0;
|
|
||||||
//printf("%s\n", ip);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
}
|
|
||||||
pUnicast = pUnicast->Next;
|
|
||||||
}
|
|
||||||
pAddresses = pAddresses->Next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LPVOID lpMsgBuf;
|
|
||||||
printf("Call to GetAdaptersAddresses failed.\n");
|
|
||||||
if (FormatMessage(
|
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL,
|
|
||||||
dwRetVal,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
||||||
(LPTSTR) & lpMsgBuf,
|
|
||||||
0,
|
|
||||||
NULL)) {
|
|
||||||
printf("\tError: %s", lpMsgBuf);
|
|
||||||
}
|
|
||||||
LocalFree(lpMsgBuf);
|
|
||||||
}
|
|
||||||
free(pAddresses);
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "tulog.h"
|
|
||||||
|
|
||||||
void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) {
|
|
||||||
tError("InitTcpClient not support in windows");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosCloseTcpClientConnection(void *chandle) {
|
|
||||||
tError("CloseTcpClientConnection not support in windows");
|
|
||||||
}
|
|
||||||
|
|
||||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
|
|
||||||
tError("OpenTcpClientConnection not support in windows");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
|
|
||||||
tError("SendTcpClientData not support in windows");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosCleanUpTcpClient(void *chandle) {
|
|
||||||
tError("SendTcpClientData not support in windows");
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,172 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
// add
|
||||||
|
char interlocked_add_fetch_8(char volatile* ptr, char val) {
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
return __sync_fetch_and_add(ptr, val) + val;
|
||||||
|
#else
|
||||||
|
return _InterlockedExchangeAdd8(ptr, val) + val;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
short interlocked_add_fetch_16(short volatile* ptr, short val) {
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
return __sync_fetch_and_add(ptr, val) + val;
|
||||||
|
#else
|
||||||
|
return _InterlockedExchangeAdd16(ptr, val) + val;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
long interlocked_add_fetch_32(long volatile* ptr, long val) {
|
||||||
|
return _InterlockedExchangeAdd(ptr, val) + val;
|
||||||
|
}
|
||||||
|
|
||||||
|
__int64 interlocked_add_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
return _InterlockedExchangeAdd64(ptr, val) + val;
|
||||||
|
}
|
||||||
|
|
||||||
|
// and
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
char interlocked_and_fetch_8(char volatile* ptr, char val) {
|
||||||
|
return _InterlockedAnd8(ptr, val) & val;
|
||||||
|
}
|
||||||
|
|
||||||
|
short interlocked_and_fetch_16(short volatile* ptr, short val) {
|
||||||
|
return _InterlockedAnd16(ptr, val) & val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
long interlocked_and_fetch_32(long volatile* ptr, long val) {
|
||||||
|
return _InterlockedAnd(ptr, val) & val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _M_IX86
|
||||||
|
|
||||||
|
__int64 interlocked_and_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
return _InterlockedAnd64(ptr, val) & val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
__int64 interlocked_and_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
__int64 old, res;
|
||||||
|
do {
|
||||||
|
old = *ptr;
|
||||||
|
res = old & val;
|
||||||
|
} while(_InterlockedCompareExchange64(ptr, res, old) != old);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
__int64 interlocked_fetch_and_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
__int64 old;
|
||||||
|
do {
|
||||||
|
old = *ptr;
|
||||||
|
} while(_InterlockedCompareExchange64(ptr, old & val, old) != old);
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// or
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
char interlocked_or_fetch_8(char volatile* ptr, char val) {
|
||||||
|
return _InterlockedOr8(ptr, val) | val;
|
||||||
|
}
|
||||||
|
|
||||||
|
short interlocked_or_fetch_16(short volatile* ptr, short val) {
|
||||||
|
return _InterlockedOr16(ptr, val) | val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
long interlocked_or_fetch_32(long volatile* ptr, long val) {
|
||||||
|
return _InterlockedOr(ptr, val) | val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _M_IX86
|
||||||
|
|
||||||
|
__int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
return _InterlockedOr64(ptr, val) & val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
__int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
__int64 old, res;
|
||||||
|
do {
|
||||||
|
old = *ptr;
|
||||||
|
res = old | val;
|
||||||
|
} while(_InterlockedCompareExchange64(ptr, res, old) != old);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
__int64 interlocked_fetch_or_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
__int64 old;
|
||||||
|
do {
|
||||||
|
old = *ptr;
|
||||||
|
} while(_InterlockedCompareExchange64(ptr, old | val, old) != old);
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// xor
|
||||||
|
#ifndef _TD_GO_DLL_
|
||||||
|
char interlocked_xor_fetch_8(char volatile* ptr, char val) {
|
||||||
|
return _InterlockedXor8(ptr, val) ^ val;
|
||||||
|
}
|
||||||
|
|
||||||
|
short interlocked_xor_fetch_16(short volatile* ptr, short val) {
|
||||||
|
return _InterlockedXor16(ptr, val) ^ val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
long interlocked_xor_fetch_32(long volatile* ptr, long val) {
|
||||||
|
return _InterlockedXor(ptr, val) ^ val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _M_IX86
|
||||||
|
|
||||||
|
__int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
return _InterlockedXor64(ptr, val) ^ val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
__int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
__int64 old, res;
|
||||||
|
do {
|
||||||
|
old = *ptr;
|
||||||
|
res = old ^ val;
|
||||||
|
} while(_InterlockedCompareExchange64(ptr, res, old) != old);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
__int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val) {
|
||||||
|
__int64 old;
|
||||||
|
do {
|
||||||
|
old = *ptr;
|
||||||
|
} while(_InterlockedCompareExchange64(ptr, old ^ val, old) != old);
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "tconfig.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tsystem.h"
|
||||||
|
|
||||||
|
void taosSetCoreDump() {}
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
||||||
const char* tdengineTmpFileNamePrefix = "tdengine-";
|
const char* tdengineTmpFileNamePrefix = "tdengine-";
|
||||||
char tmpPath[PATH_MAX];
|
char tmpPath[PATH_MAX];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
#define _SEND_FILE_STEP_ 1000
|
||||||
|
|
||||||
|
int taosTSendFileImp(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count) {
|
||||||
|
fseek(in_file, (int32_t)(*offset), 0);
|
||||||
|
int writeLen = 0;
|
||||||
|
uint8_t buffer[_SEND_FILE_STEP_] = { 0 };
|
||||||
|
|
||||||
|
for (int len = 0; len < (count - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
||||||
|
size_t rlen = fread(buffer, 1, _SEND_FILE_STEP_, in_file);
|
||||||
|
if (rlen <= 0) {
|
||||||
|
return writeLen;
|
||||||
|
}
|
||||||
|
else if (rlen < _SEND_FILE_STEP_) {
|
||||||
|
fwrite(buffer, 1, rlen, out_file);
|
||||||
|
return (int)(writeLen + rlen);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fwrite(buffer, 1, _SEND_FILE_STEP_, in_file);
|
||||||
|
writeLen += _SEND_FILE_STEP_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int remain = count - writeLen;
|
||||||
|
if (remain > 0) {
|
||||||
|
size_t rlen = fread(buffer, 1, remain, in_file);
|
||||||
|
if (rlen <= 0) {
|
||||||
|
return writeLen;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fwrite(buffer, 1, remain, out_file);
|
||||||
|
writeLen += remain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return writeLen;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
int64_t tsosStr2int64(char *str) {
|
||||||
|
char *endptr = NULL;
|
||||||
|
return strtoll(str, &endptr, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t htonll(uint64_t val)
|
||||||
|
{
|
||||||
|
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
int32_t BUILDIN_CLZL(uint64_t val) {
|
||||||
|
unsigned long r = 0;
|
||||||
|
_BitScanReverse64(&r, val);
|
||||||
|
return (int)(r >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t BUILDIN_CLZ(uint32_t val) {
|
||||||
|
unsigned long r = 0;
|
||||||
|
_BitScanReverse(&r, val);
|
||||||
|
return (int)(r >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t BUILDIN_CTZL(uint64_t val) {
|
||||||
|
unsigned long r = 0;
|
||||||
|
_BitScanForward64(&r, val);
|
||||||
|
return (int)(r >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t BUILDIN_CTZ(uint32_t val) {
|
||||||
|
unsigned long r = 0;
|
||||||
|
_BitScanForward(&r, val);
|
||||||
|
return (int)(r >> 3);
|
||||||
|
}
|
||||||
|
|
@ -16,42 +16,41 @@
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
|
||||||
void taosFreeMsgHdr(void *hdr) {
|
void taosFreeMsgHdr(void *hdr) {
|
||||||
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
||||||
free(msgHdr->lpBuffers);
|
free(msgHdr->lpBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
int taosMsgHdrSize(void *hdr) {
|
int taosMsgHdrSize(void *hdr) {
|
||||||
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
||||||
return msgHdr->dwBufferCount;
|
return msgHdr->dwBufferCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosSendMsgHdr(void *hdr, int fd) {
|
void taosSendMsgHdr(void *hdr, int fd) {
|
||||||
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
|
||||||
WSASendMsg(fd, msgHdr, 0, &len, 0, 0);
|
WSASendMsg(fd, msgHdr, 0, &len, 0, 0);
|
||||||
msgHdr->dwBufferCount = 0;
|
msgHdr->dwBufferCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosInitMsgHdr(void **hdr, void *dest, int maxPkts) {
|
void taosInitMsgHdr(void **hdr, void *dest, int maxPkts) {
|
||||||
WSAMSG *msgHdr = (WSAMSG *)malloc(sizeof(WSAMSG));
|
WSAMSG *msgHdr = (WSAMSG *)malloc(sizeof(WSAMSG));
|
||||||
memset(msgHdr, 0, sizeof(WSAMSG));
|
memset(msgHdr, 0, sizeof(WSAMSG));
|
||||||
*hdr = msgHdr;
|
*hdr = msgHdr;
|
||||||
|
|
||||||
// see ws2def.h
|
// see ws2def.h
|
||||||
// the size of LPSOCKADDR and sockaddr_in * is same, so it's safe
|
// the size of LPSOCKADDR and sockaddr_in * is same, so it's safe
|
||||||
msgHdr->name = (LPSOCKADDR)dest;
|
msgHdr->name = (LPSOCKADDR)dest;
|
||||||
msgHdr->namelen = sizeof(struct sockaddr_in);
|
msgHdr->namelen = sizeof(struct sockaddr_in);
|
||||||
int size = sizeof(WSABUF) * maxPkts;
|
int size = sizeof(WSABUF) * maxPkts;
|
||||||
msgHdr->lpBuffers = (LPWSABUF)malloc(size);
|
msgHdr->lpBuffers = (LPWSABUF)malloc(size);
|
||||||
memset(msgHdr->lpBuffers, 0, size);
|
memset(msgHdr->lpBuffers, 0, size);
|
||||||
msgHdr->dwBufferCount = 0;
|
msgHdr->dwBufferCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosSetMsgHdrData(void *hdr, char *data, int dataLen) {
|
void taosSetMsgHdrData(void *hdr, char *data, int dataLen) {
|
||||||
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
WSAMSG *msgHdr = (WSAMSG *)hdr;
|
||||||
msgHdr->lpBuffers[msgHdr->dwBufferCount].buf = data;
|
msgHdr->lpBuffers[msgHdr->dwBufferCount].buf = data;
|
||||||
msgHdr->lpBuffers[msgHdr->dwBufferCount].len = dataLen;
|
msgHdr->lpBuffers[msgHdr->dwBufferCount].len = dataLen;
|
||||||
msgHdr->dwBufferCount++;
|
msgHdr->dwBufferCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
bool taosCheckPthreadValid(pthread_t thread) { return thread.p != NULL; }
|
||||||
|
|
||||||
|
void taosResetPthread(pthread_t *thread) { thread->p = 0; }
|
||||||
|
|
||||||
|
int64_t taosGetPthreadId() {
|
||||||
|
#ifdef PTW32_VERSION
|
||||||
|
return pthread_getw32threadid_np(pthread_self());
|
||||||
|
#else
|
||||||
|
return (int64_t)pthread_self();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <WS2tcpip.h>
|
||||||
|
#include <IPHlpApi.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ws2def.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
void taosWinSocketInit() {
|
||||||
|
static char flag = 0;
|
||||||
|
if (flag == 0) {
|
||||||
|
WORD wVersionRequested;
|
||||||
|
WSADATA wsaData;
|
||||||
|
wVersionRequested = MAKEWORD(1, 1);
|
||||||
|
if (WSAStartup(wVersionRequested, &wsaData) == 0) {
|
||||||
|
flag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int taosSetNonblocking(SOCKET sock, int on) {
|
||||||
|
u_long mode;
|
||||||
|
if (on) {
|
||||||
|
mode = 1;
|
||||||
|
ioctlsocket(sock, FIONBIO, &mode);
|
||||||
|
} else {
|
||||||
|
mode = 0;
|
||||||
|
ioctlsocket(sock, FIONBIO, &mode);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void taosBlockSIGPIPE() {}
|
||||||
|
|
||||||
|
int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optlen) {
|
||||||
|
if (level == SOL_SOCKET && optname == TCP_KEEPCNT) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level == SOL_TCP && optname == TCP_KEEPIDLE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level == SOL_TCP && optname == TCP_KEEPINTVL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return setsockopt(socketfd, level, optname, optval, optlen);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get next token from string *stringp, where tokens are possibly-empty
|
||||||
|
* strings separated by characters from delim.
|
||||||
|
*
|
||||||
|
* Writes NULs into the string at *stringp to end tokens.
|
||||||
|
* delim need not remain constant from call to call.
|
||||||
|
* On return, *stringp points past the last NUL written (if there might
|
||||||
|
* be further tokens), or is NULL (if there are definitely no moretokens).
|
||||||
|
*
|
||||||
|
* If *stringp is NULL, strsep returns NULL.
|
||||||
|
*/
|
||||||
|
char *strsep(char **stringp, const char *delim) {
|
||||||
|
char *s;
|
||||||
|
const char *spanp;
|
||||||
|
int c, sc;
|
||||||
|
char *tok;
|
||||||
|
if ((s = *stringp) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
for (tok = s;;) {
|
||||||
|
c = *s++;
|
||||||
|
spanp = delim;
|
||||||
|
do {
|
||||||
|
if ((sc = *spanp++) == c) {
|
||||||
|
if (c == 0)
|
||||||
|
s = NULL;
|
||||||
|
else
|
||||||
|
s[-1] = 0;
|
||||||
|
*stringp = s;
|
||||||
|
return (tok);
|
||||||
|
}
|
||||||
|
} while (sc != 0);
|
||||||
|
}
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
|
||||||
|
char *getpass(const char *prefix) {
|
||||||
|
static char passwd[TSDB_KEY_LEN] = {0};
|
||||||
|
|
||||||
|
printf("%s", prefix);
|
||||||
|
scanf("%s", passwd);
|
||||||
|
|
||||||
|
char n = getchar();
|
||||||
|
return passwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *strndup(const char *s, size_t n) {
|
||||||
|
int len = strlen(s);
|
||||||
|
if (len >= n) {
|
||||||
|
len = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *r = calloc(len + 1, 1);
|
||||||
|
memcpy(r, s, len);
|
||||||
|
r[len] = 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
int64_t tsosStr2int64(char *str) {
|
||||||
|
char *endptr = NULL;
|
||||||
|
return strtoll(str, &endptr, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t htonll(uint64_t val)
|
||||||
|
{
|
||||||
|
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "tconfig.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
static void taosGetSystemTimezone() {
|
||||||
|
// get and set default timezone
|
||||||
|
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
|
||||||
|
if (cfg_timezone && cfg_timezone->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
||||||
|
char *tz = getenv("TZ");
|
||||||
|
if (tz == NULL || strlen(tz) == 0) {
|
||||||
|
strcpy(tsTimezone, "not configured");
|
||||||
|
} else {
|
||||||
|
strcpy(tsTimezone, tz);
|
||||||
|
}
|
||||||
|
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
||||||
|
uInfo("timezone not configured, use default");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosGetSystemLocale() {
|
||||||
|
// get and set default locale
|
||||||
|
SGlobalCfg *cfg_locale = taosGetConfigOption("locale");
|
||||||
|
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
||||||
|
char *locale = setlocale(LC_CTYPE, "chs");
|
||||||
|
if (locale != NULL) {
|
||||||
|
tstrncpy(tsLocale, locale, sizeof(tsLocale));
|
||||||
|
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
||||||
|
uInfo("locale not configured, set to default:%s", tsLocale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SGlobalCfg *cfg_charset = taosGetConfigOption("charset");
|
||||||
|
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
|
||||||
|
strcpy(tsCharset, "cp936");
|
||||||
|
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
|
||||||
|
uInfo("charset not configured, set to default:%s", tsCharset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void taosPrintOsInfo() {}
|
||||||
|
|
||||||
|
void taosKillSystem() {
|
||||||
|
uError("function taosKillSystem, exit!");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void taosGetSystemInfo() {
|
||||||
|
taosGetSystemTimezone();
|
||||||
|
taosGetSystemLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool taosGetDisk() { return true; }
|
||||||
|
|
||||||
|
bool taosGetProcIO(float *readKB, float *writeKB) {
|
||||||
|
*readKB = 0;
|
||||||
|
*writeKB = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool taosGetBandSpeed(float *bandSpeedKb) {
|
||||||
|
*bandSpeedKb = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
|
||||||
|
*sysCpuUsage = 0;
|
||||||
|
*procCpuUsage = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
|
*memoryUsedMB = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool taosGetSysMemory(float *memoryUsedMB) {
|
||||||
|
*memoryUsedMB = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int taosSystem(const char *cmd) {
|
||||||
|
uError("taosSystem not support");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int flock(int fd, int option) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fsync(int filedes) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sigaction(int sig, struct sigaction *d, void *p) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -22,8 +22,7 @@
|
||||||
|
|
||||||
typedef void (*win_timer_f)(int signo);
|
typedef void (*win_timer_f)(int signo);
|
||||||
|
|
||||||
void WINAPI taosWinOnTimer(UINT wTimerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dwl, DWORD_PTR dw2)
|
void WINAPI taosWinOnTimer(UINT wTimerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dwl, DWORD_PTR dw2) {
|
||||||
{
|
|
||||||
win_timer_f callback = *((win_timer_f *)&dwUser);
|
win_timer_f callback = *((win_timer_f *)&dwUser);
|
||||||
if (callback != NULL) {
|
if (callback != NULL) {
|
||||||
callback(0);
|
callback(0);
|
||||||
|
|
@ -48,7 +47,3 @@ void taosUninitTimer() {
|
||||||
void taosMsleep(int mseconds) {
|
void taosMsleep(int mseconds) {
|
||||||
Sleep(mseconds);
|
Sleep(mseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep(int mseconds) {
|
|
||||||
taosMsleep(mseconds);
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get next token from string *stringp, where tokens are possibly-empty
|
||||||
|
* strings separated by characters from delim.
|
||||||
|
*
|
||||||
|
* Writes NULs into the string at *stringp to end tokens.
|
||||||
|
* delim need not remain constant from call to call.
|
||||||
|
* On return, *stringp points past the last NUL written (if there might
|
||||||
|
* be further tokens), or is NULL (if there are definitely no moretokens).
|
||||||
|
*
|
||||||
|
* If *stringp is NULL, strsep returns NULL.
|
||||||
|
*/
|
||||||
|
char *strsep(char **stringp, const char *delim) {
|
||||||
|
char *s;
|
||||||
|
const char *spanp;
|
||||||
|
int c, sc;
|
||||||
|
char *tok;
|
||||||
|
if ((s = *stringp) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
for (tok = s;;) {
|
||||||
|
c = *s++;
|
||||||
|
spanp = delim;
|
||||||
|
do {
|
||||||
|
if ((sc = *spanp++) == c) {
|
||||||
|
if (c == 0)
|
||||||
|
s = NULL;
|
||||||
|
else
|
||||||
|
s[-1] = 0;
|
||||||
|
*stringp = s;
|
||||||
|
return (tok);
|
||||||
|
}
|
||||||
|
} while (sc != 0);
|
||||||
|
}
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
|
||||||
|
char *getpass(const char *prefix) {
|
||||||
|
static char passwd[TSDB_KEY_LEN] = {0};
|
||||||
|
|
||||||
|
printf("%s", prefix);
|
||||||
|
scanf("%s", passwd);
|
||||||
|
|
||||||
|
char n = getchar();
|
||||||
|
return passwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
int flock(int fd, int option) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fsync(int filedes) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sigaction(int sig, struct sigaction *d, void *p) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wordexp(const char *words, wordexp_t *pwordexp, int flags) {
|
||||||
|
pwordexp->we_offs = 0;
|
||||||
|
pwordexp->we_wordc = 1;
|
||||||
|
pwordexp->we_wordv = (char **)(pwordexp->wordPos);
|
||||||
|
pwordexp->we_wordv[0] = (char *)words;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wordfree(wordexp_t *pwordexp) {}
|
||||||
|
|
||||||
|
|
||||||
|
char *strndup(const char *s, size_t n) {
|
||||||
|
int len = strlen(s);
|
||||||
|
if (len >= n) {
|
||||||
|
len = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *r = calloc(len + 1, 1);
|
||||||
|
memcpy(r, s, len);
|
||||||
|
r[len] = 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void taosSetCoreDump() {}
|
||||||
|
|
||||||
|
#ifdef _TD_GO_DLL_
|
||||||
|
int64_t tsosStr2int64(char *str) {
|
||||||
|
char *endptr = NULL;
|
||||||
|
return strtoll(str, &endptr, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t htonll(uint64_t val)
|
||||||
|
{
|
||||||
|
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -13,22 +13,21 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttimer.h"
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
|
||||||
void taosCloseTcpServerConnection(void *chandle) {
|
int wordexp(const char *words, wordexp_t *pwordexp, int flags) {
|
||||||
tError("CloseTcpServerConnection not support in windows");
|
pwordexp->we_offs = 0;
|
||||||
}
|
pwordexp->we_wordc = 1;
|
||||||
|
pwordexp->we_wordv = (char **)(pwordexp->wordPos);
|
||||||
void taosCleanUpTcpServer(void *handle) {
|
pwordexp->we_wordv[0] = (char *)words;
|
||||||
tError("CleanUpTcpServer not support in windows");
|
|
||||||
}
|
|
||||||
|
|
||||||
void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
|
|
||||||
tError("InitTcpServer not support in windows");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
|
void wordfree(wordexp_t *pwordexp) {}
|
||||||
tError("SendTcpServerData not support in windows");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -38,7 +38,7 @@ tExtMemBuffer* createExtMemBuffer(int32_t inMemSize, int32_t elemSize, int32_t p
|
||||||
pMemBuffer->numOfElemsPerPage = (pMemBuffer->pageSize - sizeof(tFilePage)) / pMemBuffer->nElemSize;
|
pMemBuffer->numOfElemsPerPage = (pMemBuffer->pageSize - sizeof(tFilePage)) / pMemBuffer->nElemSize;
|
||||||
|
|
||||||
char name[MAX_TMPFILE_PATH_LENGTH] = {0};
|
char name[MAX_TMPFILE_PATH_LENGTH] = {0};
|
||||||
getTmpfilePath("extbuf", name);
|
taosGetTmpfilePath("extbuf", name);
|
||||||
|
|
||||||
pMemBuffer->path = strdup(name);
|
pMemBuffer->path = strdup(name);
|
||||||
uDebug("create tmp file:%s", pMemBuffer->path);
|
uDebug("create tmp file:%s", pMemBuffer->path);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t ro
|
||||||
pResBuf->all = taosHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
|
pResBuf->all = taosHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
|
||||||
|
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
getTmpfilePath("qbuf", path);
|
taosGetTmpfilePath("qbuf", path);
|
||||||
pResBuf->path = strdup(path);
|
pResBuf->path = strdup(path);
|
||||||
|
|
||||||
pResBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
|
pResBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTmpfilePath("join", pTSBuf->path);
|
taosGetTmpfilePath("join", pTSBuf->path);
|
||||||
pTSBuf->f = fopen(pTSBuf->path, "w+");
|
pTSBuf->f = fopen(pTSBuf->path, "w+");
|
||||||
if (pTSBuf->f == NULL) {
|
if (pTSBuf->f == NULL) {
|
||||||
free(pTSBuf);
|
free(pTSBuf);
|
||||||
|
|
|
||||||
|
|
@ -766,7 +766,7 @@ TEST(testCase, getTempFilePath_test) {
|
||||||
char path[4096] = {0};
|
char path[4096] = {0};
|
||||||
memset(path, 1, 4096);
|
memset(path, 1, 4096);
|
||||||
|
|
||||||
getTmpfilePath("new_tmp", path);
|
taosGetTmpfilePath("new_tmp", path);
|
||||||
printf("%s\n", path);
|
printf("%s\n", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue