refact
This commit is contained in:
parent
3b227a5f73
commit
bddec203b6
|
@ -20,26 +20,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "osInc.h"
|
||||
#include "osDef.h"
|
||||
#include "osAtomic.h"
|
||||
#include "osDir.h"
|
||||
#include "osFile.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"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
void osInit();
|
||||
#include "osMemory.h"
|
||||
|
||||
#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" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tutil.h"
|
||||
|
||||
// TODO: move this to a platform file
|
||||
#define ENCODE_LIMIT (((uint8_t)1) << 7)
|
||||
static const int32_t TNUMBER = 1;
|
|
@ -1,2 +1,4 @@
|
|||
add_subdirectory(os)
|
||||
add_subdirectory(util)
|
||||
# add_subdirectory(common)
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
|
||||
PROJECT(TDengine)
|
||||
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
AUX_SOURCE_DIRECTORY(src SRC)
|
||||
|
||||
ADD_LIBRARY(common ${SRC})
|
||||
TARGET_LINK_LIBRARIES(common tutil)
|
||||
aux_source_directory(source COMMON_SRC)
|
||||
add_library(common ${COMMON_SRC})
|
||||
target_include_directories(
|
||||
common
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/common"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
target_include_directories(
|
||||
common
|
||||
PRIVATE util
|
||||
)
|
|
@ -1,14 +1,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX)
|
||||
ADD_SUBDIRECTORY(src/linux)
|
||||
ELSEIF (TD_DARWIN)
|
||||
ADD_SUBDIRECTORY(src/darwin)
|
||||
ELSEIF (TD_WINDOWS)
|
||||
ADD_SUBDIRECTORY(src/windows)
|
||||
ENDIF ()
|
||||
|
||||
ADD_SUBDIRECTORY(src/detail)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
|
||||
aux_source_directory(source OS_SRC)
|
||||
add_library(os ${OS_SRC})
|
||||
target_include_directories(
|
||||
os
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/os"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
|
@ -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)
|
||||
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 ()
|
||||
aux_source_directory(source UTIL_SRC)
|
||||
add_library(util ${UTIL_SRC})
|
||||
target_include_directories(
|
||||
util
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/util"
|
||||
PRIVATE "${CMAKE_SOURCE_DIR}/include"
|
||||
)
|
||||
target_link_libraries(
|
||||
util
|
||||
PRIVATE os
|
||||
)
|
|
@ -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 "tutil.h"
|
||||
|
||||
#include "talgo.h"
|
||||
|
||||
#define doswap(__left, __right, __size, __buf) do {\
|
Loading…
Reference in New Issue