diff --git a/src/os/inc/os.h b/src/os/inc/os.h index b71b382176536cc6ba3830c7c3ed8a2138551ef8..6006f1b9690373158300734728a2a21e472a8776 100644 --- a/src/os/inc/os.h +++ b/src/os/inc/os.h @@ -58,7 +58,6 @@ extern "C" { #include "osDef.h" #include "osAtomic.h" -#include "osCommon.h" #include "osDir.h" #include "osFile.h" #include "osLz4.h" diff --git a/src/os/inc/osCommon.h b/src/os/inc/osCommon.h deleted file mode 100644 index 70d2b2c0c243cd13d5309e4c5e25c4bed3bae277..0000000000000000000000000000000000000000 --- a/src/os/inc/osCommon.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_COMMON_H -#define TDENGINE_OS_COMMON_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef TAOS_OS_DEF_ZU - #define PRIzu "zu" -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osDef.h b/src/os/inc/osDef.h index 64ad7e55c48d8a32b8e40578a4c827020858de9f..ac7aac0afa5175e1f43f148d6b7ea5ba9725cdac 100644 --- a/src/os/inc/osDef.h +++ b/src/os/inc/osDef.h @@ -111,6 +111,10 @@ extern "C" { #define threadlocal __declspec( thread ) #endif +#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) + #define PRIzu "ld" +#endif + #ifdef __cplusplus } #endif diff --git a/src/os/inc/osDir.h b/src/os/inc/osDir.h index 540efc310c1d89530d6e41733ce2419ad79b1e36..bdc65e452068cf34fd3969ada6ac69fbf5035217 100644 --- a/src/os/inc/osDir.h +++ b/src/os/inc/osDir.h @@ -20,13 +20,10 @@ extern "C" { #endif -#include - -// TAOS_OS_FUNC_DIR -void taosRemoveDir(char *rootDir); -int taosMkDir(const char *pathname, mode_t mode); -void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays); -int32_t taosRename(char* oldName, char *newName); +void taosRemoveDir(char *rootDir); +int32_t taosMkDir(const char *pathname, mode_t mode); +void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays); +int32_t taosRename(char *oldName, char *newName); int32_t taosCompressFile(char *srcFileName, char *destFileName); #ifdef __cplusplus diff --git a/src/os/inc/osLinux32.h b/src/os/inc/osLinux32.h index eee4999399ace745e6800f81cb09144e828f8cfc..6d9a01a9a899c60e9dcaa0b9691ae724548bb9a8 100644 --- a/src/os/inc/osLinux32.h +++ b/src/os/inc/osLinux32.h @@ -79,12 +79,6 @@ extern "C" { #include #include -#define TAOS_OS_FUNC_LZ4 -#define BUILDIN_CLZL(val) __builtin_clzll(val) -#define BUILDIN_CTZL(val) __builtin_ctzll(val) -#define BUILDIN_CLZ(val) __builtin_clz(val) -#define BUILDIN_CTZ(val) __builtin_ctz(val) - #ifdef __cplusplus } #endif diff --git a/src/os/inc/osLz4.h b/src/os/inc/osLz4.h index a944892c482470a60c17a13f693c19801bde2081..8363861e0348141243c49c9df72b4aac7b6c199d 100644 --- a/src/os/inc/osLz4.h +++ b/src/os/inc/osLz4.h @@ -20,7 +20,22 @@ extern "C" { #endif -#ifndef TAOS_OS_FUNC_LZ4 +#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) + 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); +#elif defined (_TD_LINUX_32) + #define BUILDIN_CLZL(val) __builtin_clzll(val) + #define BUILDIN_CTZL(val) __builtin_ctzll(val) + #define BUILDIN_CLZ(val) __builtin_clz(val) + #define BUILDIN_CTZ(val) __builtin_ctz(val) +#elif defined (_TD_ARM_32) + #define BUILDIN_CLZL(val) __builtin_clzll(val) + #define BUILDIN_CTZL(val) __builtin_ctzll(val) + #define BUILDIN_CLZ(val) __builtin_clz(val) + #define BUILDIN_CTZ(val) __builtin_ctz(val) +#else #define BUILDIN_CLZL(val) __builtin_clzl(val) #define BUILDIN_CTZL(val) __builtin_ctzl(val) #define BUILDIN_CLZ(val) __builtin_clz(val) diff --git a/src/os/inc/osMath.h b/src/os/inc/osMath.h index 9935f94d39ef0431b7c9b1a524b956e6fafe9f4f..65e8a1f6feaf32bff7f413b7085fc64835ba70fb 100644 --- a/src/os/inc/osMath.h +++ b/src/os/inc/osMath.h @@ -23,26 +23,38 @@ extern "C" { #define POW2(x) ((x) * (x)) #define ABS(x) ((x) > 0 ? (x) : -(x)) -#ifndef TAOS_OS_FUNC_MATH - #define SWAP(a, b, c) \ - do { \ - typeof(a) __tmp = (a); \ - (a) = (b); \ - (b) = __tmp; \ +#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) + + #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)) + +#else + + #define SWAP(a, b, c) \ + do { \ + typeof(a) __tmp = (a); \ + (a) = (b); \ + (b) = __tmp; \ } while (0) - #define MAX(a, b) \ - ({ \ - typeof(a) __a = (a); \ - typeof(b) __b = (b); \ - (__a > __b) ? __a : __b; \ + #define MAX(a, b) \ + ({ \ + typeof(a) __a = (a); \ + typeof(b) __b = (b); \ + (__a > __b) ? __a : __b; \ }) - #define MIN(a, b) \ - ({ \ - typeof(a) __a = (a); \ - typeof(b) __b = (b); \ - (__a < __b) ? __a : __b; \ + #define MIN(a, b) \ + ({ \ + typeof(a) __a = (a); \ + typeof(b) __b = (b); \ + (__a < __b) ? __a : __b; \ }) #endif diff --git a/src/os/inc/osWindows.h b/src/os/inc/osWindows.h index 68b6834def3f6c722bd793cb91077f6ecb01c6d5..5fd32711f9a0406f59bbb60f599ff4a6c24d65f3 100644 --- a/src/os/inc/osWindows.h +++ b/src/os/inc/osWindows.h @@ -55,11 +55,6 @@ extern "C" { #endif -#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_FILE #define TAOS_OS_FUNC_FILE_ISREG @@ -69,17 +64,6 @@ extern "C" { #define TAOS_OS_FUNC_FILE_GETTMPFILEPATH #define TAOS_OS_FUNC_FILE_FTRUNCATE -#define TAOS_OS_FUNC_DIR - -#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_SEMPHONE_PTHREAD @@ -104,9 +88,6 @@ typedef SOCKET eventfd_t; #define EPOLLWAKEUP (1u << 29) #endif -#define TAOS_OS_DEF_ZU - #define PRIzu "ld" - #define TAOS_OS_FUNC_STRING_WCHAR int twcslen(const wchar_t *wcs); #define TAOS_OS_FUNC_STRING_GETLINE diff --git a/src/os/src/darwin/darwinFile.c b/src/os/src/darwin/darwinFile.c deleted file mode 100644 index bcca3fa53d1efb017843fb925781631730e701ff..0000000000000000000000000000000000000000 --- a/src/os/src/darwin/darwinFile.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "tulog.h" - - - diff --git a/src/os/src/detail/osDir.c b/src/os/src/detail/osDir.c index 144c59fa2db3ae24a81679de16116812fddbccc5..2a2e2519b5dadf94ee8641064735e92267394a87 100644 --- a/src/os/src/detail/osDir.c +++ b/src/os/src/detail/osDir.c @@ -28,7 +28,7 @@ void taosRemoveDir(char *rootDir) { struct dirent *de = NULL; while ((de = readdir(dir)) != NULL) { if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue; - + char filename[1024]; snprintf(filename, 1023, "%s/%s", rootDir, de->d_name); if (de->d_type & DT_DIR) { @@ -51,27 +51,11 @@ int taosMkDir(const char *path, mode_t mode) { return code; } - -#ifndef TAOS_OS_FUNC_DIR - -int32_t taosRename(char* oldName, char *newName) { - int32_t code = rename(oldName, newName); - if (code < 0) { - uError("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno)); - } else { - uTrace("successfully to rename file %s to %s", oldName, newName); - } - - return code; -} - -#endif - void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) { DIR *dir = opendir(rootDir); if (dir == NULL) return; - int64_t sec = taosGetTimestampSec(); + int64_t sec = taosGetTimestampSec(); struct dirent *de = NULL; while ((de = readdir(dir)) != NULL) { diff --git a/src/os/src/windows/wFile.c b/src/os/src/windows/wFile.c deleted file mode 100644 index ee97062b38b774b042ce2fc022ab7cebfe8000b8..0000000000000000000000000000000000000000 --- a/src/os/src/windows/wFile.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "osSocket.h" -#include "tglobal.h" -#include "tulog.h" - - - - - -