diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 3794a0a228ce9f5643159f7cd04d818af2b06e9f..f5911ca0c9e81eb3d51278cbf148014e07784125 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -7,4 +7,8 @@ ADD_SUBDIRECTORY(regex) ADD_SUBDIRECTORY(iconv) ADD_SUBDIRECTORY(lz4) ADD_SUBDIRECTORY(cJson) -ADD_SUBDIRECTORY(MQTT-C) +#ADD_SUBDIRECTORY(MsvcLibX) + +IF (NOT TD_WINDOWS) + ADD_SUBDIRECTORY(MQTT-C) +ENDIF () \ No newline at end of file diff --git a/deps/MQTT-C/CMakeLists.txt b/deps/MQTT-C/CMakeLists.txt index cb288a4193b140c6521c19c10e53ce6af9beac16..ea5d4238d57a87b9546510f1511869f1b68e7722 100644 --- a/deps/MQTT-C/CMakeLists.txt +++ b/deps/MQTT-C/CMakeLists.txt @@ -10,11 +10,11 @@ option(MQTT_C_TESTS "Build MQTT-C tests?" OFF) list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # MQTT-C library -add_library(mqttc STATIC +ADD_LIBRARY(mqttc STATIC src/mqtt_pal.c src/mqtt.c ) -target_include_directories(mqttc PUBLIC include) +TARGET_INCLUDE_DIRECTORIES(mqttc PUBLIC include) target_link_libraries(mqttc PUBLIC $<$:ws2_32> ) @@ -30,7 +30,7 @@ endif() # Configure with mbed TLS support if(MQTT_C_MbedTLS_SUPPORT) find_package(MbedTLS REQUIRED) - target_include_directories(mqttc PUBLIC ${MBEDTLS_INCLUDE_DIRS}) + TARGET_INCLUDE_DIRECTORIES(mqttc PUBLIC ${MBEDTLS_INCLUDE_DIRS}) target_link_libraries(mqttc INTERFACE ${MBEDTLS_LIBRARY}) target_compile_definitions(mqttc PUBLIC MQTT_USE_MBEDTLS) endif() @@ -70,7 +70,7 @@ if(MQTT_C_TESTS) add_executable(tests tests.c) target_link_libraries(tests ${CMOCKA_LIBRARY} mqttc) - target_include_directories(tests PRIVATE ${CMOCKA_INCLUDE_DIR}) + TARGET_INCLUDE_DIRECTORIES(tests PRIVATE ${CMOCKA_INCLUDE_DIR}) endif() # Install includes and library diff --git a/deps/cJson/CMakeLists.txt b/deps/cJson/CMakeLists.txt index 43b31589b30f9bddbdaac8ff2344545c289bc609..2fe197506581bbfd526ae08969211c20e4faff3d 100644 --- a/deps/cJson/CMakeLists.txt +++ b/deps/cJson/CMakeLists.txt @@ -1,4 +1,4 @@ -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) -add_library(cJson ${SOURCE_LIST}) -target_include_directories(cJson PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) \ No newline at end of file +ADD_LIBRARY(cJson ${SOURCE_LIST}) +TARGET_INCLUDE_DIRECTORIES(cJson PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) \ No newline at end of file diff --git a/deps/iconv/CMakeLists.txt b/deps/iconv/CMakeLists.txt index 944cb400e0c80a92f27aed159a4886ed25d9af6d..286070fa9071f8fcd1949850cec87c1ced3245d7 100644 --- a/deps/iconv/CMakeLists.txt +++ b/deps/iconv/CMakeLists.txt @@ -1,9 +1,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -IF (TD_WINDOWS_64) +IF (TD_WINDOWS) LIST(APPEND SRC iconv.c) LIST(APPEND SRC localcharset.c) INCLUDE_DIRECTORIES(.) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX-") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX-") ADD_LIBRARY(iconv ${SRC}) ENDIF () \ No newline at end of file diff --git a/deps/iconv/iconv.h b/deps/iconv/iconv.h index 83358ce987d582666569fe57a6379de4d3aa5f74..a461cef544317bfcaf0e8056025a0b997c8e63fd 100644 --- a/deps/iconv/iconv.h +++ b/deps/iconv/iconv.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2003, 2005-2006, 2008-2009 Free Software Foundation, Inc. +/* Copyright (C) 1999-2003, 2005-2006, 2008-2009 Free Software Foundation, Inc. This file is part of the GNU LIBICONV Library. The GNU LIBICONV Library is free software; you can redistribute it diff --git a/deps/lz4/CMakeLists.txt b/deps/lz4/CMakeLists.txt index a142d8d468c1674509de0df8d5625d7b8938869d..c3762ffe730bd9ec8c752e4e0415d0c41306dc77 100644 --- a/deps/lz4/CMakeLists.txt +++ b/deps/lz4/CMakeLists.txt @@ -1,4 +1,9 @@ -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) -add_library(lz4 ${SOURCE_LIST}) -target_include_directories(lz4 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) \ No newline at end of file +IF (TD_WINDOWS) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX-") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX-") +ENDIF() + +ADD_LIBRARY(lz4 ${SOURCE_LIST}) +TARGET_INCLUDE_DIRECTORIES(lz4 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) \ No newline at end of file diff --git a/deps/pthread/CMakeLists.txt b/deps/pthread/CMakeLists.txt index a218d05bab036685b5a3e2e86a75cc5af26eaee5..04e5be7472a9b8cbdb384348697b919bf2dd0ece 100644 --- a/deps/pthread/CMakeLists.txt +++ b/deps/pthread/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -IF (TD_WINDOWS_64) +IF (TD_WINDOWS) INCLUDE_DIRECTORIES(.) LIST(APPEND SRC pthread.c) ADD_LIBRARY(pthread ${SRC}) diff --git a/deps/pthread/pthread_mutex_consistent.c b/deps/pthread/pthread_mutex_consistent.c index 3e05635007e2d42106e65ebff8b6c8cd425e53ac..2d68213ce1bd6e1e119c94dbab99dd1a5af4fc51 100644 --- a/deps/pthread/pthread_mutex_consistent.c +++ b/deps/pthread/pthread_mutex_consistent.c @@ -1,4 +1,4 @@ -/* +/* * pthread_mutex_consistent.c * * Description: diff --git a/deps/regex/CMakeLists.txt b/deps/regex/CMakeLists.txt index 8f8396caa45f56ff5759b1f2cc55ae28086be6ab..054b093d07c386d7ff9b0ffc4c05909d79b33129 100644 --- a/deps/regex/CMakeLists.txt +++ b/deps/regex/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -IF (TD_WINDOWS_64) +IF (TD_WINDOWS) INCLUDE_DIRECTORIES(inc .) LIST(APPEND SRC regex.c) ADD_LIBRARY(regex ${SRC}) diff --git a/deps/zlib-1.2.11/CMakeLists.txt b/deps/zlib-1.2.11/CMakeLists.txt index c69e54a1b0ed9d7f5ed449f92d760ef3c197e73e..686e6fcff5c2c20815c97d6b976804b3c491527b 100644 --- a/deps/zlib-1.2.11/CMakeLists.txt +++ b/deps/zlib-1.2.11/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -IF (TD_LINUX_64) +IF (TD_LINUX_64 OR TD_WINDOWS_64) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(z ${SRC}) diff --git a/deps/zlib-1.2.11/inc/zconf.h b/deps/zlib-1.2.11/inc/zconf.h index 97b1e279ef33ff1414be4fb7657006d9b829ec9c..9b83d3a898662f8802154e4bd600cc2dde545756 100644 --- a/deps/zlib-1.2.11/inc/zconf.h +++ b/deps/zlib-1.2.11/inc/zconf.h @@ -14,177 +14,177 @@ * Even better than compiling with -DZ_PREFIX would be to use configure to set * this permanently in zconf.h using "./configure --zprefix". */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +#define Z_PREFIX_SET /* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion +#define _dist_code z__dist_code +#define _length_code z__length_code +#define _tr_align z__tr_align +#define _tr_flush_bits z__tr_flush_bits +#define _tr_flush_block z__tr_flush_block +#define _tr_init z__tr_init +#define _tr_stored_block z__tr_stored_block +#define _tr_tally z__tr_tally +#define adler32 z_adler32 +#define adler32_combine z_adler32_combine +#define adler32_combine64 z_adler32_combine64 +#define adler32_z z_adler32_z +#ifndef Z_SOLO +#define compress z_compress +#define compress2 z_compress2 +#define compressBound z_compressBound +#endif +#define crc32 z_crc32 +#define crc32_combine z_crc32_combine +#define crc32_combine64 z_crc32_combine64 +#define crc32_z z_crc32_z +#define deflate z_deflate +#define deflateBound z_deflateBound +#define deflateCopy z_deflateCopy +#define deflateEnd z_deflateEnd +#define deflateGetDictionary z_deflateGetDictionary +#define deflateInit z_deflateInit +#define deflateInit2 z_deflateInit2 +#define deflateInit2_ z_deflateInit2_ +#define deflateInit_ z_deflateInit_ +#define deflateParams z_deflateParams +#define deflatePending z_deflatePending +#define deflatePrime z_deflatePrime +#define deflateReset z_deflateReset +#define deflateResetKeep z_deflateResetKeep +#define deflateSetDictionary z_deflateSetDictionary +#define deflateSetHeader z_deflateSetHeader +#define deflateTune z_deflateTune +#define deflate_copyright z_deflate_copyright +#define get_crc_table z_get_crc_table +#ifndef Z_SOLO +#define gz_error z_gz_error +#define gz_intmax z_gz_intmax +#define gz_strwinerror z_gz_strwinerror +#define gzbuffer z_gzbuffer +#define gzclearerr z_gzclearerr +#define gzclose z_gzclose +#define gzclose_r z_gzclose_r +#define gzclose_w z_gzclose_w +#define gzdirect z_gzdirect +#define gzdopen z_gzdopen +#define gzeof z_gzeof +#define gzerror z_gzerror +#define gzflush z_gzflush +#define gzfread z_gzfread +#define gzfwrite z_gzfwrite +#define gzgetc z_gzgetc +#define gzgetc_ z_gzgetc_ +#define gzgets z_gzgets +#define gzoffset z_gzoffset +#define gzoffset64 z_gzoffset64 +#define gzopen z_gzopen +#define gzopen64 z_gzopen64 +#ifdef _WIN32 +#define gzopen_w z_gzopen_w +#endif +#define gzprintf z_gzprintf +#define gzputc z_gzputc +#define gzputs z_gzputs +#define gzread z_gzread +#define gzrewind z_gzrewind +#define gzseek z_gzseek +#define gzseek64 z_gzseek64 +#define gzsetparams z_gzsetparams +#define gztell z_gztell +#define gztell64 z_gztell64 +#define gzungetc z_gzungetc +#define gzvprintf z_gzvprintf +#define gzwrite z_gzwrite +#endif +#define inflate z_inflate +#define inflateBack z_inflateBack +#define inflateBackEnd z_inflateBackEnd +#define inflateBackInit z_inflateBackInit +#define inflateBackInit_ z_inflateBackInit_ +#define inflateCodesUsed z_inflateCodesUsed +#define inflateCopy z_inflateCopy +#define inflateEnd z_inflateEnd +#define inflateGetDictionary z_inflateGetDictionary +#define inflateGetHeader z_inflateGetHeader +#define inflateInit z_inflateInit +#define inflateInit2 z_inflateInit2 +#define inflateInit2_ z_inflateInit2_ +#define inflateInit_ z_inflateInit_ +#define inflateMark z_inflateMark +#define inflatePrime z_inflatePrime +#define inflateReset z_inflateReset +#define inflateReset2 z_inflateReset2 +#define inflateResetKeep z_inflateResetKeep +#define inflateSetDictionary z_inflateSetDictionary +#define inflateSync z_inflateSync +#define inflateSyncPoint z_inflateSyncPoint +#define inflateUndermine z_inflateUndermine +#define inflateValidate z_inflateValidate +#define inflate_copyright z_inflate_copyright +#define inflate_fast z_inflate_fast +#define inflate_table z_inflate_table +#ifndef Z_SOLO +#define uncompress z_uncompress +#define uncompress2 z_uncompress2 +#endif +#define zError z_zError +#ifndef Z_SOLO +#define zcalloc z_zcalloc +#define zcfree z_zcfree +#endif +#define zlibCompileFlags z_zlibCompileFlags +#define zlibVersion z_zlibVersion /* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf +#define Byte z_Byte +#define Bytef z_Bytef +#define alloc_func z_alloc_func +#define charf z_charf +#define free_func z_free_func +#ifndef Z_SOLO +#define gzFile z_gzFile +#endif +#define gz_header z_gz_header +#define gz_headerp z_gz_headerp +#define in_func z_in_func +#define intf z_intf +#define out_func z_out_func +#define uInt z_uInt +#define uIntf z_uIntf +#define uLong z_uLong +#define uLongf z_uLongf +#define voidp z_voidp +#define voidpc z_voidpc +#define voidpf z_voidpf /* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state +#define gz_header_s z_gz_header_s +#define internal_state z_internal_state #endif #if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS +#define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 +#define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS +#define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif +#ifndef WIN32 +#define WIN32 +#endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif +#if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +#ifndef SYS16BIT +#define SYS16BIT +#endif +#endif #endif /* @@ -192,73 +192,73 @@ * than 64k bytes at a time (needed on systems with 16-bit int). */ #ifdef SYS16BIT -# define MAXSEG_64K +#define MAXSEG_64K #endif #ifdef MSDOS -# define UNALIGNED_OK +#define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif +#ifndef STDC +#define STDC +#endif +#if __STDC_VERSION__ >= 199901L +#ifndef STDC99 +#define STDC99 +#endif +#endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC +#define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC +#define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC +#define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC +#define STDC #endif -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +#define STDC #endif #ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif +#ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +#define const /* note: need a more gentle solution here */ +#endif #endif #if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const +#define z_const const #else -# define z_const +#define z_const #endif #ifdef Z_SOLO - typedef uint64_t z_size_t; +typedef uint64_t z_size_t; +#else +#define z_longlong int64_t +#if defined(NO_SIZE_T) +typedef unsigned NO_SIZE_T z_size_t; +#elif defined(STDC) +#include +typedef size_t z_size_t; #else -# define z_longlong int64_t -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef uint64_t z_size_t; -# endif -# undef z_longlong +typedef uint64_t z_size_t; +#endif +#undef z_longlong #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif +#ifdef MAXSEG_64K +#define MAX_MEM_LEVEL 8 +#else +#define MAX_MEM_LEVEL 9 +#endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. @@ -267,7 +267,7 @@ * gzip.) */ #ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ +#define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): @@ -283,22 +283,22 @@ for small objects. */ - /* Type declarations */ +/* Type declarations */ #ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif +#ifdef STDC +#define OF(args) args +#else +#define OF(args) () +#endif #endif #ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +#define Z_ARG(args) args +#else +#define Z_ARG(args) () +#endif #endif /* The following definitions for FAR are needed only for MSDOS mixed @@ -308,153 +308,153 @@ * just define FAR to be empty. */ #ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif +#if defined(M_I86SM) || defined(M_I86MM) +/* MSC small or medium model */ +#define SMALL_MEDIUM +#ifdef _MSC_VER +#define FAR _far +#else +#define FAR far +#endif +#endif +#if (defined(__SMALL__) || defined(__MEDIUM__)) +/* Turbo C small or medium model */ +#define SMALL_MEDIUM +#ifdef __BORLANDC__ +#define FAR _far +#else +#define FAR far +#endif +#endif #endif #if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif +/* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +#ifdef ZLIB_DLL +#if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +#ifdef ZLIB_INTERNAL +#define ZEXTERN extern __declspec(dllexport) +#else +#define ZEXTERN extern __declspec(dllimport) +#endif +#endif +#endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +#ifdef ZLIB_WINAPI +#ifdef FAR +#undef FAR +#endif +#include +/* No need for _export, use ZLIB.DEF instead. */ +/* For complete Windows compatibility, use WINAPI, not __stdcall. */ +#define ZEXPORT WINAPI +#ifdef WIN32 +#define ZEXPORTVA WINAPIV +#else +#define ZEXPORTVA FAR CDECL +#endif +#endif +#endif + +#if defined(__BEOS__) +#ifdef ZLIB_DLL +#ifdef ZLIB_INTERNAL +#define ZEXPORT __declspec(dllexport) +#define ZEXPORTVA __declspec(dllexport) +#else +#define ZEXPORT __declspec(dllimport) +#define ZEXPORTVA __declspec(dllimport) +#endif +#endif #endif #ifndef ZEXTERN -# define ZEXTERN extern +#define ZEXTERN extern #endif #ifndef ZEXPORT -# define ZEXPORT +#define ZEXPORT #endif #ifndef ZEXPORTVA -# define ZEXPORTVA +#define ZEXPORTVA #endif #ifndef FAR -# define FAR +#define FAR #endif #if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ +typedef unsigned char Byte; /* 8 bits */ #endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef uint64_t uLong; /* 32 bits or more */ +typedef unsigned int uInt; /* 16 bits or more */ +typedef uint64_t uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR +/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +#define Bytef Byte FAR #else - typedef Byte FAR Bytef; +typedef Byte FAR Bytef; #endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; typedef uLong FAR uLongf; #ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; +typedef void const *voidpc; +typedef void FAR *voidpf; +typedef void * voidp; #else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; +typedef Byte const *voidpc; +typedef Byte FAR *voidpf; +typedef Byte * voidp; #endif #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 uint64_t -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif +#include +#if (UINT_MAX == 0xffffffffUL) +#define Z_U4 unsigned +#elif (ULONG_MAX == 0xffffffffUL) +#define Z_U4 uint64_t +#elif (USHRT_MAX == 0xffffffffUL) +#define Z_U4 unsigned short +#endif #endif #ifdef Z_U4 - typedef Z_U4 z_crc_t; +typedef Z_U4 z_crc_t; #else - typedef uint64_t z_crc_t; +typedef uint64_t z_crc_t; #endif -#if 1 /* was set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H +#if 1 /* was set to #if 1 by ./configure */ +#define Z_HAVE_UNISTD_H #endif -#if 1 /* was set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H +#if 1 /* was set to #if 1 by ./configure */ +#define Z_HAVE_STDARG_H #endif #ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif +#ifndef Z_SOLO +#include /* for off_t */ +#endif #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif +#ifndef Z_SOLO +#include /* for va_list */ +#endif #endif #ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif +#ifndef Z_SOLO +#include /* for wchar_t */ +#endif #endif /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and @@ -464,71 +464,76 @@ typedef uLong FAR uLongf; * equivalently requesting no 64-bit operations */ #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE +#undef _LARGEFILE64_SOURCE #endif #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H +#define Z_HAVE_UNISTD_H #endif #ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif +#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +#if (_WIN64) +#include +#include +#else +#include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +#endif +#ifdef VMS +#include /* for off_t */ +#endif +#ifndef z_off_t +#define z_off_t off_t +#endif +#endif #endif -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE - 0 +#define Z_LFS64 #endif #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 +#define Z_LARGE64 #endif -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS - 0 == 64 && defined(Z_LFS64) +#define Z_WANT64 #endif #if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#define SEEK_SET 0 /* Seek from beginning of file. */ +#define SEEK_CUR 1 /* Seek from current position. */ +#define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t -# define z_off_t int64_t +#define z_off_t int64_t #endif #if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t +#define z_off64_t off64_t +#else +#if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +#define z_off64_t __int64 #else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif +#define z_off64_t z_off_t +#endif #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") +#pragma map(deflateInit_, "DEIN") +#pragma map(deflateInit2_, "DEIN2") +#pragma map(deflateEnd, "DEEND") +#pragma map(deflateBound, "DEBND") +#pragma map(inflateInit_, "ININ") +#pragma map(inflateInit2_, "ININ2") +#pragma map(inflateEnd, "INEND") +#pragma map(inflateSync, "INSY") +#pragma map(inflateSetDictionary, "INSEDI") +#pragma map(compressBound, "CMBND") +#pragma map(inflate_table, "INTABL") +#pragma map(inflate_fast, "INFA") +#pragma map(inflate_copyright, "INCOPY") #endif #endif /* ZCONF_H */ diff --git a/deps/zlib-1.2.11/src/zconf.h b/deps/zlib-1.2.11/src/zconf.h index d71de993e1230fb6c6c1cf3c9e60c9d7f9e4ba7c..361c098281905400d304372852df52989d51f463 100644 --- a/deps/zlib-1.2.11/src/zconf.h +++ b/deps/zlib-1.2.11/src/zconf.h @@ -472,7 +472,12 @@ typedef uLong FAR uLongf; #endif #ifndef Z_SOLO # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +#if (_WIN64) +#include +#include +#else +#include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +#endif # ifdef VMS # include /* for off_t */ # endif diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index eaebd2f19dfb77ffcd54d3d8d2a0dc597c8ed875..987c309add49401923899123e613d14b1ebd644c 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -37,7 +37,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) ADD_SUBDIRECTORY(tests) -ELSEIF (TD_WINDOWS_64) +ELSEIF (TD_WINDOWS) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index e856481a9a5c84967910bb609fe5347b171bab7a..05114cc3244cab876c7aec5af31ac23cc42b3d8f 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,6 +1,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) +IF (TD_WINDOWS) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/iconv) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex) +ENDIF () + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index a185a9de7b4f79d1adcb12205af09a02e7cdfe36..0be021617446e75414c40677e5f53360db1c8d15 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -565,7 +565,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { nrow = malloc(kvRowLen(row) + sizeof(SColIdx) + diff); if (nrow == NULL) return -1; - kvRowSetLen(nrow, kvRowLen(row) + sizeof(SColIdx) + diff); + kvRowSetLen(nrow, kvRowLen(row) + (int16_t)sizeof(SColIdx) + diff); kvRowSetNCols(nrow, kvRowNCols(row) + 1); if (ptr == NULL) { @@ -573,10 +573,10 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { memcpy(kvRowValues(nrow), kvRowValues(row), POINTER_DISTANCE(kvRowEnd(row), kvRowValues(row))); int colIdx = kvRowNCols(nrow) - 1; kvRowColIdxAt(nrow, colIdx)->colId = colId; - kvRowColIdxAt(nrow, colIdx)->offset = POINTER_DISTANCE(kvRowEnd(row), kvRowValues(row)); + kvRowColIdxAt(nrow, colIdx)->offset = (int16_t)(POINTER_DISTANCE(kvRowEnd(row), kvRowValues(row))); memcpy(kvRowColVal(nrow, kvRowColIdxAt(nrow, colIdx)), value, diff); } else { - int16_t tlen = POINTER_DISTANCE(ptr, kvRowColIdx(row)); + int16_t tlen = (int16_t)(POINTER_DISTANCE(ptr, kvRowColIdx(row))); if (tlen > 0) { memcpy(kvRowColIdx(nrow), kvRowColIdx(row), tlen); memcpy(kvRowValues(nrow), kvRowValues(row), ((SColIdx *)ptr)->offset); @@ -617,7 +617,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { kvRowSetNCols(nrow, kvRowNCols(row)); // Copy part ahead - nlen = POINTER_DISTANCE(ptr, kvRowColIdx(row)); + nlen = (int16_t)(POINTER_DISTANCE(ptr, kvRowColIdx(row))); ASSERT(nlen % sizeof(SColIdx) == 0); if (nlen > 0) { ASSERT(((SColIdx *)ptr)->offset > 0); diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 5ad1257f7d6ca7587e3b4e7f612bac3392bee9ce..0cd3196ad015e28e6444a5763fae6eb2c09b8d35 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -92,7 +92,7 @@ int32_t tsStreamCompStartDelay = 10000; int32_t tsStreamCompRetryDelay = 10; // The delayed computing ration. 10% of the whole computing time window by default. -float tsStreamComputDelayRatio = 0.1; +float tsStreamComputDelayRatio = 0.1f; int32_t tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance @@ -173,8 +173,8 @@ float tsTotalTmpDirGB = 0; float tsTotalDataDirGB = 0; float tsAvailTmpDirectorySpace = 0; float tsAvailDataDirGB = 0; -float tsReservedTmpDirectorySpace = 0.1; -float tsMinimalDataDirGB = 0.5; +float tsReservedTmpDirectorySpace = 0.1f; +float tsMinimalDataDirGB = 0.5f; int32_t tsTotalMemoryMB = 0; int32_t tsVersion = 0; @@ -294,7 +294,7 @@ bool taosCfgDynamicOptions(char *msg) { return false; } -static void doInitGlobalConfig() { +static void doInitGlobalConfig(void) { SGlobalCfg cfg = {0}; // ip address @@ -405,8 +405,8 @@ static void doInitGlobalConfig() { cfg.ptr = &tsRatioOfQueryThreads; cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; - cfg.minValue = 0.1; - cfg.maxValue = 0.9; + cfg.minValue = 0.1f; + cfg.maxValue = 0.9f; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); @@ -607,8 +607,8 @@ static void doInitGlobalConfig() { cfg.ptr = &tsStreamComputDelayRatio; cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 0.1; - cfg.maxValue = 0.9; + cfg.minValue = 0.1f; + cfg.maxValue = 0.9f; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); @@ -870,7 +870,7 @@ static void doInitGlobalConfig() { cfg.ptr = &tsMinimalLogDirGB; cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 0.001; + cfg.minValue = 0.001f; cfg.maxValue = 10000000; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_GB; @@ -880,7 +880,7 @@ static void doInitGlobalConfig() { cfg.ptr = &tsReservedTmpDirectorySpace; cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 0.001; + cfg.minValue = 0.001f; cfg.maxValue = 10000000; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_GB; @@ -890,7 +890,7 @@ static void doInitGlobalConfig() { cfg.ptr = &tsMinimalDataDirGB; cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 0.001; + cfg.minValue = 0.001f; cfg.maxValue = 10000000; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_GB; @@ -1256,7 +1256,7 @@ static void doInitGlobalConfig() { cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; cfg.minValue = 1; - cfg.maxValue = 0x7fffffff; + cfg.maxValue = 65536; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); @@ -1338,7 +1338,7 @@ int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) { */ bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) { - int len = strlen(option); + int len = (int)strlen(option); if (strncasecmp(option, "vnode:", 6) != 0) { return false; } diff --git a/src/common/src/tname.c b/src/common/src/tname.c index 15ec68fc66e770adad09815219d593aaa83f492c..d80ddb0ee2ba4883c63126f1023b3c86fb02f396 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -6,7 +6,7 @@ #include "ttokendef.h" // todo refactor -__attribute__((unused)) static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) { +UNUSED_FUNC static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) { for (int32_t i = 0; i < num; ++i) { while (*input != 0 && *input++ != delim) { }; @@ -14,7 +14,7 @@ __attribute__((unused)) static FORCE_INLINE const char* skipSegments(const char* return input; } -__attribute__((unused)) static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) { +UNUSED_FUNC static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) { size_t len = 0; while (*src != delimiter && *src != 0) { *dst++ = *src++; @@ -120,11 +120,11 @@ void extractTableNameFromToken(SSQLToken* pToken, SSQLToken* pTable) { char* r = strnchr(pToken->z, sep, pToken->n, false); if (r != NULL) { // record the table name token - pTable->n = r - pToken->z; + pTable->n = (uint32_t)(r - pToken->z); pTable->z = pToken->z; r += 1; - pToken->n -= (r - pToken->z); + pToken->n -= (uint32_t)(r - pToken->z); pToken->z = r; } } diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index 44b1d9fc385595638098ad098f51245a46a4bfef..3910d80ecf3cc035074b54b2671828c9b2a3ca8c 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -204,8 +204,8 @@ static void getStatics_i64(const TSKEY *primaryKey, const void *pData, int32_t n static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { float *data = (float *)pData; - float fmin = DBL_MAX; - float fmax = -DBL_MAX; + float fmin = FLT_MAX; + float fmax = -FLT_MAX; double dsum = 0; *minIndex = 0; *maxIndex = 0; diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 2906b3f0aca5a1527efa984d2068351a57796f3a..5460d2125219112105a376b8853eaf439faa2425 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -101,19 +101,19 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 break; } case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length - int32_t lenInwchar = len / TSDB_NCHAR_SIZE; + size_t lenInwchar = len / TSDB_NCHAR_SIZE; pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE); wcsncpy(pVar->wpz, (wchar_t *)pz, lenInwchar); pVar->wpz[lenInwchar] = 0; - pVar->nLen = len; + pVar->nLen = (int32_t)len; break; } case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method pVar->pz = calloc(len, sizeof(char)); memcpy(pVar->pz, pz, len); - pVar->nLen = len; + pVar->nLen = (int32_t)len; break; } @@ -185,7 +185,7 @@ int32_t tVariantToString(tVariant *pVar, char *dst) { case TSDB_DATA_TYPE_NCHAR: { dst[0] = '\''; taosUcs4ToMbs(pVar->wpz, (twcslen(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1); - int32_t len = strlen(dst); + int32_t len = (int32_t)strlen(dst); dst[len] = '\''; dst[len + 1] = 0; return len + 1; @@ -361,11 +361,11 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { pBuf = realloc(pBuf, newSize + 1); } - taosUcs4ToMbs(pVariant->wpz, newSize, pBuf); + taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, pBuf); free(pVariant->wpz); pBuf[newSize] = 0; } else { - taosUcs4ToMbs(pVariant->wpz, newSize, *pDest); + taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, *pDest); } } else { @@ -384,7 +384,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { *pDest = pBuf; } - *pDestSize = strlen(*pDest); + *pDestSize = (int32_t)strlen(*pDest); return 0; } @@ -428,7 +428,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output); if (pDestSize != NULL) { - *pDestSize = output; + *pDestSize = (int32_t)output; } } @@ -682,7 +682,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu float fv = (float)pVariant->i64Key; SET_FLOAT_VAL_ALIGN(payload, &fv); #else - *((float *)payload) = pVariant->i64Key; + *((float *)payload) = (float)pVariant->i64Key; #endif } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { #ifdef _TD_ARM_32_ @@ -735,7 +735,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu double dv = (double)(pVariant->i64Key); SET_DOUBLE_VAL_ALIGN(payload, &dv); #else - *((double *)payload) = pVariant->i64Key; + *((double *)payload) = (double)pVariant->i64Key; #endif } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { #ifdef _TD_ARM_32_ diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 57e0b46f06b1fb31b43c6c38c35912e294dcd287..6d43568ecd095fcd4602288914bde9a21873e21f 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -206,7 +206,7 @@ typedef struct SSubmitMsg { SMsgHead header; int32_t length; int32_t numOfBlocks; - SSubmitBlk blocks[]; + char blocks[]; } SSubmitMsg; typedef struct { @@ -680,7 +680,7 @@ typedef struct STableMetaMsg { typedef struct SMultiTableMeta { int32_t numOfTables; int32_t contLen; - STableMetaMsg metas[]; + char metas[]; } SMultiTableMeta; typedef struct { diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt index 3695f694f3a13c0a664d7de4b9650b4e42be512a..445d4f6951af4cf97c1a919893838625281c6c44 100644 --- a/src/kit/shell/CMakeLists.txt +++ b/src/kit/shell/CMakeLists.txt @@ -22,7 +22,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) # ENDIF () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) -ELSEIF (TD_WINDOWS_64) +ELSEIF (TD_WINDOWS) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex) LIST(APPEND SRC ./src/shellEngine.c) diff --git a/src/os/inc/osDarwin.h b/src/os/inc/osDarwin.h index 8628a0f3ac266605d40e81cdd64b38458201b3e5..c1a950fbe6375b14e3cf25277eb933b96e518f10 100644 --- a/src/os/inc/osDarwin.h +++ b/src/os/inc/osDarwin.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_PLATFORM_LINUX_H -#define TDENGINE_PLATFORM_LINUX_H +#ifndef TDENGINE_OS_DARWIN_H +#define TDENGINE_OS_DARWIN_H #ifdef __cplusplus extern "C" { diff --git a/src/os/inc/osFile.h b/src/os/inc/osFile.h index 6e48e80ca4966b43dda90ddd5a4d7261f144acfc..e99c64c2e04165bb42006935385c7f06395a8ac1 100644 --- a/src/os/inc/osFile.h +++ b/src/os/inc/osFile.h @@ -56,6 +56,22 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP // TAOS_OS_FUNC_FILE_GETTMPFILEPATH void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath); +#ifdef TAOS_OS_FUNC_FILE_ISDIR + #define S_ISDIR(m) (((m) & 0170000) == (0040000)) +#endif + +#ifdef TAOS_OS_FUNC_FILE_ISREG + #define S_ISREG(m) !(S_ISDIR(m)) +#endif + +#ifdef TAOS_OS_FUNC_FILE_ISLNK + #define S_ISLNK(m) 0 +#endif + +#ifndef TAOS_OS_FUNC_FILE_FTRUNCATE + #define taosFtruncate ftruncate +#endif + #ifdef __cplusplus } #endif diff --git a/src/os/inc/osLinux32.h b/src/os/inc/osLinux32.h index b62b086d0fbd6b9af7782e1339495a1cf4724809..93e917e797a60c9704726ea44d585d33d4ec102a 100644 --- a/src/os/inc/osLinux32.h +++ b/src/os/inc/osLinux32.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_OS_LINUX64_H -#define TDENGINE_OS_LINUX64_H +#ifndef TDENGINE_OS_LINUX32_H +#define TDENGINE_OS_LINUX32_H #ifdef __cplusplus extern "C" { diff --git a/src/os/inc/osMemory.h b/src/os/inc/osMemory.h index aaac8c68e31c480c9b7a793be110b0e8f316ff48..37d9dc9828ec1f51f36542e6c297ec3df8709f7e 100644 --- a/src/os/inc/osMemory.h +++ b/src/os/inc/osMemory.h @@ -74,9 +74,9 @@ void taosTMemset(void *ptr, int c); #define taosCalloc(num, size) taos_calloc(num, size, __FILE__, __LINE__) #define taosRealloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__) #define taosFree(ptr) taos_free(ptr, __FILE__, __LINE__) - #define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__) - #define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__) - #define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__) + //#define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__) + //#define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__) + //#define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__) #endif #endif diff --git a/src/os/inc/osSemphone.h b/src/os/inc/osSemphone.h index 300f1e8ef1bca311e14fc220ca72bedd8a5f4152..c4fc98988a98b751ce0ec4cd49e90f2d013d40dc 100644 --- a/src/os/inc/osSemphone.h +++ b/src/os/inc/osSemphone.h @@ -31,6 +31,7 @@ extern "C" { // TAOS_OS_FUNC_SEMPHONE_PTHREAD bool taosCheckPthreadValid(pthread_t thread); int64_t taosGetPthreadId(); +void taosResetPthread(pthread_t *thread); #ifdef __cplusplus } diff --git a/src/os/inc/osWindows.h b/src/os/inc/osWindows.h index a8c2243253f7768c4682acedeaabb25b197cad55..1118b3c64b7bd1296a2b083143e444a665c2264e 100644 --- a/src/os/inc/osWindows.h +++ b/src/os/inc/osWindows.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_PLATFORM_WINDOWS_H -#define TDENGINE_PLATFORM_WINDOWS_H +#ifndef TDENGINE_OS_WINDOWS_H +#define TDENGINE_OS_WINDOWS_H #include #include @@ -60,10 +60,15 @@ extern "C" { #define TAOS_OS_FUNC_DIR #define TAOS_OS_FUNC_FILE +#define TAOS_OS_FUNC_FILE_ISREG +#define TAOS_OS_FUNC_FILE_ISDIR +#define TAOS_OS_FUNC_FILE_ISLNK #define TAOS_OS_FUNC_FILE_SENDIFLE #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_FILE_GETTMPFILEPATH +#define TAOS_OS_FUNC_FILE_FTRUNCATE + extern int taosFtruncate(int fd, int64_t length); #define TAOS_OS_FUNC_MATH #define SWAP(a, b, c) \ @@ -87,6 +92,7 @@ extern "C" { #define taosCloseSocket(fd) closesocket(fd) #define TAOS_OS_FUNC_STRING_WCHAR + int twcslen(const wchar_t *wcs); #define TAOS_OS_FUNC_STRING_GETLINE #define TAOS_OS_FUNC_STRING_STR2INT64 #ifdef _TD_GO_DLL_ @@ -97,7 +103,7 @@ extern "C" { #endif #define TAOS_OS_FUNC_STRING_STRDUP #define taosStrdupImp(str) _strdup(str) - #define taosStrndupImp(str, size) _strndup(str, size) + #define taosStrndupImp(str, size) _strndup(str, size) #define TAOS_OS_FUNC_SYSINFO @@ -154,6 +160,9 @@ char * strndup(const char *s, size_t n); #define TCP_KEEPCNT 0x1234 #define TCP_KEEPIDLE 0x1234 #define TCP_KEEPINTVL 0x1234 +#define SHUT_RDWR SD_BOTH +#define SHUT_RD SD_RECEIVE +#define SHUT_WR SD_SEND #define LOCK_EX 1 #define LOCK_NB 2 diff --git a/src/os/src/darwin/darwinSysInfo.c b/src/os/src/darwin/darwinSysInfo.c index 108cc6239f82105f49ef1ada0a326e14db3233b9..f8aa02dcffd14e2def6339ccb507b9f9ab2489d1 100644 --- a/src/os/src/darwin/darwinSysInfo.c +++ b/src/os/src/darwin/darwinSysInfo.c @@ -41,7 +41,7 @@ static void taosGetSystemLocale() { if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) { char *locale = setlocale(LC_CTYPE, "chs"); if (locale != NULL) { - strncpy(tsLocale, locale, TSDB_LOCALE_LEN - 1); + tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN); cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT; uInfo("locale not configured, set to default:%s", tsLocale); } diff --git a/src/os/src/detail/CMakeLists.txt b/src/os/src/detail/CMakeLists.txt index 5902a9356b834b8122fa2eee24f2ad126ce999c1..3ea7f97985f52ac96f625ba5f366441f486684a9 100644 --- a/src/os/src/detail/CMakeLists.txt +++ b/src/os/src/detail/CMakeLists.txt @@ -1,6 +1,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) +IF (TD_WINDOWS) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/iconv) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex) +ENDIF () + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) diff --git a/src/os/src/detail/osFile.c b/src/os/src/detail/osFile.c index 516b7bb19e37452cf1aac27cd1d7e2b9f76413fe..8f055dd8129f340f267e64cdd905505a7b675a2d 100644 --- a/src/os/src/detail/osFile.c +++ b/src/os/src/detail/osFile.c @@ -70,7 +70,7 @@ ssize_t taosTReadImp(int fd, void *buf, size_t count) { char * tbuf = (char *)buf; while (leftbytes > 0) { - readbytes = read(fd, (void *)tbuf, leftbytes); + readbytes = read(fd, (void *)tbuf, (uint32_t)leftbytes); if (readbytes < 0) { if (errno == EINTR) { continue; @@ -94,7 +94,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) { char * tbuf = (char *)buf; while (nleft > 0) { - nwritten = write(fd, (void *)tbuf, nleft); + nwritten = write(fd, (void *)tbuf, (uint32_t)nleft); if (nwritten < 0) { if (errno == EINTR) { continue; @@ -105,7 +105,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) { tbuf += nwritten; } - return n; + return (ssize_t)n; } #ifndef TAOS_OS_FUNC_FILE_SENDIFLE diff --git a/src/os/src/detail/osRand.c b/src/os/src/detail/osRand.c index edb8642bd65660e69deb59a61ccaf70c95f3ad8b..b322a88684e63776b432d2f4025b3d16fc614861 100644 --- a/src/os/src/detail/osRand.c +++ b/src/os/src/detail/osRand.c @@ -26,11 +26,11 @@ uint32_t taosSafeRand(void) { fd = open("/dev/urandom", 0); if (fd < 0) { - seed = time(0); + seed = (int)time(0); } else { int len = read(fd, &seed, sizeof(seed)); if (len < 0) { - seed = time(0); + seed = (int)time(0); } close(fd); } diff --git a/src/os/src/detail/osSemphone.c b/src/os/src/detail/osSemphone.c index 82b916b4d73080c55da69ac090d9b5b56e23685b..1f1ef268c61c86e11ef67fa588fc0b2f5bffebfa 100644 --- a/src/os/src/detail/osSemphone.c +++ b/src/os/src/detail/osSemphone.c @@ -20,5 +20,6 @@ bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; } int64_t taosGetPthreadId() { return (int64_t)pthread_self(); } +void taosResetPthread(pthread_t *thread) { *thread = 0; } #endif \ No newline at end of file diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index 6d41692d8072442bafead45d082038e4910ba136..ced1643d2b5eae25f64aa88aa7fe1720508c834b 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -165,7 +165,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) { char* sep = strchr(&str[i], ':'); if (sep != NULL) { - int32_t len = sep - &str[i]; + int32_t len = (int32_t)(sep - &str[i]); hour = strnatoi(&str[i], len); i += len + 1; @@ -212,7 +212,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) { /* mktime will be affected by TZ, set by using taos_options */ #ifdef WINDOWS - int64_t seconds = gmtime(&tm); + int64_t seconds = user_mktime64(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + //int64_t seconds = gmtime(&tm); #else int64_t seconds = timegm(&tm); #endif diff --git a/src/os/src/windows/w64File.c b/src/os/src/windows/w64File.c index f2c59c3639ead8e980d0bf1ce9c7a43c8dbb629b..5549c078a5220d3e493ce21e2c19e38fb9611cbb 100644 --- a/src/os/src/windows/w64File.c +++ b/src/os/src/windows/w64File.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "os.h" +#include "tulog.h" void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) { const char* tdengineTmpFileNamePrefix = "tdengine-"; @@ -77,4 +78,9 @@ int taosFSendFileImp(FILE* out_file, FILE* in_file, int64_t* offset, int32_t cou ssize_t taosTSendFileImp(int dfd, int sfd, off_t *offset, size_t size) { uError("taosTSendFileImp no implemented yet"); return 0; +} + +int taosFtruncate(int fd, int64_t length) { + uError("taosFtruncate no implemented yet"); + return 0; } \ No newline at end of file diff --git a/src/os/src/windows/w64Socket.c b/src/os/src/windows/w64Socket.c index cdf46825e8c481a726b264447664ab881ced8a7d..dbe501b6454000adf8e250e0acfbed980ac55785 100644 --- a/src/os/src/windows/w64Socket.c +++ b/src/os/src/windows/w64Socket.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include "os.h" #include #include #include @@ -33,7 +34,7 @@ void taosWinSocketInit() { } } -int taosSetNonblocking(SOCKET sock, int on) { +int taosSetNonblocking(int sock, int on) { u_long mode; if (on) { mode = 1; diff --git a/src/os/src/windows/w64String.c b/src/os/src/windows/w64String.c index 8057c89a5595d1eefa87b41c760d1fa57acf0ac4..e3ac7d88322b9b1722460c7c0415d7a6c932c620 100644 --- a/src/os/src/windows/w64String.c +++ b/src/os/src/windows/w64String.c @@ -67,7 +67,7 @@ char *getpass(const char *prefix) { } char *strndup(const char *s, size_t n) { - int len = strlen(s); + size_t len = strlen(s); if (len >= n) { len = n; } @@ -78,13 +78,13 @@ char *strndup(const char *s, size_t n) { return r; } -size_t twcslen(const wchar_t *wcs) { +int twcslen(const wchar_t *wcs) { int *wstr = (int *)wcs; if (NULL == wstr) { return 0; } - size_t n = 0; + int n = 0; while (1) { if (0 == *wstr++) { break; diff --git a/src/os/src/windows/w64Sysinfo.c b/src/os/src/windows/w64Sysinfo.c index 0a680ac0b7d47f65017d5027569fee4f2f54f508..27869e1eec3b0c026c3a467a9e7c591053129fdf 100644 --- a/src/os/src/windows/w64Sysinfo.c +++ b/src/os/src/windows/w64Sysinfo.c @@ -43,7 +43,7 @@ static void taosGetSystemLocale() { if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) { char *locale = setlocale(LC_CTYPE, "chs"); if (locale != NULL) { - tstrncpy(tsLocale, locale, sizeof(tsLocale)); + tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);; cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT; uInfo("locale not configured, set to default:%s", tsLocale); } diff --git a/src/rpc/src/rpcCache.c b/src/rpc/src/rpcCache.c index 3f76b202c9e85eecbe216f7226370f8221250512..751f03e52ac3d8b4cb1a36f7330bbd4c7faef328 100644 --- a/src/rpc/src/rpcCache.c +++ b/src/rpc/src/rpcCache.c @@ -82,7 +82,7 @@ void *rpcOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl, pCache->cleanFp = cleanFp; pCache->tmrCtrl = tmrCtrl; pCache->lockedBy = calloc(sizeof(int64_t), maxSessions); - taosTmrReset(rpcCleanConnCache, pCache->keepTimer * 2, pCache, pCache->tmrCtrl, &pCache->pTimer); + taosTmrReset(rpcCleanConnCache, (int32_t)(pCache->keepTimer * 2), pCache, pCache->tmrCtrl, &pCache->pTimer); pthread_mutex_init(&pCache->mutex, NULL); @@ -226,7 +226,7 @@ static void rpcCleanConnCache(void *handle, void *tmrId) { } // tTrace("timer, total connections in cache:%d", pCache->total); - taosTmrReset(rpcCleanConnCache, pCache->keepTimer * 2, pCache, pCache->tmrCtrl, &pCache->pTimer); + taosTmrReset(rpcCleanConnCache, (int32_t)(pCache->keepTimer * 2), pCache, pCache->tmrCtrl, &pCache->pTimer); } static void rpcRemoveExpiredNodes(SConnCache *pCache, SConnHash *pNode, int hash, uint64_t time) { diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 01c753ec5b0b415eb015c92df2c5f45da832aac3..29afe8d2abe2535d8fc9f605fcb68286f85cc6d8 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -33,7 +33,7 @@ #include "rpcHead.h" #define RPC_MSG_OVERHEAD (sizeof(SRpcReqContext) + sizeof(SRpcHead) + sizeof(SRpcDigest)) -#define rpcHeadFromCont(cont) ((SRpcHead *) (cont - sizeof(SRpcHead))) +#define rpcHeadFromCont(cont) ((SRpcHead *) ((char*)cont - sizeof(SRpcHead))) #define rpcContFromHead(msg) (msg + sizeof(SRpcHead)) #define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead)) #define rpcContLenFromMsg(msgLen) (msgLen - sizeof(SRpcHead)) @@ -359,7 +359,7 @@ void rpcSendRequest(void *shandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg) { SRpcReqContext *pContext; int contLen = rpcCompressRpcMsg(pMsg->pCont, pMsg->contLen); - pContext = (SRpcReqContext *) (pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext)); + pContext = (SRpcReqContext *) ((char*)pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext)); pContext->ahandle = pMsg->ahandle; pContext->signature = pContext; pContext->pRpc = (SRpcInfo *)shandle; @@ -492,7 +492,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo) { void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { SRpcReqContext *pContext; - pContext = (SRpcReqContext *) (pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext)); + pContext = (SRpcReqContext *) ((char*)pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext)); memset(pRsp, 0, sizeof(SRpcMsg)); @@ -654,7 +654,7 @@ static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc) { pConn->pRpc = pRpc; pConn->sid = sid; - pConn->tranId = (uint16_t)(random() & 0xFFFF); + pConn->tranId = (uint16_t)(taosRand() & 0xFFFF); pConn->ownId = htonl(pConn->sid); pConn->linkUid = (uint32_t)((int64_t)pConn + (int64_t)getpid() + (int64_t)pConn->tranId); pConn->spi = pRpc->spi; diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 7fa05af9b040ef6a962ad236eaeb8e2747218fdb..c69456b8e282dcad61d3c30fca89efabdc8ecbda 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -81,7 +81,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread } pServerObj->fd = -1; - pServerObj->thread = 0; + taosResetPthread(&pServerObj->thread); pServerObj->ip = ip; pServerObj->port = port; tstrncpy(pServerObj->label, label, sizeof(pServerObj->label)); @@ -104,7 +104,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread pThreadObj = pServerObj->pThreadObj; for (int i = 0; i < numOfThreads; ++i) { pThreadObj->pollFd = -1; - pThreadObj->thread = 0; + taosResetPthread(&pThreadObj->thread); pThreadObj->processData = fp; tstrncpy(pThreadObj->label, label, sizeof(pThreadObj->label)); pThreadObj->shandle = shandle; diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c index f75375e2fea16efa924eaac0c6427e3608dc07ae..7e59210caee47c533ed44fcc94eed11b5aa1b29d 100644 --- a/src/rpc/src/rpcUdp.c +++ b/src/rpc/src/rpcUdp.c @@ -144,7 +144,9 @@ void taosStopUdpConnection(void *handle) { for (int i = 0; i < pSet->threads; ++i) { pConn = pSet->udpConn + i; - if (pConn->thread) pthread_join(pConn->thread, NULL); + if (taosCheckPthreadValid(pConn->thread)) { + pthread_join(pConn->thread, NULL); + } taosTFree(pConn->buffer); // tTrace("%s UDP thread is closed, index:%d", pConn->label, i); } diff --git a/src/tsdb/tests/CMakeLists.txt b/src/tsdb/tests/CMakeLists.txt index b330109340c76181739aaa503cde83f049445442..a3477aef95f9e54484c106ba2afb853b48456be0 100644 --- a/src/tsdb/tests/CMakeLists.txt +++ b/src/tsdb/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) add_executable(tsdbTests ${SOURCE_LIST}) target_link_libraries(tsdbTests gtest gtest_main pthread common tsdb tutil trpc) diff --git a/src/util/inc/tchecksum.h b/src/util/inc/tchecksum.h index 54043d68e137eaf35622df90a465a0eabb184c59..495aaf33e8fca3594c45f1cfe6fc6acc59fa59d5 100644 --- a/src/util/inc/tchecksum.h +++ b/src/util/inc/tchecksum.h @@ -53,7 +53,12 @@ static FORCE_INLINE int taosCheckChecksum(const uint8_t *stream, uint32_t ssize, static FORCE_INLINE int taosCheckChecksumWhole(const uint8_t *stream, uint32_t ssize) { if (ssize < sizeof(TSCKSUM)) return 0; + +#if (_WIN64) + return 1; +#else return *((TSCKSUM *)(stream + ssize - sizeof(TSCKSUM))) == (*crc32c)(0, stream, (size_t)(ssize - sizeof(TSCKSUM))); +#endif } #ifdef __cplusplus diff --git a/src/util/inc/tcoding.h b/src/util/inc/tcoding.h index 907c69bf016f863e0e1a785209b30ce32c9c89b6..9300094e353b2010ff047eff2c55bdac5597d293 100644 --- a/src/util/inc/tcoding.h +++ b/src/util/inc/tcoding.h @@ -196,14 +196,14 @@ static FORCE_INLINE void *taosDecodeFixedI64(void *buf, int64_t *value) { static FORCE_INLINE int taosEncodeVariantU16(void **buf, uint16_t value) { int i = 0; while (value >= ENCODE_LIMIT) { - if (buf != NULL) ((uint8_t *)(*buf))[i] = (value | ENCODE_LIMIT); + if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT); value >>= 7; i++; ASSERT(i < 3); } if (buf != NULL) { - ((uint8_t *)(*buf))[i] = value; + ((uint8_t *)(*buf))[i] = (uint8_t)value; *buf = POINTER_SHIFT(*buf, i + 1); } @@ -292,14 +292,14 @@ static FORCE_INLINE void *taosDecodeVariantI32(void *buf, int32_t *value) { static FORCE_INLINE int taosEncodeVariantU64(void **buf, uint64_t value) { int i = 0; while (value >= ENCODE_LIMIT) { - if (buf != NULL) ((uint8_t *)(*buf))[i] = (value | ENCODE_LIMIT); + if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT); value >>= 7; i++; ASSERT(i < 10); } if (buf != NULL) { - ((uint8_t *)(*buf))[i] = value; + ((uint8_t *)(*buf))[i] = (uint8_t)value; *buf = POINTER_SHIFT(*buf, i + 1); } @@ -346,7 +346,7 @@ static FORCE_INLINE int taosEncodeString(void **buf, char *value) { memcpy(*buf, value, size); *buf = POINTER_SHIFT(*buf, size); } - tlen += size; + tlen += (int)size; return tlen; } diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index 79b19ff79dc144590a1fd647a2819c0fe2b34736..0520cf29a87c9d4727ef6db48d8f5712ac845b89 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -68,7 +68,7 @@ typedef struct { int8_t cfgStatus; int8_t unitType; int8_t valType; - uint32_t ptrLength; + int32_t ptrLength; } SGlobalCfg; extern SGlobalCfg tsGlobalConfig[]; diff --git a/src/util/inc/tstoken.h b/src/util/inc/tstoken.h index 7b0e498d766f2564b417291febb559b613fd3f1d..258e62cf8a7808393493bf57eff46d7541dd2279 100644 --- a/src/util/inc/tstoken.h +++ b/src/util/inc/tstoken.h @@ -82,7 +82,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) { const char* z = pToken->z; int32_t type = TK_ILLEGAL; - int32_t i = 0; + uint32_t i = 0; for(; i < pToken->n; ++i) { switch (z[i]) { case '+': diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 88f02aff7ed2dc3221d63a2e764446751ff0ec68..37c9146a49da8efad869290c62fda776c960ecc2 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -81,7 +81,7 @@ static FORCE_INLINE void __lock_destroy(void *lock) { static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { int32_t len = MIN(length, HASH_MAX_CAPACITY); - uint32_t i = 4; + int32_t i = 4; while (i < len) i = (i << 1u); return i; } @@ -176,7 +176,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool threadsafe) { } // the max slots is not defined by user - pHashObj->capacity = taosHashCapacity(capacity); + pHashObj->capacity = taosHashCapacity((int32_t)capacity); assert((pHashObj->capacity & (pHashObj->capacity - 1)) == 0); pHashObj->hashFp = fn; @@ -219,7 +219,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da __wr_lock(pHashObj->lock); uint32_t hashVal = 0; - SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &hashVal); + SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (uint32_t)keyLen, &hashVal); if (pNode == NULL) { // no data in hash table with the specified key, add it into hash table taosHashTableResize(pHashObj); @@ -261,7 +261,7 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) { __rd_lock(pHashObj->lock); uint32_t hashVal = 0; - SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &hashVal); + SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (int32_t)keyLen, &hashVal); __unlock(pHashObj->lock); @@ -278,7 +278,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) { __wr_lock(pHashObj->lock); uint32_t val = 0; - SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &val); + SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (uint32_t)keyLen, &val); if (pNode == NULL) { __unlock(pHashObj->lock); return; @@ -460,7 +460,7 @@ void taosHashTableResize(SHashObj *pHashObj) { SHashNode *pNode = NULL; SHashNode *pNext = NULL; - int32_t newSize = pHashObj->capacity << 1u; + int32_t newSize = (int32_t)(pHashObj->capacity) << 1u; if (newSize > HASH_MAX_CAPACITY) { // uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached", // pHashObj->capacity, HASH_MAX_CAPACITY); @@ -539,7 +539,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s pNewNode->key = pNewNode->data + dsize; memcpy(pNewNode->key, key, keyLen); - pNewNode->keyLen = keyLen; + pNewNode->keyLen = (uint32_t)keyLen; pNewNode->hashVal = hashVal; return pNewNode; diff --git a/src/util/src/talgo.c b/src/util/src/talgo.c index 6879461953eb9367bf79e07f26f11ca935877d4d..4b96e62e91ff440684328d7e7ea8c8c6cd783caa 100644 --- a/src/util/src/talgo.c +++ b/src/util/src/talgo.c @@ -24,7 +24,7 @@ } while (0); static void median(void *src, size_t size, size_t s, size_t e, const void *param, __ext_compar_fn_t comparFn, void* buf) { - int32_t mid = ((e - s) >> 1u) + s; + int32_t mid = ((int32_t)(e - s) >> 1u) + (int32_t)s; if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) == 1) { doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf); @@ -152,14 +152,14 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ext_compar_fn_t comparFn) { char *buf = calloc(1, size); // prepare the swap buffer - tqsortImpl(src, 0, numOfElem - 1, size, param, comparFn, buf); + tqsortImpl(src, 0, (int32_t)numOfElem - 1, (int32_t)size, param, comparFn, buf); taosTFree(buf); } void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t compar, int flags) { // TODO: need to check the correctness of this function int l = 0; - int r = nmemb; + int r = (int)nmemb; int idx = 0; int comparison; diff --git a/src/util/src/tarray.c b/src/util/src/tarray.c index 19225e998a1b2a5fead58b781b448ccf4b604415..65147b38def067bdca5de7c403835f8505a9b98e 100755 --- a/src/util/src/tarray.c +++ b/src/util/src/tarray.c @@ -120,8 +120,8 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) { void* dst = TARRAY_GET_ELEM(pArray, index); - int32_t remain = pArray->size - index; - memmove(dst + pArray->elemSize, dst, pArray->elemSize * remain); + int32_t remain = (int32_t)(pArray->size - index); + memmove((char*)dst + pArray->elemSize, (char*)dst, pArray->elemSize * remain); memcpy(dst, pData, pArray->elemSize); pArray->size += 1; @@ -138,7 +138,7 @@ void taosArrayRemove(SArray* pArray, size_t index) { } size_t remain = pArray->size - index - 1; - memmove(pArray->pData + index * pArray->elemSize, pArray->pData + (index + 1) * pArray->elemSize, remain * pArray->elemSize); + memmove((char*)pArray->pData + index * pArray->elemSize, (char*)pArray->pData + (index + 1) * pArray->elemSize, remain * pArray->elemSize); pArray->size -= 1; } diff --git a/src/util/src/tbuffer.c b/src/util/src/tbuffer.c index 4af435798cccf989eef5c75b74f72e8cfe5ccaa0..240f744ea3083e1b21f60076032483f828298167 100644 --- a/src/util/src/tbuffer.c +++ b/src/util/src/tbuffer.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "tbuffer.h" #include "exception.h" #include diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 4a30a6687191be0dc8b3285ab281bcdd49bc9439..7eca3b263713358efd23919dc60583da2878a140 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -292,7 +292,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v uError("cache:%s, key:%p, failed to added into cache, out of memory", pCacheObj->name, key); } } else { // old data exists, update the node - pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, keyLen, pData, dataSize, duration * 1000L); + pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, (int32_t)keyLen, pData, (uint32_t)dataSize, duration * 1000L); uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode->data, pOld); } @@ -509,7 +509,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char * memcpy(pNewNode->data, pData, size); pNewNode->key = (char *)pNewNode + sizeof(SCacheDataNode) + size; - pNewNode->keySize = keyLen; + pNewNode->keySize = (uint16_t)keyLen; memcpy(pNewNode->key, key, keyLen); @@ -645,7 +645,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t while (taosHashIterNext(pIter)) { SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter); - if (pNode->expireTime < time && T_REF_VAL_GET(pNode) <= 0) { + if (pNode->expireTime < (uint64_t)time && T_REF_VAL_GET(pNode) <= 0) { taosCacheReleaseNode(pCacheObj, pNode); continue; } diff --git a/src/util/src/tcompression.c b/src/util/src/tcompression.c index b085e26e07177189d2b7d350a82ef779576d3cf2..c20ba59ac9b351445cf9f97134ae08fd1e45f0f7 100644 --- a/src/util/src/tcompression.c +++ b/src/util/src/tcompression.c @@ -52,14 +52,13 @@ #include "tscompression.h" #include "taosdef.h" -const int TEST_NUMBER = 1; +static const int TEST_NUMBER = 1; #define is_bigendian() ((*(char *)&TEST_NUMBER) == 0) #define SIMPLE8B_MAX_INT64 ((uint64_t)2305843009213693951L) -bool safeInt64Add(int64_t a, int64_t b) { - if ((a > 0 && b > INT64_MAX - a) || (a < 0 && b < INT64_MIN - a)) return false; - return true; -} +#define safeInt64Add(a, b) (((a >= 0) && (b <= INT64_MAX - a)) || ((a < 0) && (b >= INT64_MIN - a))) +#define ZIGZAG_ENCODE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode +#define ZIGZAG_DECODE(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode /* * Compress Integer (Simple8B). @@ -90,7 +89,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o break; default: perror("Wrong integer types.\n"); - exit(1); + return -1; } int byte_limit = nelements * word_length + 1; @@ -125,11 +124,11 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o int64_t diff = curr_value - prev_value_tmp; // Zigzag encode the value. - uint64_t zigzag_value = (diff >> (LONG_BYTES * BITS_PER_BYTE - 1)) ^ (diff << 1); + uint64_t zigzag_value = ZIGZAG_ENCODE(int64_t, diff); if (zigzag_value >= SIMPLE8B_MAX_INT64) goto _copy_and_exit; - char tmp_bit; + int64_t tmp_bit; if (zigzag_value == 0) { // Take care here, __builtin_clzl give wrong anser for value 0; tmp_bit = 0; @@ -171,7 +170,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o break; } int64_t diff = curr_value - prev_value; - uint64_t zigzag_value = (diff >> (LONG_BYTES * BITS_PER_BYTE - 1)) ^ (diff << 1); + uint64_t zigzag_value = ZIGZAG_ENCODE(int64_t, diff); buffer |= ((zigzag_value & INT64MASK(bit)) << (bit * k + 4)); i++; prev_value = curr_value; @@ -211,7 +210,7 @@ int tsDecompressINTImp(const char *const input, const int nelements, char *const break; default: perror("Wrong integer types.\n"); - exit(1); + return -1; } // If not compressed. @@ -248,30 +247,30 @@ int tsDecompressINTImp(const char *const input, const int nelements, char *const } else { zigzag_value = ((w >> (4 + bit * i)) & INT64MASK(bit)); } - int64_t diff = (zigzag_value >> 1) ^ -(zigzag_value & 1); + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); int64_t curr_value = diff + prev_value; prev_value = curr_value; switch (type) { case TSDB_DATA_TYPE_BIGINT: - *((int64_t *)output + _pos) = curr_value; + *((int64_t *)output + _pos) = (int64_t)curr_value; _pos++; break; case TSDB_DATA_TYPE_INT: - *((int32_t *)output + _pos) = curr_value; + *((int32_t *)output + _pos) = (int32_t)curr_value; _pos++; break; case TSDB_DATA_TYPE_SMALLINT: - *((int16_t *)output + _pos) = curr_value; + *((int16_t *)output + _pos) = (int16_t)curr_value; _pos++; break; case TSDB_DATA_TYPE_TINYINT: - *((int8_t *)output + _pos) = curr_value; + *((int8_t *)output + _pos) = (int8_t)curr_value; _pos++; break; default: perror("Wrong integer types.\n"); - exit(1); + return -1; } count++; if (count == nelements) break; @@ -309,7 +308,7 @@ int tsCompressBoolImp(const char *const input, const int nelements, char *const output[pos] |= t; } else { perror("Wrong bool value.\n"); - exit(1); + return -1; } } @@ -365,7 +364,7 @@ int tsCompressBoolRLEImp(const char *const input, const int nelements, char *con output[_pos++] = (counter << 1) | INT8MASK(0); } else { perror("Wrong bool value!\n"); - exit(1); + return -1; } } @@ -417,7 +416,7 @@ int tsDecompressStringImp(const char *const input, int compressedSize, char *con char msg[128] = {0}; sprintf(msg, "decomp_size:%d, Error decompress in LZ4 algorithm!\n", decompressed_size); perror(msg); - exit(EXIT_FAILURE); + return -1; } return decompressed_size; @@ -427,7 +426,7 @@ int tsDecompressStringImp(const char *const input, int compressedSize, char *con return compressedSize - 1; } else { perror("Wrong compressed string indicator!\n"); - exit(EXIT_FAILURE); + return -1; } } @@ -454,21 +453,21 @@ int tsCompressTimestampImp(const char *const input, const int nelements, char *c if (!safeInt64Add(curr_delta, -prev_delta)) goto _exit_over; int64_t delta_of_delta = curr_delta - prev_delta; // zigzag encode the value. - uint64_t zigzag_value = (delta_of_delta >> (LONG_BYTES * BITS_PER_BYTE - 1)) ^ (delta_of_delta << 1); + uint64_t zigzag_value = ZIGZAG_ENCODE(int64_t, delta_of_delta); if (i % 2 == 0) { flags = 0; dd1 = zigzag_value; if (dd1 == 0) { flag1 = 0; } else { - flag1 = LONG_BYTES - BUILDIN_CLZL(dd1) / BITS_PER_BYTE; + flag1 = (uint8_t)(LONG_BYTES - BUILDIN_CLZL(dd1) / BITS_PER_BYTE); } } else { dd2 = zigzag_value; if (dd2 == 0) { flag2 = 0; } else { - flag2 = LONG_BYTES - BUILDIN_CLZL(dd2) / BITS_PER_BYTE; + flag2 = (uint8_t)(LONG_BYTES - BUILDIN_CLZL(dd2) / BITS_PER_BYTE); } flags = flag1 | (flag2 << 4); // Encode the flag. @@ -555,7 +554,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char } else { memcpy(&dd1, input + ipos, nbytes); } - delta_of_delta = (dd1 >> 1) ^ -(dd1 & 1); + delta_of_delta = ZIGZAG_DECODE(int64_t, dd1); } ipos += nbytes; if (opos == 0) { @@ -581,7 +580,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char memcpy(&dd2, input + ipos, nbytes); } // zigzag_decoding - delta_of_delta = (dd2 >> 1) ^ -(dd2 & 1); + delta_of_delta = ZIGZAG_DECODE(int64_t, dd2); } ipos += nbytes; prev_delta = delta_of_delta + prev_delta; @@ -643,12 +642,12 @@ int tsCompressDoubleImp(const char *const input, const int nelements, char *cons uint8_t flag; if (trailing_zeros > leading_zeros) { - nbytes = LONG_BYTES - trailing_zeros / BITS_PER_BYTE; + nbytes = (uint8_t)(LONG_BYTES - trailing_zeros / BITS_PER_BYTE); if (nbytes > 0) nbytes--; flag = ((uint8_t)1 << 3) | nbytes; } else { - nbytes = LONG_BYTES - leading_zeros / BITS_PER_BYTE; + nbytes = (uint8_t)(LONG_BYTES - leading_zeros / BITS_PER_BYTE); if (nbytes > 0) nbytes--; flag = nbytes; } @@ -790,12 +789,12 @@ int tsCompressFloatImp(const char *const input, const int nelements, char *const uint8_t flag; if (trailing_zeros > leading_zeros) { - nbytes = FLOAT_BYTES - trailing_zeros / BITS_PER_BYTE; + nbytes = (uint8_t)(FLOAT_BYTES - trailing_zeros / BITS_PER_BYTE); if (nbytes > 0) nbytes--; flag = ((uint8_t)1 << 3) | nbytes; } else { - nbytes = FLOAT_BYTES - leading_zeros / BITS_PER_BYTE; + nbytes = (uint8_t)(FLOAT_BYTES - leading_zeros / BITS_PER_BYTE); if (nbytes > 0) nbytes--; flag = nbytes; } diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 9fc9386b42eae0606a21d370b35c95ef82667313..ccf4ea7317ed0e32b0259386e877c2b3ece5962e 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -98,7 +98,7 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) { } static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { - int length = strlen(input_value); + int length = (int)strlen(input_value); char *option = (char *)cfg->ptr; if (length <= 0 || length > cfg->ptrLength) { uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", @@ -150,7 +150,7 @@ static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) { } static void taosReadStringConfig(SGlobalCfg *cfg, char *input_value) { - int length = strlen(input_value); + int length = (int) strlen(input_value); char *option = (char *)cfg->ptr; if (length <= 0 || length > cfg->ptrLength) { uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", @@ -283,7 +283,7 @@ void taosReadGlobalLogCfg() { option = value = NULL; olen = vlen = 0; - getline(&line, &len, fp); + taosGetline(&line, &len, fp); line[len - 1] = 0; paGetToken(line, &option, &olen); @@ -329,7 +329,7 @@ bool taosReadGlobalCfg() { option = value = NULL; olen = vlen = 0; - getline(&line, &len, fp); + taosGetline(&line, &len, fp); line[len - 1] = 0; paGetToken(line, &option, &olen); diff --git a/src/util/src/tcrc32c.c b/src/util/src/tcrc32c.c index 3ef10b1b0dd91c52b235bcd55e388cf0b4bc434e..502116f9c27be1900f1c02d4bc9f2281fd9235af 100644 --- a/src/util/src/tcrc32c.c +++ b/src/util/src/tcrc32c.c @@ -1353,12 +1353,12 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) { #endif // #ifndef _TD_ARM_ void taosResolveCRC() { -#ifndef _TD_ARM_ +#if defined _TD_ARM_ || defined WINDOWS + crc32c = crc32c_sf; +#else int sse42; SSE42(sse42); crc32c = sse42 ? crc32c_hw : crc32c_sf; -#else - crc32c = crc32c_sf; #endif /* return sse42 ? crc32c_hw(crci, bytes, len) : crc32c_sf(crci, bytes, len); */ diff --git a/src/util/src/terror.c b/src/util/src/terror.c index aa6925464e12a1863b8dc510d7389ed97267d142..1eb6893cbc639be013104fe636f6af373a61b3c3 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -49,7 +49,7 @@ static int tsCompareTaosError(const void* a, const void* b) { } static pthread_once_t tsErrorInit = PTHREAD_ONCE_INIT; -static void tsSortError() { +static void tsSortError(void) { qsort(errors, sizeof(errors)/sizeof(errors[0]), sizeof(errors[0]), tsCompareTaosError); } diff --git a/src/util/src/thashutil.c b/src/util/src/thashutil.c index 33f0d6d4302e0a8744bb0bc80e4d231445315cc4..681d73db3d085295f514269ad6201ee6c6dd9508 100644 --- a/src/util/src/thashutil.c +++ b/src/util/src/thashutil.c @@ -78,7 +78,7 @@ uint32_t taosIntHash_64(const char *key, uint32_t UNUSED_PARAM(len)) { uint64_t hash = val >> 16U; hash += (val & 0xFFFFU); - return hash; + return (uint32_t)hash; } _hash_fn_t taosGetDefaultHashFunction(int32_t type) { diff --git a/src/util/src/tkvstore.c b/src/util/src/tkvstore.c index 3231f2301b082bbe1ab7cbe95615d44de1a7a8c4..9657d827730d3eb4a7a0124136ebd3538688e8bc 100644 --- a/src/util/src/tkvstore.c +++ b/src/util/src/tkvstore.c @@ -120,7 +120,7 @@ SKVStore *tdOpenKVStore(char *fname, iterFunc iFunc, afterFunc aFunc, void *appH version, KVSTORE_FILE_VERSION); } - if (ftruncate(pStore->fd, info.size) < 0) { + if (taosFtruncate(pStore->fd, info.size) < 0) { uError("failed to truncate %s to %" PRId64 " size since %s", pStore->fname, info.size, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -296,7 +296,7 @@ int tdDropKVStoreRecord(SKVStore *pStore, uint64_t uid) { return -1; } - pStore->info.magic = taosCalcChecksum(pStore->info.magic, (uint8_t *)buf, POINTER_DISTANCE(pBuf, buf)); + pStore->info.magic = taosCalcChecksum(pStore->info.magic, (uint8_t *)buf, (uint32_t)POINTER_DISTANCE(pBuf, buf)); pStore->info.size += POINTER_DISTANCE(pBuf, buf); pStore->info.nDels++; pStore->info.nRecords--; @@ -498,7 +498,7 @@ static void *tdDecodeKVRecord(void *buf, SKVRecord *pRecord) { static int tdRestoreKVStore(SKVStore *pStore) { char tbuf[128] = "\0"; void * buf = NULL; - int maxBufSize = 0; + int64_t maxBufSize = 0; SKVRecord rInfo = {0}; SHashMutableIterator *pIter = NULL; @@ -535,7 +535,7 @@ static int tdRestoreKVStore(SKVStore *pStore) { maxBufSize = MAX(maxBufSize, rInfo.size); - if (lseek(pStore->fd, rInfo.size, SEEK_CUR) < 0) { + if (lseek(pStore->fd, (off_t)rInfo.size, SEEK_CUR) < 0) { uError("failed to lseek file %s since %s", pStore->fname, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -548,7 +548,7 @@ static int tdRestoreKVStore(SKVStore *pStore) { buf = malloc(maxBufSize); if (buf == NULL) { - uError("failed to allocate %d bytes in KV store %s", maxBufSize, pStore->fname); + uError("failed to allocate %" PRId64 " bytes in KV store %s", maxBufSize, pStore->fname); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; } @@ -563,7 +563,7 @@ static int tdRestoreKVStore(SKVStore *pStore) { while (taosHashIterNext(pIter)) { SKVRecord *pRecord = taosHashIterGet(pIter); - if (lseek(pStore->fd, pRecord->offset + sizeof(SKVRecord), SEEK_SET) < 0) { + if (lseek(pStore->fd, (off_t)(pRecord->offset + sizeof(SKVRecord)), SEEK_SET) < 0) { uError("failed to lseek file %s since %s, offset %" PRId64, pStore->fname, strerror(errno), pRecord->offset); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -577,7 +577,7 @@ static int tdRestoreKVStore(SKVStore *pStore) { } if (pStore->iFunc) { - if ((*pStore->iFunc)(pStore->appH, buf, pRecord->size) < 0) { + if ((*pStore->iFunc)(pStore->appH, buf, (int)pRecord->size) < 0) { uError("failed to restore record uid %" PRIu64 " in kv store %s at offset %" PRId64 " size %" PRId64 " since %s", pRecord->uid, pStore->fname, pRecord->offset, pRecord->size, tstrerror(terrno)); diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 913989bf5286123130b4e08b4eb010362a258397..cf6ccdcbce8c25751bf9014fa696bae5e62ab825 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -65,7 +65,7 @@ typedef struct { int32_t tsAsyncLog = 1; float tsTotalLogDirGB = 0; float tsAvailLogDirGB = 0; -float tsMinimalLogDirGB = 0.1; +float tsMinimalLogDirGB = 0.1f; char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/taos"; static SLogObj tsLogObj = { .fileNum = 1 }; diff --git a/src/util/src/tmempool.c b/src/util/src/tmempool.c index 4a899ebb48271abb4e9894610cee0508bccde68c..a3d10355003c85d993b3a37190081436c0fb19ab 100644 --- a/src/util/src/tmempool.c +++ b/src/util/src/tmempool.c @@ -13,11 +13,7 @@ * along with this program. If not, see . */ -#include -#include -#include -#include - +#include "os.h" #include "tulog.h" #include "tmempool.h" #include "tutil.h" diff --git a/src/util/src/tsched.c b/src/util/src/tsched.c index 39155bc0fd954661e0631fbdde43754b4a0485d3..cf7f5c10d4c369211baddcf43e1ec0d10fea82b1 100644 --- a/src/util/src/tsched.c +++ b/src/util/src/tsched.c @@ -192,12 +192,12 @@ void taosCleanUpScheduler(void *param) { pSched->stop = true; for (int i = 0; i < pSched->numOfThreads; ++i) { - if (pSched->qthread[i]) { + if (taosCheckPthreadValid(pSched->qthread[i])) { tsem_post(&pSched->fullSem); } } for (int i = 0; i < pSched->numOfThreads; ++i) { - if (pSched->qthread[i]) { + if (taosCheckPthreadValid(pSched->qthread[i])) { pthread_join(pSched->qthread[i], NULL); } } diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 14029fbd8137acdaa1a120c2ac6591ebaf018364..303c2440bf9b59282b8347604d58d3368dd312c0 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -19,7 +19,7 @@ #include "tutil.h" #include "tcompare.h" -__attribute__ ((unused)) static FORCE_INLINE void recordNodeEachLevel(SSkipList *pSkipList, int32_t level) { // record link count in each level +UNUSED_FUNC static FORCE_INLINE void recordNodeEachLevel(SSkipList *pSkipList, int32_t level) { // record link count in each level #if SKIP_LIST_RECORD_PERFORMANCE for (int32_t i = 0; i < level; ++i) { pSkipList->state.nLevelNodeCnt[i]++; @@ -27,7 +27,7 @@ __attribute__ ((unused)) static FORCE_INLINE void recordNodeEachLevel(SSkipList #endif } -__attribute__ ((unused)) static FORCE_INLINE void removeNodeEachLevel(SSkipList *pSkipList, int32_t level) { +UNUSED_FUNC static FORCE_INLINE void removeNodeEachLevel(SSkipList *pSkipList, int32_t level) { #if SKIP_LIST_RECORD_PERFORMANCE for (int32_t i = 0; i < level; ++i) { pSkipList->state.nLevelNodeCnt[i]--; @@ -132,7 +132,7 @@ static bool initForwardBackwardPtr(SSkipList* pSkipList) { pSkipList->pTail = (SSkipListNode*) ((char*) pSkipList->pHead + SL_NODE_HEADER_SIZE(maxLevel)); pSkipList->pTail->level = pSkipList->maxLevel; - for(int32_t i = 0; i < maxLevel; ++i) { + for (uint32_t i = 0; i < maxLevel; ++i) { SL_GET_FORWARD_POINTER(pSkipList->pHead, i) = pSkipList->pTail; SL_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pSkipList->pHead; } @@ -177,7 +177,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint8_t keyLen, ui } } - srand(time(NULL)); + srand((uint32_t)time(NULL)); #if SKIP_LIST_RECORD_PERFORMANCE pSkipList->state.nTotalMemSize += sizeof(SSkipList); diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c index b2982d353f2b80d80af25c4ffe579f9256047da5..0222a6d80a3f36bacde9847b1cc326fe22aa389a 100644 --- a/src/util/src/ttimer.c +++ b/src/util/src/ttimer.c @@ -445,7 +445,7 @@ bool taosTmrStopA(tmr_h* timerId) { bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle, tmr_h* pTmrId) { tmr_ctrl_t* ctrl = (tmr_ctrl_t*)handle; if (ctrl == NULL || ctrl->label[0] == 0) { - return NULL; + return false; } uintptr_t id = (uintptr_t)*pTmrId; @@ -491,7 +491,7 @@ static void taosTmrModuleInit(void) { return; } - for (int i = 0; i < tsMaxTmrCtrl - 1; ++i) { + for (uint32_t i = 0; i < tsMaxTmrCtrl - 1; ++i) { tmr_ctrl_t* ctrl = tmrCtrls + i; ctrl->next = ctrl + 1; } diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index f4b6ae629dfbb8cc94035853b52e44b98e9254a0..6c4af437b27b6623aeebb404e0dad1c70241cf47 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -273,7 +273,7 @@ char *strbetween(char *string, char *begin, char *end) { char *_begin = strstr(string, begin); if (_begin != NULL) { char *_end = strstr(_begin + strlen(begin), end); - int size = _end - _begin; + int size = (int)(_end - _begin); if (_end != NULL && size > 0) { result = (char *)calloc(1, size); memcpy(result, _begin + strlen(begin), size - +strlen(begin)); @@ -332,7 +332,7 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) { } int versionNumberPos[5] = {0}; - int len = strlen(versionStr); + int len = (int)strlen(versionStr); int dot = 0; for (int pos = 0; pos < len && dot < 4; ++pos) { if (versionStr[pos] == '.') {