Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1e24b995
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1e24b995
编写于
8月 11, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1057 system function in windows
上级
1169eba1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
115 addition
and
6 deletion
+115
-6
src/os/src/windows/w64Atomic.c
src/os/src/windows/w64Atomic.c
+4
-0
src/os/src/windows/w64Lz4.c
src/os/src/windows/w64Lz4.c
+25
-1
src/os/src/windows/w64Sysinfo.c
src/os/src/windows/w64Sysinfo.c
+86
-5
未找到文件。
src/os/src/windows/w64Atomic.c
浏览文件 @
1e24b995
...
...
@@ -43,7 +43,11 @@ long interlocked_add_fetch_32(long volatile* ptr, long val) {
}
__int64
interlocked_add_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
)
{
#ifdef _WIN64
return
_InterlockedExchangeAdd64
(
ptr
,
val
)
+
val
;
#else
return
_InterlockedExchangeAdd
(
ptr
,
val
)
+
val
;
#endif
}
// and
...
...
src/os/src/windows/w64Lz4.c
浏览文件 @
1e24b995
...
...
@@ -21,9 +21,29 @@
#include "tulog.h"
#include "tutil.h"
unsigned
char
_MyBitScanForward64
(
unsigned
long
*
ret
,
uint64_t
x
)
{
unsigned
long
x0
=
(
unsigned
long
)
x
,
top
,
bottom
;
_BitScanForward
(
&
top
,
(
unsigned
long
)(
x
>>
32
));
_BitScanForward
(
&
bottom
,
x0
);
*
ret
=
x0
?
bottom
:
32
+
top
;
return
x
!=
0
;
}
unsigned
char
_MyBitScanReverse64
(
unsigned
long
*
ret
,
uint64_t
x
)
{
unsigned
long
x1
=
(
unsigned
long
)(
x
>>
32
),
top
,
bottom
;
_BitScanReverse
(
&
top
,
x1
);
_BitScanReverse
(
&
bottom
,
(
unsigned
long
)
x
);
*
ret
=
x1
?
top
+
32
:
bottom
;
return
x
!=
0
;
}
int32_t
BUILDIN_CLZL
(
uint64_t
val
)
{
unsigned
long
r
=
0
;
#ifdef _WIN64
_BitScanReverse64
(
&
r
,
val
);
#else
_MyBitScanReverse64
(
&
r
,
val
);
#endif
return
(
int
)(
r
>>
3
);
}
...
...
@@ -35,7 +55,11 @@ int32_t BUILDIN_CLZ(uint32_t val) {
int32_t
BUILDIN_CTZL
(
uint64_t
val
)
{
unsigned
long
r
=
0
;
#ifdef _WIN64
_BitScanForward64
(
&
r
,
val
);
#else
_MyBitScanForward64
(
&
r
,
val
);
#endif
return
(
int
)(
r
>>
3
);
}
...
...
@@ -43,4 +67,4 @@ int32_t BUILDIN_CTZ(uint32_t val) {
unsigned
long
r
=
0
;
_BitScanForward
(
&
r
,
val
);
return
(
int
)(
r
>>
3
);
}
}
\ No newline at end of file
src/os/src/windows/w64Sysinfo.c
浏览文件 @
1e24b995
...
...
@@ -21,6 +21,15 @@
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
#if (_WIN64)
#include <windows.h>
#include <iphlpapi.h>
#include <psapi.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <mswsock.h>
#pragma comment(lib, "Mswsock.lib ")
#endif
static
void
taosGetSystemTimezone
()
{
// get and set default timezone
...
...
@@ -69,11 +78,64 @@ void taosGetSystemInfo() {
taosGetSystemLocale
();
}
bool
taosGetDisk
()
{
return
true
;
}
bool
taosGetDisk
()
{
const
double
unit
=
1024
*
1024
*
1024
;
BOOL
fResult
;
unsigned
_int64
i64FreeBytesToCaller
;
unsigned
_int64
i64TotalBytes
;
unsigned
_int64
i64FreeBytes
;
char
dir
[
4
]
=
{
'C'
,
':'
,
'\\'
,
'\0'
};
int
drive_type
;
if
(
tscEmbedded
)
{
drive_type
=
GetDriveTypeA
(
dir
);
if
(
drive_type
==
DRIVE_FIXED
)
{
fResult
=
GetDiskFreeSpaceExA
(
dir
,
(
PULARGE_INTEGER
)
&
i64FreeBytesToCaller
,
(
PULARGE_INTEGER
)
&
i64TotalBytes
,
(
PULARGE_INTEGER
)
&
i64FreeBytes
);
if
(
fResult
)
{
tsTotalDataDirGB
=
tsTotalLogDirGB
=
tsTotalTmpDirGB
=
(
float
)(
i64TotalBytes
/
unit
);
tsAvailDataDirGB
=
tsAvailLogDirGB
=
tsAvailTmpDirectorySpace
=
(
float
)(
i64FreeBytes
/
unit
);
}
}
}
return
true
;
}
bool
taosReadProcIO
(
int64_t
*
readbyte
,
int64_t
*
writebyte
)
{
IO_COUNTERS
io_counter
;
if
(
GetProcessIoCounters
(
GetCurrentProcess
(),
&
io_counter
))
{
if
(
readbyte
)
*
readbyte
=
io_counter
.
ReadTransferCount
;
if
(
writebyte
)
*
writebyte
=
io_counter
.
WriteTransferCount
;
return
true
;
}
return
false
;
}
bool
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
*
readKB
=
0
;
*
writeKB
=
0
;
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
int64_t
curReadbyte
=
0
;
int64_t
curWritebyte
=
0
;
if
(
!
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
))
{
return
false
;
}
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
return
false
;
}
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
*
writeKB
=
(
float
)((
double
)(
curWritebyte
-
lastWritebyte
)
/
1024
);
if
(
*
readKB
<
0
)
*
readKB
=
0
;
if
(
*
writeKB
<
0
)
*
writeKB
=
0
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
return
true
;
}
...
...
@@ -89,12 +151,31 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
}
bool
taosGetProcMemory
(
float
*
memoryUsedMB
)
{
*
memoryUsedMB
=
0
;
unsigned
bytes_used
=
0
;
#if defined(_WIN32) && defined(_MSC_VER)
PROCESS_MEMORY_COUNTERS
pmc
;
HANDLE
cur_proc
=
GetCurrentProcess
();
if
(
GetProcessMemoryInfo
(
cur_proc
,
&
pmc
,
sizeof
(
pmc
)))
{
bytes_used
=
(
unsigned
)(
pmc
.
WorkingSetSize
+
pmc
.
PagefileUsage
);
}
#endif
*
memoryUsedMB
=
(
float
)
bytes_used
/
1024
/
1024
;
return
true
;
}
bool
taosGetSysMemory
(
float
*
memoryUsedMB
)
{
*
memoryUsedMB
=
0
;
MEMORYSTATUSEX
memsStat
;
float
nMemFree
;
float
nMemTotal
;
memsStat
.
dwLength
=
sizeof
(
memsStat
);
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
return
false
;
}
nMemFree
=
memsStat
.
ullAvailPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
nMemTotal
=
memsStat
.
ullTotalPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
*
memoryUsedMB
=
nMemTotal
-
nMemFree
;
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录