refact
This commit is contained in:
parent
3b227a5f73
commit
bddec203b6
|
@ -20,26 +20,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "osInc.h"
|
#include <stdbool.h>
|
||||||
#include "osDef.h"
|
#include <stdint.h>
|
||||||
#include "osAtomic.h"
|
#include <stdlib.h>
|
||||||
#include "osDir.h"
|
#include <string.h>
|
||||||
#include "osFile.h"
|
#include <assert.h>
|
||||||
#include "osLz4.h"
|
|
||||||
#include "osMath.h"
|
|
||||||
#include "osMemory.h"
|
|
||||||
#include "osRand.h"
|
|
||||||
#include "osSemaphore.h"
|
|
||||||
#include "osSignal.h"
|
|
||||||
#include "osSleep.h"
|
|
||||||
#include "osSocket.h"
|
|
||||||
#include "osString.h"
|
|
||||||
#include "osSysinfo.h"
|
|
||||||
#include "osTime.h"
|
|
||||||
#include "osTimer.h"
|
|
||||||
#include "osSystem.h"
|
|
||||||
|
|
||||||
void osInit();
|
#include "osMemory.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_OS_MEMORY_H_
|
||||||
|
#define _TD_OS_MEMORY_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define tfree(x) \
|
||||||
|
do { \
|
||||||
|
if (x) { \
|
||||||
|
free((void *)x); \
|
||||||
|
x = 0; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_OS_MEMORY_H_*/
|
|
@ -19,11 +19,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tutil.h"
|
|
||||||
|
|
||||||
// TODO: move this to a platform file
|
// TODO: move this to a platform file
|
||||||
#define ENCODE_LIMIT (((uint8_t)1) << 7)
|
#define ENCODE_LIMIT (((uint8_t)1) << 7)
|
||||||
static const int32_t TNUMBER = 1;
|
static const int32_t TNUMBER = 1;
|
|
@ -1,2 +1,4 @@
|
||||||
add_subdirectory(os)
|
add_subdirectory(os)
|
||||||
|
add_subdirectory(util)
|
||||||
|
# add_subdirectory(common)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
|
aux_source_directory(source COMMON_SRC)
|
||||||
PROJECT(TDengine)
|
add_library(common ${COMMON_SRC})
|
||||||
|
target_include_directories(
|
||||||
INCLUDE_DIRECTORIES(inc)
|
common
|
||||||
AUX_SOURCE_DIRECTORY(src SRC)
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/common"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
ADD_LIBRARY(common ${SRC})
|
)
|
||||||
TARGET_LINK_LIBRARIES(common tutil)
|
target_include_directories(
|
||||||
|
common
|
||||||
|
PRIVATE util
|
||||||
|
)
|
|
@ -1,14 +1,7 @@
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
|
aux_source_directory(source OS_SRC)
|
||||||
PROJECT(TDengine)
|
add_library(os ${OS_SRC})
|
||||||
|
target_include_directories(
|
||||||
IF (TD_LINUX)
|
os
|
||||||
ADD_SUBDIRECTORY(src/linux)
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/os"
|
||||||
ELSEIF (TD_DARWIN)
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
ADD_SUBDIRECTORY(src/darwin)
|
)
|
||||||
ELSEIF (TD_WINDOWS)
|
|
||||||
ADD_SUBDIRECTORY(src/windows)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(src/detail)
|
|
||||||
ADD_SUBDIRECTORY(tests)
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
|
@ -1,44 +1,11 @@
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
|
aux_source_directory(source UTIL_SRC)
|
||||||
PROJECT(TDengine)
|
add_library(util ${UTIL_SRC})
|
||||||
|
target_include_directories(
|
||||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/rpc/inc)
|
util
|
||||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/sync/inc)
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/util"
|
||||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/rmonotonic/inc)
|
PRIVATE "${CMAKE_SOURCE_DIR}/include"
|
||||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/TSZ/sz/include)
|
)
|
||||||
|
target_link_libraries(
|
||||||
AUX_SOURCE_DIRECTORY(src SRC)
|
util
|
||||||
ADD_LIBRARY(tutil ${SRC})
|
PRIVATE os
|
||||||
|
)
|
||||||
TARGET_LINK_LIBRARIES(tutil pthread os lz4 z rmonotonic ${VAR_TSZ} )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IF (TD_LINUX)
|
|
||||||
TARGET_LINK_LIBRARIES(tutil m rt)
|
|
||||||
ADD_SUBDIRECTORY(tests)
|
|
||||||
|
|
||||||
FIND_PATH(ICONV_INCLUDE_EXIST iconv.h /usr/include/ /usr/local/include/)
|
|
||||||
IF (ICONV_INCLUDE_EXIST)
|
|
||||||
FIND_PATH(ICONV_LIBRARY_A_EXIST libiconv.a /usr/lib/ /usr/local/lib/ /lib64)
|
|
||||||
FIND_PATH(ICONV_LIBRARY_SO_EXIST libiconv.so /usr/lib/ /usr/local/lib/ /lib64)
|
|
||||||
IF (ICONV_LIBRARY_A_EXIST OR ICONV_LIBRARY_SO_EXIST)
|
|
||||||
MESSAGE(STATUS "Use the installed libiconv library")
|
|
||||||
TARGET_LINK_LIBRARIES(tutil iconv)
|
|
||||||
ELSE ()
|
|
||||||
# libiconv library is already included in GLIBC,
|
|
||||||
MESSAGE(STATUS "Use the iconv functions in GLIBC")
|
|
||||||
ENDIF ()
|
|
||||||
ELSE ()
|
|
||||||
MESSAGE(STATUS "Failed to find iconv, use default encoding method")
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
ELSEIF (TD_WINDOWS)
|
|
||||||
TARGET_LINK_LIBRARIES(tutil iconv regex winmm IPHLPAPI ws2_32 wepoll)
|
|
||||||
ELSEIF(TD_DARWIN)
|
|
||||||
TARGET_LINK_LIBRARIES(tutil m)
|
|
||||||
TARGET_LINK_LIBRARIES(tutil iconv)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF (TD_STORAGE)
|
|
||||||
TARGET_LINK_LIBRARIES(tutil storage)
|
|
||||||
ENDIF ()
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
|
||||||
|
PROJECT(TDengine)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/rpc/inc)
|
||||||
|
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/sync/inc)
|
||||||
|
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/rmonotonic/inc)
|
||||||
|
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/TSZ/sz/include)
|
||||||
|
|
||||||
|
AUX_SOURCE_DIRECTORY(src SRC)
|
||||||
|
ADD_LIBRARY(tutil ${SRC})
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(tutil pthread os lz4 z rmonotonic ${VAR_TSZ} )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IF (TD_LINUX)
|
||||||
|
TARGET_LINK_LIBRARIES(tutil m rt)
|
||||||
|
ADD_SUBDIRECTORY(tests)
|
||||||
|
|
||||||
|
FIND_PATH(ICONV_INCLUDE_EXIST iconv.h /usr/include/ /usr/local/include/)
|
||||||
|
IF (ICONV_INCLUDE_EXIST)
|
||||||
|
FIND_PATH(ICONV_LIBRARY_A_EXIST libiconv.a /usr/lib/ /usr/local/lib/ /lib64)
|
||||||
|
FIND_PATH(ICONV_LIBRARY_SO_EXIST libiconv.so /usr/lib/ /usr/local/lib/ /lib64)
|
||||||
|
IF (ICONV_LIBRARY_A_EXIST OR ICONV_LIBRARY_SO_EXIST)
|
||||||
|
MESSAGE(STATUS "Use the installed libiconv library")
|
||||||
|
TARGET_LINK_LIBRARIES(tutil iconv)
|
||||||
|
ELSE ()
|
||||||
|
# libiconv library is already included in GLIBC,
|
||||||
|
MESSAGE(STATUS "Use the iconv functions in GLIBC")
|
||||||
|
ENDIF ()
|
||||||
|
ELSE ()
|
||||||
|
MESSAGE(STATUS "Failed to find iconv, use default encoding method")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
ELSEIF (TD_WINDOWS)
|
||||||
|
TARGET_LINK_LIBRARIES(tutil iconv regex winmm IPHLPAPI ws2_32 wepoll)
|
||||||
|
ELSEIF(TD_DARWIN)
|
||||||
|
TARGET_LINK_LIBRARIES(tutil m)
|
||||||
|
TARGET_LINK_LIBRARIES(tutil iconv)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF (TD_STORAGE)
|
||||||
|
TARGET_LINK_LIBRARIES(tutil storage)
|
||||||
|
ENDIF ()
|
|
@ -14,7 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tutil.h"
|
|
||||||
#include "talgo.h"
|
#include "talgo.h"
|
||||||
|
|
||||||
#define doswap(__left, __right, __size, __buf) do {\
|
#define doswap(__left, __right, __size, __buf) do {\
|
Loading…
Reference in New Issue