Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8089a23c
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8089a23c
编写于
7月 31, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-992]
上级
a0c3a007
变更
40
显示空白变更内容
内联
并排
Showing
40 changed file
with
278 addition
and
451 deletion
+278
-451
src/os/inc/os.h
src/os/inc/os.h
+3
-7
src/os/inc/osDarwin.h
src/os/inc/osDarwin.h
+9
-9
src/os/inc/osFile.h
src/os/inc/osFile.h
+1
-1
src/os/inc/osSemphone.h
src/os/inc/osSemphone.h
+1
-1
src/os/inc/osSocket.h
src/os/inc/osSocket.h
+13
-11
src/os/inc/osString.h
src/os/inc/osString.h
+2
-0
src/os/inc/osWindows.h
src/os/inc/osWindows.h
+46
-37
src/os/inc/osWindows32.h
src/os/inc/osWindows32.h
+0
-54
src/os/src/darwin/CMakeLists.txt
src/os/src/darwin/CMakeLists.txt
+0
-0
src/os/src/darwin/darwinEnv.c
src/os/src/darwin/darwinEnv.c
+0
-0
src/os/src/darwin/darwinFile.c
src/os/src/darwin/darwinFile.c
+0
-0
src/os/src/darwin/darwinSemphone.c
src/os/src/darwin/darwinSemphone.c
+0
-0
src/os/src/darwin/darwinSocket.c
src/os/src/darwin/darwinSocket.c
+0
-0
src/os/src/darwin/darwinString.c
src/os/src/darwin/darwinString.c
+0
-0
src/os/src/darwin/darwinSysInfo.c
src/os/src/darwin/darwinSysInfo.c
+0
-0
src/os/src/darwin/darwinTimer.c
src/os/src/darwin/darwinTimer.c
+0
-0
src/os/src/detail/osFile.c
src/os/src/detail/osFile.c
+1
-1
src/os/src/detail/osSemphone.c
src/os/src/detail/osSemphone.c
+1
-1
src/os/src/detail/osString.c
src/os/src/detail/osString.c
+1
-5
src/os/src/detail/osTimer.c
src/os/src/detail/osTimer.c
+1
-1
src/os/src/windows/CMakeLists.txt
src/os/src/windows/CMakeLists.txt
+0
-0
src/os/src/windows/w64Atomic.c
src/os/src/windows/w64Atomic.c
+0
-0
src/os/src/windows/w64Env.c
src/os/src/windows/w64Env.c
+0
-0
src/os/src/windows/w64File.c
src/os/src/windows/w64File.c
+22
-5
src/os/src/windows/w64Getline.c
src/os/src/windows/w64Getline.c
+124
-0
src/os/src/windows/w64Godll.c
src/os/src/windows/w64Godll.c
+3
-4
src/os/src/windows/w64Lz4.c
src/os/src/windows/w64Lz4.c
+0
-0
src/os/src/windows/w64Semphone.c
src/os/src/windows/w64Semphone.c
+0
-0
src/os/src/windows/w64Socket.c
src/os/src/windows/w64Socket.c
+0
-0
src/os/src/windows/w64String.c
src/os/src/windows/w64String.c
+47
-33
src/os/src/windows/w64Strptime.c
src/os/src/windows/w64Strptime.c
+0
-0
src/os/src/windows/w64Sysinfo.c
src/os/src/windows/w64Sysinfo.c
+3
-1
src/os/src/windows/w64Time.c
src/os/src/windows/w64Time.c
+0
-0
src/os/src/windows/w64Timer.c
src/os/src/windows/w64Timer.c
+0
-0
src/os/src/windows/w64Wordexp.c
src/os/src/windows/w64Wordexp.c
+0
-0
src/os/src/windows64/w64Coredump.c
src/os/src/windows64/w64Coredump.c
+0
-23
src/os/src/windows64/w64File.c
src/os/src/windows64/w64File.c
+0
-38
src/os/src/windows64/w64Msghdr.c
src/os/src/windows64/w64Msghdr.c
+0
-56
src/os/src/windows64/w64String.c
src/os/src/windows64/w64String.c
+0
-92
src/os/src/windows64/w64Wchar.c
src/os/src/windows64/w64Wchar.c
+0
-71
未找到文件。
src/os/inc/os.h
浏览文件 @
8089a23c
...
@@ -21,7 +21,7 @@ extern "C" {
...
@@ -21,7 +21,7 @@ extern "C" {
#endif
#endif
#ifdef _TD_DARWIN_64
#ifdef _TD_DARWIN_64
#include "osDarwin
64
.h"
#include "osDarwin.h"
#endif
#endif
#ifdef _TD_LINUX_64
#ifdef _TD_LINUX_64
...
@@ -36,12 +36,8 @@ extern "C" {
...
@@ -36,12 +36,8 @@ extern "C" {
#include "osAlpine.h"
#include "osAlpine.h"
#endif
#endif
#ifdef _TD_WINDOWS_64
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#include "osWindows64.h"
#include "osWindows.h"
#endif
#ifdef _TD_WINDOWS_32
#include "osWindows32.h"
#endif
#endif
#include "osAtomic.h"
#include "osAtomic.h"
...
...
src/os/inc/osDarwin
64
.h
→
src/os/inc/osDarwin.h
浏览文件 @
8089a23c
...
@@ -71,21 +71,21 @@ extern "C" {
...
@@ -71,21 +71,21 @@ extern "C" {
#include <fcntl.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <sys/utsname.h>
#define TAOS_OS_FUNC_FILE_
T
SENDIFLE
#define TAOS_OS_FUNC_FILE_SENDIFLE
#define taosFSendFile(outfile, infile, offset, count) taosFSendFileImp(outfile, infile, offset, size)
#define taosFSendFile(outfile, infile, offset, count) taosFSendFileImp(outfile, infile, offset, size)
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
#define TAOS_OS_FUNC_SEMPHONE
#define TAOS_OS_FUNC_SEMPHONE
#define tsem_t dispatch_semaphore_t
#define tsem_t dispatch_semaphore_t
int
tsem_init
(
dispatch_semaphore_t
*
sem
,
int
pshared
,
unsigned
int
value
);
int
tsem_init
(
dispatch_semaphore_t
*
sem
,
int
pshared
,
unsigned
int
value
);
int
tsem_wait
(
dispatch_semaphore_t
*
sem
);
int
tsem_wait
(
dispatch_semaphore_t
*
sem
);
int
tsem_post
(
dispatch_semaphore_t
*
sem
);
int
tsem_post
(
dispatch_semaphore_t
*
sem
);
int
tsem_destroy
(
dispatch_semaphore_t
*
sem
);
int
tsem_destroy
(
dispatch_semaphore_t
*
sem
);
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#define TAOS_OS_FUNC_STRING_STR2INT64
#define TAOS_OS_FUNC_SYSINFO
#define TAOS_OS_FUNC_SYSINFO
#define TAOS_OS_FUNC_TIMER
#define TAOS_OS_FUNC_TIMER
#define TAOS_OS_FUNC_STRING_STR2INT64
// specific
// specific
#define htobe64 htonll
#define htobe64 htonll
...
...
src/os/inc/osFile.h
浏览文件 @
8089a23c
...
@@ -26,7 +26,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t count);
...
@@ -26,7 +26,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t count);
ssize_t
taosTSendFileImp
(
int
dfd
,
int
sfd
,
off_t
*
offset
,
size_t
size
);
ssize_t
taosTSendFileImp
(
int
dfd
,
int
sfd
,
off_t
*
offset
,
size_t
size
);
int
taosFSendFileImp
(
FILE
*
out_file
,
FILE
*
in_file
,
int64_t
*
offset
,
int32_t
count
);
int
taosFSendFileImp
(
FILE
*
out_file
,
FILE
*
in_file
,
int64_t
*
offset
,
int32_t
count
);
#ifndef TAOS_OS_FUNC_FILE_
T
SENDIFLE
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
#define taosFSendFile(outfile, infile, offset, count) taosTSendFileImp(fileno(outfile), fileno(infile), offset, size)
#define taosFSendFile(outfile, infile, offset, count) taosTSendFileImp(fileno(outfile), fileno(infile), offset, size)
#endif
#endif
...
...
src/os/inc/osSemphone.h
浏览文件 @
8089a23c
...
@@ -28,7 +28,7 @@ extern "C" {
...
@@ -28,7 +28,7 @@ extern "C" {
#define tsem_destroy sem_destroy
#define tsem_destroy sem_destroy
#endif
#endif
// TAOS_OS_FUNC_PTHREAD
// TAOS_OS_FUNC_
SEMPHONE_
PTHREAD
bool
taosCheckPthreadValid
(
pthread_t
thread
);
bool
taosCheckPthreadValid
(
pthread_t
thread
);
int64_t
taosGetPthreadId
();
int64_t
taosGetPthreadId
();
...
...
src/os/inc/osSocket.h
浏览文件 @
8089a23c
...
@@ -20,17 +20,19 @@
...
@@ -20,17 +20,19 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
#ifndef TAOS_OS_FUNC_SOCKET_OP
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, buf, len, flags, dest_addr, addrlen)
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
#define taosReadSocket(fd, buf, len) read(fd, buf, len)
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, buf, len, flags, dest_addr, addrlen)
#define taosWriteSocket(fd, buf, len) write(fd, buf, len)
#define taosReadSocket(fd, buf, len) read(fd, buf, len)
#define taosCloseSocket(x) \
#define taosWriteSocket(fd, buf, len) write(fd, buf, len)
#define taosCloseSocket(x) \
{ \
{ \
if (FD_VALID(x)) { \
if (FD_VALID(x)) { \
close(x); \
close(x); \
x = FD_INITIALIZER; \
x = FD_INITIALIZER; \
} \
} \
}
}
#endif
#define taosClose(x) taosCloseSocket(x)
#define taosClose(x) taosCloseSocket(x)
...
...
src/os/inc/osString.h
浏览文件 @
8089a23c
...
@@ -27,6 +27,8 @@ extern "C" {
...
@@ -27,6 +27,8 @@ extern "C" {
#ifndef TAOS_OS_FUNC_STRING_GETLINE
#ifndef TAOS_OS_FUNC_STRING_GETLINE
#define taosGetlineImp(lineptr, n, stream) getline(lineptr, n , stream)
#define taosGetlineImp(lineptr, n, stream) getline(lineptr, n , stream)
#else
int
taosGetlineImp
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
);
#endif
#endif
#ifndef TAOS_OS_FUNC_STRING_WCHAR
#ifndef TAOS_OS_FUNC_STRING_WCHAR
...
...
src/os/inc/osWindows
64
.h
→
src/os/inc/osWindows.h
浏览文件 @
8089a23c
...
@@ -48,16 +48,7 @@
...
@@ -48,16 +48,7 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define TAOS_OS_FUNC_STRING_WCHAR
#define TAOS_OS_FUNC_ATOMIC
#define TAOS_OS_FUNC_FILE
#define TAOS_OS_FUNC_SLEEP
#define TAOS_OS_FUNC_TIMER
#define TAOS_OS_FUNC_SOCKET
#define TAOS_OS_FUNC_PTHREAD
#define TAOS_OS_FUNC_FILEOP
#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_LZ4
#define TAOS_OS_FUNC_LZ4
int32_t
BUILDIN_CLZL
(
uint64_t
val
);
int32_t
BUILDIN_CLZL
(
uint64_t
val
);
...
@@ -65,13 +56,13 @@ extern "C" {
...
@@ -65,13 +56,13 @@ extern "C" {
int32_t
BUILDIN_CTZL
(
uint64_t
val
);
int32_t
BUILDIN_CTZL
(
uint64_t
val
);
int32_t
BUILDIN_CTZ
(
uint32_t
val
);
int32_t
BUILDIN_CTZ
(
uint32_t
val
);
#define TAOS_OS_FUNC_
STRING_STR2INT64
#define TAOS_OS_FUNC_
DIR
#ifdef _TD_GO_DLL_
int64_t
tsosStr2int64
(
char
*
str
);
#define TAOS_OS_FUNC_FILE
uint64_t
htonll
(
uint64_t
val
);
#define TAOS_OS_FUNC_FILE_SENDIFLE
#
else
#
define taosFSendFile(outfile, infile, offset, count) taosFSendFileImp(outfile, infile, offset, size)
#define tsosStr2int64 _atoi64
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
#endif
#define TAOS_OS_FUNC_FILE_GETTMPFILEPATH
#define TAOS_OS_FUNC_MATH
#define TAOS_OS_FUNC_MATH
#define SWAP(a, b, c) \
#define SWAP(a, b, c) \
...
@@ -80,26 +71,60 @@ extern "C" {
...
@@ -80,26 +71,60 @@ extern "C" {
(a) = (c)(b); \
(a) = (c)(b); \
(b) = __tmp; \
(b) = __tmp; \
} while (0)
} while (0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define TAOS_OS_FUNC_NETWORK
#define TAOS_OS_FUNC_SEMPHONE_PTHREAD
#define TAOS_OS_FUNC_SOCKET
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#define TAOS_OS_FUNC_SOCKET_OP
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, buf, len, flags, dest_addr, addrlen)
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, buf, len, flags, dest_addr, addrlen)
#define taosWriteSocket(fd, buf, len) send(fd, buf, len, 0)
#define taosWriteSocket(fd, buf, len) send(fd, buf, len, 0)
#define taosReadSocket(fd, buf, len) recv(fd, buf, len, 0)
#define taosReadSocket(fd, buf, len) recv(fd, buf, len, 0)
#define taosCloseSocket(fd) closesocket(fd)
#define taosCloseSocket(fd) closesocket(fd)
#define TAOS_OS_DEF_TIME
#define TAOS_OS_FUNC_STRING_WCHAR
#define TAOS_OS_FUNC_STRING_GETLINE
#define TAOS_OS_FUNC_STRING_STR2INT64
#ifdef _TD_GO_DLL_
int64_t
tsosStr2int64
(
char
*
str
);
uint64_t
htonll
(
uint64_t
val
);
#else
#define tsosStr2int64 _atoi64
#endif
#define TAOS_OS_FUNC_STRING_STRDUP
#define taosStrdupImp(str) _strdup(str)
#define taosStrndupImp(str, size) _strndup(str, size)
#define TAOS_OS_FUNC_SYSINFO
#define TAOS_OS_FUNC_TIME_DEF
#ifdef _TD_GO_DLL_
#ifdef _TD_GO_DLL_
#define MILLISECOND_PER_SECOND (1000LL)
#define MILLISECOND_PER_SECOND (1000LL)
#else
#else
#define MILLISECOND_PER_SECOND (1000i64)
#define MILLISECOND_PER_SECOND (1000i64)
#endif
#endif
#define TAOS_OS_FUNC_TIMER_SLEEP
#define TAOS_OS_FUNC_TIMER
// specific
typedef
int
(
*
__compar_fn_t
)(
const
void
*
,
const
void
*
);
typedef
int
(
*
__compar_fn_t
)(
const
void
*
,
const
void
*
);
int
getline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
);
#define ssize_t int
#define bzero(ptr, size) memset((ptr), 0, (size))
#define mkdir(pathname, mode) _mkdir(pathname)
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define wcsncasecmp _wcsnicmp
#define strtok_r strtok_s
#define snprintf _snprintf
#define in_addr_t unsigned long
#define socklen_t int
#define htobe64 htonll
#define twrite write
int
gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
);
int
gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
);
struct
tm
*
localtime_r
(
const
time_t
*
timep
,
struct
tm
*
result
);
struct
tm
*
localtime_r
(
const
time_t
*
timep
,
struct
tm
*
result
);
char
*
strptime
(
const
char
*
buf
,
const
char
*
fmt
,
struct
tm
*
tm
);
char
*
strptime
(
const
char
*
buf
,
const
char
*
fmt
,
struct
tm
*
tm
);
...
@@ -109,9 +134,6 @@ int flock(int fd, int option);
...
@@ -109,9 +134,6 @@ int flock(int fd, int option);
int
fsync
(
int
filedes
);
int
fsync
(
int
filedes
);
char
*
strndup
(
const
char
*
s
,
size_t
n
);
char
*
strndup
(
const
char
*
s
,
size_t
n
);
#define strdup _strdup
#define ssize_t int
// for function open in stat.h
// for function open in stat.h
#define S_IRWXU _S_IREAD
#define S_IRWXU _S_IREAD
#define S_IRWXG _S_IWRITE
#define S_IRWXG _S_IWRITE
...
@@ -135,19 +157,6 @@ char * strndup(const char *s, size_t n);
...
@@ -135,19 +157,6 @@ char * strndup(const char *s, size_t n);
#define LOCK_NB 2
#define LOCK_NB 2
#define LOCK_UN 3
#define LOCK_UN 3
#define bzero(ptr, size) memset((ptr), 0, (size))
#define mkdir(pathname, mode) _mkdir(pathname)
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define wcsncasecmp _wcsnicmp
#define strtok_r strtok_s
#define snprintf _snprintf
#define in_addr_t unsigned long
#define socklen_t int
#define htobe64 htonll
#define twrite write
#ifndef PATH_MAX
#ifndef PATH_MAX
#define PATH_MAX 256
#define PATH_MAX 256
#endif
#endif
...
...
src/os/inc/osWindows32.h
已删除
100644 → 0
浏览文件 @
a0c3a007
/*
* 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 TDENGINE_PLATFORM_WINDOWS32_H
#define TDENGINE_PLATFORM_WINDOWS32_H
#include <assert.h>
#include <ctype.h>
#include <direct.h>
#include <errno.h>
#include <fcntl.h>
#include <float.h>
#include <locale.h>
#include <intrin.h>
#include <io.h>
#include <math.h>
#include <pthread.h>
#include <semaphore.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <inttypes.h>
#include "winsock2.h"
#include <WS2tcpip.h>
#include <winbase.h>
#include <Winsock2.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
\ No newline at end of file
src/os/src/darwin
64
/CMakeLists.txt
→
src/os/src/darwin/CMakeLists.txt
浏览文件 @
8089a23c
文件已移动
src/os/src/darwin
64
/darwinEnv.c
→
src/os/src/darwin/darwinEnv.c
浏览文件 @
8089a23c
文件已移动
src/os/src/darwin
64
/darwinFile.c
→
src/os/src/darwin/darwinFile.c
浏览文件 @
8089a23c
文件已移动
src/os/src/darwin
64
/darwinSemphone.c
→
src/os/src/darwin/darwinSemphone.c
浏览文件 @
8089a23c
文件已移动
src/os/src/darwin
64
/darwinSocket.c
→
src/os/src/darwin/darwinSocket.c
浏览文件 @
8089a23c
文件已移动
src/os/src/darwin
64
/darwinString.c
→
src/os/src/darwin/darwinString.c
浏览文件 @
8089a23c
文件已移动
src/os/src/darwin
64
/darwinSysInfo.c
→
src/os/src/darwin/darwinSysInfo.c
浏览文件 @
8089a23c
文件已移动
src/os/src/darwin
64
/darwinTimer.c
→
src/os/src/darwin/darwinTimer.c
浏览文件 @
8089a23c
文件已移动
src/os/src/detail/osFile.c
浏览文件 @
8089a23c
...
@@ -109,7 +109,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) {
...
@@ -109,7 +109,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) {
return
n
;
return
n
;
}
}
#ifndef TAOS_OS_FUNC_FILE_
T
SENDIFLE
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
ssize_t
taosTSendFileImp
(
int
dfd
,
int
sfd
,
off_t
*
offset
,
size_t
size
)
{
ssize_t
taosTSendFileImp
(
int
dfd
,
int
sfd
,
off_t
*
offset
,
size_t
size
)
{
size_t
leftbytes
=
size
;
size_t
leftbytes
=
size
;
ssize_t
sentbytes
;
ssize_t
sentbytes
;
...
...
src/os/src/detail/osSemphone.c
浏览文件 @
8089a23c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#ifndef TAOS_OS_FUNC_PTHREAD
#ifndef TAOS_OS_FUNC_
SEMPHONE_
PTHREAD
bool
taosCheckPthreadValid
(
pthread_t
thread
)
{
return
thread
!=
0
;
}
bool
taosCheckPthreadValid
(
pthread_t
thread
)
{
return
thread
!=
0
;
}
int64_t
taosGetPthreadId
()
{
return
(
int64_t
)
pthread_self
();
}
int64_t
taosGetPthreadId
()
{
return
(
int64_t
)
pthread_self
();
}
...
...
src/os/src/detail/osString.c
浏览文件 @
8089a23c
...
@@ -19,20 +19,16 @@
...
@@ -19,20 +19,16 @@
#include "taosdef.h"
#include "taosdef.h"
#ifndef TAOS_OS_FUNC_STRING_STR2INT64
#ifndef TAOS_OS_FUNC_STRING_STR2INT64
int64_t
tsosStr2int64
(
char
*
str
)
{
int64_t
tsosStr2int64
(
char
*
str
)
{
char
*
endptr
=
NULL
;
char
*
endptr
=
NULL
;
return
strtoll
(
str
,
&
endptr
,
10
);
return
strtoll
(
str
,
&
endptr
,
10
);
}
}
#endif
#endif
#ifndef TAOS_OS_FUNC_STRING_WCHAR
#ifndef TAOS_OS_FUNC_STRING_WCHAR
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
)
{
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
)
{
return
wcsncmp
((
wchar_t
*
)
f1_ucs4
,
(
wchar_t
*
)
f2_ucs4
,
bytes
/
TSDB_NCHAR_SIZE
);
return
wcsncmp
((
wchar_t
*
)
f1_ucs4
,
(
wchar_t
*
)
f2_ucs4
,
bytes
/
TSDB_NCHAR_SIZE
);
}
}
#endif
#endif
#ifdef USE_LIBICONV
#ifdef USE_LIBICONV
...
...
src/os/src/detail/osTimer.c
浏览文件 @
8089a23c
...
@@ -102,7 +102,7 @@ void taosUninitTimer() {
...
@@ -102,7 +102,7 @@ void taosUninitTimer() {
#endif
#endif
#ifndef TAOS_OS_FUNC_SLEEP
#ifndef TAOS_OS_FUNC_
TIMER_
SLEEP
/*
/*
to make taosMsleep work,
to make taosMsleep work,
signal SIGALRM shall be blocked in the calling thread,
signal SIGALRM shall be blocked in the calling thread,
...
...
src/os/src/windows
64
/CMakeLists.txt
→
src/os/src/windows/CMakeLists.txt
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64
/w64Atomic.c
→
src/os/src/windows/w64Atomic.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64
/w64Env.c
→
src/os/src/windows/w64Env.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64/w64FileOp
.c
→
src/os/src/windows
/w64File
.c
浏览文件 @
8089a23c
...
@@ -15,11 +15,28 @@
...
@@ -15,11 +15,28 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
void
taosGetTmpfilePath
(
const
char
*
fileNamePrefix
,
char
*
dstPath
)
{
#include "ttimer.h"
const
char
*
tdengineTmpFileNamePrefix
=
"tdengine-"
;
#include "tulog.h"
char
tmpPath
[
PATH_MAX
];
#include "tutil.h"
char
*
tmpDir
=
getenv
(
"tmp"
);
if
(
tmpDir
==
NULL
)
{
tmpDir
=
""
;
}
strcpy
(
tmpPath
,
tmpDir
);
strcat
(
tmpPath
,
tdengineTmpFileNamePrefix
);
if
(
strlen
(
tmpPath
)
+
strlen
(
fileNamePrefix
)
+
strlen
(
"-%d-%s"
)
<
PATH_MAX
)
{
strcat
(
tmpPath
,
fileNamePrefix
);
strcat
(
tmpPath
,
"-%d-%s"
);
}
char
rand
[
8
]
=
{
0
};
taosRandStr
(
rand
,
tListLen
(
rand
)
-
1
);
snprintf
(
dstPath
,
PATH_MAX
,
tmpPath
,
getpid
(),
rand
);
}
#define _SEND_FILE_STEP_ 1000
#define _SEND_FILE_STEP_ 1000
...
...
src/os/src/windows
64
/w64Getline.c
→
src/os/src/windows/w64Getline.c
浏览文件 @
8089a23c
...
@@ -40,30 +40,20 @@ null terminator), or -1 on error or EOF. On a -1 return, the caller
...
@@ -40,30 +40,20 @@ null terminator), or -1 on error or EOF. On a -1 return, the caller
should check feof(), if not then errno has been set to indicate
should check feof(), if not then errno has been set to indicate
the error. */
the error. */
int
int
getstr
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
char
terminator
,
int
offset
)
{
getstr
(
lineptr
,
n
,
stream
,
terminator
,
offset
)
char
**
lineptr
;
size_t
*
n
;
FILE
*
stream
;
char
terminator
;
int
offset
;
{
int
nchars_avail
;
/* Allocated but unused chars in *LINEPTR. */
int
nchars_avail
;
/* Allocated but unused chars in *LINEPTR. */
char
*
read_pos
;
/* Where we're reading into *LINEPTR. */
char
*
read_pos
;
/* Where we're reading into *LINEPTR. */
int
ret
;
int
ret
;
if
(
!
lineptr
||
!
n
||
!
stream
)
if
(
!
lineptr
||
!
n
||
!
stream
)
{
{
errno
=
EINVAL
;
errno
=
EINVAL
;
return
-
1
;
return
-
1
;
}
}
if
(
!*
lineptr
)
if
(
!*
lineptr
)
{
{
*
n
=
MIN_CHUNK
;
*
n
=
MIN_CHUNK
;
*
lineptr
=
malloc
(
*
n
);
*
lineptr
=
malloc
(
*
n
);
if
(
!*
lineptr
)
if
(
!*
lineptr
)
{
{
errno
=
ENOMEM
;
errno
=
ENOMEM
;
return
-
1
;
return
-
1
;
}
}
...
@@ -72,8 +62,7 @@ int offset;
...
@@ -72,8 +62,7 @@ int offset;
nchars_avail
=
(
int
)(
*
n
-
offset
);
nchars_avail
=
(
int
)(
*
n
-
offset
);
read_pos
=
*
lineptr
+
offset
;
read_pos
=
*
lineptr
+
offset
;
for
(;;)
for
(;;)
{
{
int
save_errno
;
int
save_errno
;
register
int
c
=
getc
(
stream
);
register
int
c
=
getc
(
stream
);
...
@@ -84,8 +73,7 @@ int offset;
...
@@ -84,8 +73,7 @@ int offset;
NUL-terminate the line buffer. */
NUL-terminate the line buffer. */
assert
((
*
lineptr
+
*
n
)
==
(
read_pos
+
nchars_avail
));
assert
((
*
lineptr
+
*
n
)
==
(
read_pos
+
nchars_avail
));
if
(
nchars_avail
<
2
)
if
(
nchars_avail
<
2
)
{
{
if
(
*
n
>
MIN_CHUNK
)
if
(
*
n
>
MIN_CHUNK
)
*
n
*=
2
;
*
n
*=
2
;
else
else
...
@@ -93,8 +81,7 @@ int offset;
...
@@ -93,8 +81,7 @@ int offset;
nchars_avail
=
(
int
)(
*
n
+
*
lineptr
-
read_pos
);
nchars_avail
=
(
int
)(
*
n
+
*
lineptr
-
read_pos
);
*
lineptr
=
realloc
(
*
lineptr
,
*
n
);
*
lineptr
=
realloc
(
*
lineptr
,
*
n
);
if
(
!*
lineptr
)
if
(
!*
lineptr
)
{
{
errno
=
ENOMEM
;
errno
=
ENOMEM
;
return
-
1
;
return
-
1
;
}
}
...
@@ -102,8 +89,7 @@ int offset;
...
@@ -102,8 +89,7 @@ int offset;
assert
((
*
lineptr
+
*
n
)
==
(
read_pos
+
nchars_avail
));
assert
((
*
lineptr
+
*
n
)
==
(
read_pos
+
nchars_avail
));
}
}
if
(
ferror
(
stream
))
if
(
ferror
(
stream
))
{
{
/* Might like to return partial line, but there is no
/* Might like to return partial line, but there is no
place for us to store errno. And we don't want to just
place for us to store errno. And we don't want to just
lose errno. */
lose errno. */
...
@@ -111,8 +97,7 @@ int offset;
...
@@ -111,8 +97,7 @@ int offset;
return
-
1
;
return
-
1
;
}
}
if
(
c
==
EOF
)
if
(
c
==
EOF
)
{
{
/* Return partial line, if any. */
/* Return partial line, if any. */
if
(
read_pos
==
*
lineptr
)
if
(
read_pos
==
*
lineptr
)
return
-
1
;
return
-
1
;
...
@@ -123,8 +108,7 @@ int offset;
...
@@ -123,8 +108,7 @@ int offset;
*
read_pos
++
=
c
;
*
read_pos
++
=
c
;
nchars_avail
--
;
nchars_avail
--
;
if
(
c
==
terminator
)
if
(
c
==
terminator
)
/* Return the line. */
/* Return the line. */
break
;
break
;
}
}
...
@@ -135,11 +119,6 @@ int offset;
...
@@ -135,11 +119,6 @@ int offset;
return
ret
;
return
ret
;
}
}
int
int
taosGetlineImp
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
)
{
getline
(
lineptr
,
n
,
stream
)
char
**
lineptr
;
size_t
*
n
;
FILE
*
stream
;
{
return
getstr
(
lineptr
,
n
,
stream
,
'\n'
,
0
);
return
getstr
(
lineptr
,
n
,
stream
,
'\n'
,
0
);
}
}
\ No newline at end of file
src/os/src/windows
64
/w64Godll.c
→
src/os/src/windows/w64Godll.c
浏览文件 @
8089a23c
...
@@ -27,8 +27,7 @@ int64_t tsosStr2int64(char *str) {
...
@@ -27,8 +27,7 @@ int64_t tsosStr2int64(char *str) {
return
strtoll
(
str
,
&
endptr
,
10
);
return
strtoll
(
str
,
&
endptr
,
10
);
}
}
uint64_t
htonll
(
uint64_t
val
)
uint64_t
htonll
(
uint64_t
val
)
{
{
return
(((
uint64_t
)
htonl
(
val
))
<<
32
)
+
htonl
(
val
>>
32
);
return
(((
uint64_t
)
htonl
(
val
))
<<
32
)
+
htonl
(
val
>>
32
);
}
}
#endif
#endif
src/os/src/windows
64
/w64Lz4.c
→
src/os/src/windows/w64Lz4.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64/w64PThread
.c
→
src/os/src/windows
/w64Semphone
.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64
/w64Socket.c
→
src/os/src/windows/w64Socket.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64/w64Util
.c
→
src/os/src/windows
/w64String
.c
浏览文件 @
8089a23c
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include "tulog.h"
#include "tulog.h"
#include "tutil.h"
#include "tutil.h"
/*
/*
* Get next token from string *stringp, where tokens are possibly-empty
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
* strings separated by characters from delim.
...
@@ -67,29 +66,6 @@ char *getpass(const char *prefix) {
...
@@ -67,29 +66,6 @@ char *getpass(const char *prefix) {
return
passwd
;
return
passwd
;
}
}
int
flock
(
int
fd
,
int
option
)
{
return
0
;
}
int
fsync
(
int
filedes
)
{
return
0
;
}
int
sigaction
(
int
sig
,
struct
sigaction
*
d
,
void
*
p
)
{
return
0
;
}
int
wordexp
(
const
char
*
words
,
wordexp_t
*
pwordexp
,
int
flags
)
{
pwordexp
->
we_offs
=
0
;
pwordexp
->
we_wordc
=
1
;
pwordexp
->
we_wordv
=
(
char
**
)(
pwordexp
->
wordPos
);
pwordexp
->
we_wordv
[
0
]
=
(
char
*
)
words
;
return
0
;
}
void
wordfree
(
wordexp_t
*
pwordexp
)
{}
char
*
strndup
(
const
char
*
s
,
size_t
n
)
{
char
*
strndup
(
const
char
*
s
,
size_t
n
)
{
int
len
=
strlen
(
s
);
int
len
=
strlen
(
s
);
if
(
len
>=
n
)
{
if
(
len
>=
n
)
{
...
@@ -102,16 +78,54 @@ char *strndup(const char *s, size_t n) {
...
@@ -102,16 +78,54 @@ char *strndup(const char *s, size_t n) {
return
r
;
return
r
;
}
}
void
taosSetCoreDump
()
{}
size_t
twcslen
(
const
wchar_t
*
wcs
)
{
int
*
wstr
=
(
int
*
)
wcs
;
if
(
NULL
==
wstr
)
{
return
0
;
}
#ifdef _TD_GO_DLL_
size_t
n
=
0
;
int64_t
tsosStr2int64
(
char
*
str
)
{
while
(
1
)
{
char
*
endptr
=
NULL
;
if
(
0
==
*
wstr
++
)
{
return
strtoll
(
str
,
&
endptr
,
10
);
break
;
}
}
n
++
;
}
uint64_t
htonll
(
uint64_t
val
)
return
n
;
{
return
(((
uint64_t
)
htonl
(
val
))
<<
32
)
+
htonl
(
val
>>
32
);
}
}
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
)
{
for
(
int
i
=
0
;
i
<
bytes
;
++
i
)
{
int32_t
f1
=
*
(
int32_t
*
)((
char
*
)
f1_ucs4
+
i
*
4
);
int32_t
f2
=
*
(
int32_t
*
)((
char
*
)
f2_ucs4
+
i
*
4
);
if
((
f1
==
0
&&
f2
!=
0
)
||
(
f1
!=
0
&&
f2
==
0
))
{
return
f1
-
f2
;
}
else
if
(
f1
==
0
&&
f2
==
0
)
{
return
0
;
}
if
(
f1
!=
f2
)
{
return
f1
-
f2
;
}
}
return
0
;
#if 0
int32_t ucs4_max_len = bytes + 4;
char *f1_mbs = calloc(bytes, 1);
char *f2_mbs = calloc(bytes, 1);
if (taosUcs4ToMbs(f1_ucs4, ucs4_max_len, f1_mbs) < 0) {
return -1;
}
if (taosUcs4ToMbs(f2_ucs4, ucs4_max_len, f2_mbs) < 0) {
return -1;
}
int32_t ret = strcmp(f1_mbs, f2_mbs);
free(f1_mbs);
free(f2_mbs);
return ret;
#endif
#endif
}
src/os/src/windows
64
/w64Strptime.c
→
src/os/src/windows/w64Strptime.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64
/w64Sysinfo.c
→
src/os/src/windows/w64Sysinfo.c
浏览文件 @
8089a23c
...
@@ -114,3 +114,5 @@ int fsync(int filedes) {
...
@@ -114,3 +114,5 @@ int fsync(int filedes) {
int
sigaction
(
int
sig
,
struct
sigaction
*
d
,
void
*
p
)
{
int
sigaction
(
int
sig
,
struct
sigaction
*
d
,
void
*
p
)
{
return
0
;
return
0
;
}
}
void
taosSetCoreDump
()
{}
\ No newline at end of file
src/os/src/windows
64
/w64Time.c
→
src/os/src/windows/w64Time.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64
/w64Timer.c
→
src/os/src/windows/w64Timer.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows
64
/w64Wordexp.c
→
src/os/src/windows/w64Wordexp.c
浏览文件 @
8089a23c
文件已移动
src/os/src/windows64/w64Coredump.c
已删除
100644 → 0
浏览文件 @
a0c3a007
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsystem.h"
void
taosSetCoreDump
()
{}
\ No newline at end of file
src/os/src/windows64/w64File.c
已删除
100644 → 0
浏览文件 @
a0c3a007
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
void
taosGetTmpfilePath
(
const
char
*
fileNamePrefix
,
char
*
dstPath
)
{
const
char
*
tdengineTmpFileNamePrefix
=
"tdengine-"
;
char
tmpPath
[
PATH_MAX
];
char
*
tmpDir
=
getenv
(
"tmp"
);
if
(
tmpDir
==
NULL
)
{
tmpDir
=
""
;
}
strcpy
(
tmpPath
,
tmpDir
);
strcat
(
tmpPath
,
tdengineTmpFileNamePrefix
);
if
(
strlen
(
tmpPath
)
+
strlen
(
fileNamePrefix
)
+
strlen
(
"-%d-%s"
)
<
PATH_MAX
)
{
strcat
(
tmpPath
,
fileNamePrefix
);
strcat
(
tmpPath
,
"-%d-%s"
);
}
char
rand
[
8
]
=
{
0
};
taosRandStr
(
rand
,
tListLen
(
rand
)
-
1
);
snprintf
(
dstPath
,
PATH_MAX
,
tmpPath
,
getpid
(),
rand
);
}
src/os/src/windows64/w64Msghdr.c
已删除
100644 → 0
浏览文件 @
a0c3a007
/*
* 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/>.
*/
#include <winsock2.h>
void
taosFreeMsgHdr
(
void
*
hdr
)
{
WSAMSG
*
msgHdr
=
(
WSAMSG
*
)
hdr
;
free
(
msgHdr
->
lpBuffers
);
}
int
taosMsgHdrSize
(
void
*
hdr
)
{
WSAMSG
*
msgHdr
=
(
WSAMSG
*
)
hdr
;
return
msgHdr
->
dwBufferCount
;
}
void
taosSendMsgHdr
(
void
*
hdr
,
int
fd
)
{
WSAMSG
*
msgHdr
=
(
WSAMSG
*
)
hdr
;
DWORD
len
;
WSASendMsg
(
fd
,
msgHdr
,
0
,
&
len
,
0
,
0
);
msgHdr
->
dwBufferCount
=
0
;
}
void
taosInitMsgHdr
(
void
**
hdr
,
void
*
dest
,
int
maxPkts
)
{
WSAMSG
*
msgHdr
=
(
WSAMSG
*
)
malloc
(
sizeof
(
WSAMSG
));
memset
(
msgHdr
,
0
,
sizeof
(
WSAMSG
));
*
hdr
=
msgHdr
;
// see ws2def.h
// the size of LPSOCKADDR and sockaddr_in * is same, so it's safe
msgHdr
->
name
=
(
LPSOCKADDR
)
dest
;
msgHdr
->
namelen
=
sizeof
(
struct
sockaddr_in
);
int
size
=
sizeof
(
WSABUF
)
*
maxPkts
;
msgHdr
->
lpBuffers
=
(
LPWSABUF
)
malloc
(
size
);
memset
(
msgHdr
->
lpBuffers
,
0
,
size
);
msgHdr
->
dwBufferCount
=
0
;
}
void
taosSetMsgHdrData
(
void
*
hdr
,
char
*
data
,
int
dataLen
)
{
WSAMSG
*
msgHdr
=
(
WSAMSG
*
)
hdr
;
msgHdr
->
lpBuffers
[
msgHdr
->
dwBufferCount
].
buf
=
data
;
msgHdr
->
lpBuffers
[
msgHdr
->
dwBufferCount
].
len
=
dataLen
;
msgHdr
->
dwBufferCount
++
;
}
src/os/src/windows64/w64String.c
已删除
100644 → 0
浏览文件 @
a0c3a007
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no moretokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
char
*
strsep
(
char
**
stringp
,
const
char
*
delim
)
{
char
*
s
;
const
char
*
spanp
;
int
c
,
sc
;
char
*
tok
;
if
((
s
=
*
stringp
)
==
NULL
)
return
(
NULL
);
for
(
tok
=
s
;;)
{
c
=
*
s
++
;
spanp
=
delim
;
do
{
if
((
sc
=
*
spanp
++
)
==
c
)
{
if
(
c
==
0
)
s
=
NULL
;
else
s
[
-
1
]
=
0
;
*
stringp
=
s
;
return
(
tok
);
}
}
while
(
sc
!=
0
);
}
/* NOTREACHED */
}
char
*
getpass
(
const
char
*
prefix
)
{
static
char
passwd
[
TSDB_KEY_LEN
]
=
{
0
};
printf
(
"%s"
,
prefix
);
scanf
(
"%s"
,
passwd
);
char
n
=
getchar
();
return
passwd
;
}
char
*
strndup
(
const
char
*
s
,
size_t
n
)
{
int
len
=
strlen
(
s
);
if
(
len
>=
n
)
{
len
=
n
;
}
char
*
r
=
calloc
(
len
+
1
,
1
);
memcpy
(
r
,
s
,
len
);
r
[
len
]
=
0
;
return
r
;
}
#ifdef _TD_GO_DLL_
int64_t
tsosStr2int64
(
char
*
str
)
{
char
*
endptr
=
NULL
;
return
strtoll
(
str
,
&
endptr
,
10
);
}
uint64_t
htonll
(
uint64_t
val
)
{
return
(((
uint64_t
)
htonl
(
val
))
<<
32
)
+
htonl
(
val
>>
32
);
}
#endif
\ No newline at end of file
src/os/src/windows64/w64Wchar.c
已删除
100644 → 0
浏览文件 @
a0c3a007
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "tulog.h"
size_t
twcslen
(
const
wchar_t
*
wcs
)
{
int
*
wstr
=
(
int
*
)
wcs
;
if
(
NULL
==
wstr
)
{
return
0
;
}
size_t
n
=
0
;
while
(
1
)
{
if
(
0
==
*
wstr
++
)
{
break
;
}
n
++
;
}
return
n
;
}
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
)
{
for
(
int
i
=
0
;
i
<
bytes
;
++
i
)
{
int32_t
f1
=
*
(
int32_t
*
)((
char
*
)
f1_ucs4
+
i
*
4
);
int32_t
f2
=
*
(
int32_t
*
)((
char
*
)
f2_ucs4
+
i
*
4
);
if
((
f1
==
0
&&
f2
!=
0
)
||
(
f1
!=
0
&&
f2
==
0
))
{
return
f1
-
f2
;
}
else
if
(
f1
==
0
&&
f2
==
0
)
{
return
0
;
}
if
(
f1
!=
f2
)
{
return
f1
-
f2
;
}
}
return
0
;
#if 0
int32_t ucs4_max_len = bytes + 4;
char *f1_mbs = calloc(bytes, 1);
char *f2_mbs = calloc(bytes, 1);
if (taosUcs4ToMbs(f1_ucs4, ucs4_max_len, f1_mbs) < 0) {
return -1;
}
if (taosUcs4ToMbs(f2_ucs4, ucs4_max_len, f2_mbs) < 0) {
return -1;
}
int32_t ret = strcmp(f1_mbs, f2_mbs);
free(f1_mbs);
free(f2_mbs);
return ret;
#endif
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录