提交 362fb3d3 编写于 作者: S slguan

TD-1037 os module compile

上级 6fd3fc34
...@@ -7,4 +7,7 @@ ADD_SUBDIRECTORY(regex) ...@@ -7,4 +7,7 @@ ADD_SUBDIRECTORY(regex)
ADD_SUBDIRECTORY(iconv) ADD_SUBDIRECTORY(iconv)
ADD_SUBDIRECTORY(lz4) ADD_SUBDIRECTORY(lz4)
ADD_SUBDIRECTORY(cJson) ADD_SUBDIRECTORY(cJson)
ADD_SUBDIRECTORY(MQTT-C)
IF (NOT TD_WINDOWS)
ADD_SUBDIRECTORY(MQTT-C)
ENDIF ()
\ No newline at end of file
...@@ -5,5 +5,7 @@ IF (TD_WINDOWS_64) ...@@ -5,5 +5,7 @@ IF (TD_WINDOWS_64)
LIST(APPEND SRC iconv.c) LIST(APPEND SRC iconv.c)
LIST(APPEND SRC localcharset.c) LIST(APPEND SRC localcharset.c)
INCLUDE_DIRECTORIES(.) 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}) ADD_LIBRARY(iconv ${SRC})
ENDIF () ENDIF ()
\ No newline at end of file
/* 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. This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it The GNU LIBICONV Library is free software; you can redistribute it
......
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}) add_library(lz4 ${SOURCE_LIST})
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX-")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX-")
target_include_directories(lz4 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) target_include_directories(lz4 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc)
\ No newline at end of file
/* /*
* pthread_mutex_consistent.c * pthread_mutex_consistent.c
* *
* Description: * Description:
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_PLATFORM_LINUX_H #ifndef TDENGINE_OS_DARWIN_H
#define TDENGINE_PLATFORM_LINUX_H #define TDENGINE_OS_DARWIN_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_OS_LINUX64_H #ifndef TDENGINE_OS_LINUX32_H
#define TDENGINE_OS_LINUX64_H #define TDENGINE_OS_LINUX32_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_PLATFORM_WINDOWS_H #ifndef TDENGINE_OS_WINDOWS_H
#define TDENGINE_PLATFORM_WINDOWS_H #define TDENGINE_OS_WINDOWS_H
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
......
...@@ -41,7 +41,7 @@ static void taosGetSystemLocale() { ...@@ -41,7 +41,7 @@ static void taosGetSystemLocale() {
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) { if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs"); char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) { if (locale != NULL) {
strncpy(tsLocale, locale, TSDB_LOCALE_LEN - 1); tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT; cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("locale not configured, set to default:%s", tsLocale); uInfo("locale not configured, set to default:%s", tsLocale);
} }
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) 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/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
......
...@@ -70,7 +70,7 @@ ssize_t taosTReadImp(int fd, void *buf, size_t count) { ...@@ -70,7 +70,7 @@ ssize_t taosTReadImp(int fd, void *buf, size_t count) {
char * tbuf = (char *)buf; char * tbuf = (char *)buf;
while (leftbytes > 0) { while (leftbytes > 0) {
readbytes = read(fd, (void *)tbuf, leftbytes); readbytes = read(fd, (void *)tbuf, (uint32_t)leftbytes);
if (readbytes < 0) { if (readbytes < 0) {
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
...@@ -94,7 +94,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) { ...@@ -94,7 +94,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) {
char * tbuf = (char *)buf; char * tbuf = (char *)buf;
while (nleft > 0) { while (nleft > 0) {
nwritten = write(fd, (void *)tbuf, nleft); nwritten = write(fd, (void *)tbuf, (uint32_t)nleft);
if (nwritten < 0) { if (nwritten < 0) {
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
...@@ -105,7 +105,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) { ...@@ -105,7 +105,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) {
tbuf += nwritten; tbuf += nwritten;
} }
return n; return (ssize_t)n;
} }
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE #ifndef TAOS_OS_FUNC_FILE_SENDIFLE
......
...@@ -26,11 +26,11 @@ uint32_t taosSafeRand(void) { ...@@ -26,11 +26,11 @@ uint32_t taosSafeRand(void) {
fd = open("/dev/urandom", 0); fd = open("/dev/urandom", 0);
if (fd < 0) { if (fd < 0) {
seed = time(0); seed = (int)time(0);
} else { } else {
int len = read(fd, &seed, sizeof(seed)); int len = read(fd, &seed, sizeof(seed));
if (len < 0) { if (len < 0) {
seed = time(0); seed = (int)time(0);
} }
close(fd); close(fd);
} }
......
...@@ -165,7 +165,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) { ...@@ -165,7 +165,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
char* sep = strchr(&str[i], ':'); char* sep = strchr(&str[i], ':');
if (sep != NULL) { if (sep != NULL) {
int32_t len = sep - &str[i]; int32_t len = (int32_t)(sep - &str[i]);
hour = strnatoi(&str[i], len); hour = strnatoi(&str[i], len);
i += len + 1; i += len + 1;
...@@ -212,7 +212,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) { ...@@ -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 */ /* mktime will be affected by TZ, set by using taos_options */
#ifdef WINDOWS #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 #else
int64_t seconds = timegm(&tm); int64_t seconds = timegm(&tm);
#endif #endif
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "tulog.h"
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) { void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
const char* tdengineTmpFileNamePrefix = "tdengine-"; const char* tdengineTmpFileNamePrefix = "tdengine-";
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "os.h"
#include <WS2tcpip.h> #include <WS2tcpip.h>
#include <IPHlpApi.h> #include <IPHlpApi.h>
#include <winsock2.h> #include <winsock2.h>
...@@ -33,7 +34,7 @@ void taosWinSocketInit() { ...@@ -33,7 +34,7 @@ void taosWinSocketInit() {
} }
} }
int taosSetNonblocking(SOCKET sock, int on) { int taosSetNonblocking(int sock, int on) {
u_long mode; u_long mode;
if (on) { if (on) {
mode = 1; mode = 1;
......
...@@ -67,7 +67,7 @@ char *getpass(const char *prefix) { ...@@ -67,7 +67,7 @@ char *getpass(const char *prefix) {
} }
char *strndup(const char *s, size_t n) { char *strndup(const char *s, size_t n) {
int len = strlen(s); size_t len = strlen(s);
if (len >= n) { if (len >= n) {
len = n; len = n;
} }
......
...@@ -43,7 +43,7 @@ static void taosGetSystemLocale() { ...@@ -43,7 +43,7 @@ static void taosGetSystemLocale() {
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) { if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs"); char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) { if (locale != NULL) {
tstrncpy(tsLocale, locale, sizeof(tsLocale)); tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);;
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT; cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("locale not configured, set to default:%s", tsLocale); uInfo("locale not configured, set to default:%s", tsLocale);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册