Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
0fb150b1
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0fb150b1
编写于
5月 08, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-4088
上级
eda9995a
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
280 addition
and
352 deletion
+280
-352
src/os/inc/osAtomic.h
src/os/inc/osAtomic.h
+246
-1
src/os/inc/osDarwin.h
src/os/inc/osDarwin.h
+1
-15
src/os/inc/osDef.h
src/os/inc/osDef.h
+0
-3
src/os/inc/osEok.h
src/os/inc/osEok.h
+0
-0
src/os/inc/osNingsi.h
src/os/inc/osNingsi.h
+0
-136
src/os/inc/osSocket.h
src/os/inc/osSocket.h
+23
-8
src/os/inc/osWindows.h
src/os/inc/osWindows.h
+0
-175
src/os/src/darwin/dwEok.c
src/os/src/darwin/dwEok.c
+1
-3
src/os/src/darwin/dwSemphone.c
src/os/src/darwin/dwSemphone.c
+1
-0
src/os/src/detail/osSleep.c
src/os/src/detail/osSleep.c
+0
-3
src/os/src/detail/osSocket.c
src/os/src/detail/osSocket.c
+4
-3
src/os/src/windows/wSocket.c
src/os/src/windows/wSocket.c
+3
-1
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+0
-3
tests/examples/c/epoll.c
tests/examples/c/epoll.c
+1
-1
未找到文件。
src/os/inc/osAtomic.h
浏览文件 @
0fb150b1
...
...
@@ -20,7 +20,252 @@
extern
"C"
{
#endif
#ifndef TAOS_OS_FUNC_ATOMIC
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#define atomic_load_8(ptr) (*(char volatile*)(ptr))
#define atomic_load_16(ptr) (*(short volatile*)(ptr))
#define atomic_load_32(ptr) (*(long volatile*)(ptr))
#define atomic_load_64(ptr) (*(__int64 volatile*)(ptr))
#define atomic_load_ptr(ptr) (*(void* volatile*)(ptr))
#define atomic_store_8(ptr, val) ((*(char volatile*)(ptr)) = (char)(val))
#define atomic_store_16(ptr, val) ((*(short volatile*)(ptr)) = (short)(val))
#define atomic_store_32(ptr, val) ((*(long volatile*)(ptr)) = (long)(val))
#define atomic_store_64(ptr, val) ((*(__int64 volatile*)(ptr)) = (__int64)(val))
#define atomic_store_ptr(ptr, val) ((*(void* volatile*)(ptr)) = (void*)(val))
#define atomic_exchange_8(ptr, val) _InterlockedExchange8((char volatile*)(ptr), (char)(val))
#define atomic_exchange_16(ptr, val) _InterlockedExchange16((short volatile*)(ptr), (short)(val))
#define atomic_exchange_32(ptr, val) _InterlockedExchange((long volatile*)(ptr), (long)(val))
#define atomic_exchange_64(ptr, val) _InterlockedExchange64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _WIN64
#define atomic_exchange_ptr(ptr, val) _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val))
#else
#define atomic_exchange_ptr(ptr, val) _InlineInterlockedExchangePointer((void* volatile*)(ptr), (void*)(val))
#endif
#ifdef _TD_GO_DLL_
#define atomic_val_compare_exchange_8 __sync_val_compare_and_swap
#else
#define atomic_val_compare_exchange_8(ptr, oldval, newval) _InterlockedCompareExchange8((char volatile*)(ptr), (char)(newval), (char)(oldval))
#endif
#define atomic_val_compare_exchange_16(ptr, oldval, newval) _InterlockedCompareExchange16((short volatile*)(ptr), (short)(newval), (short)(oldval))
#define atomic_val_compare_exchange_32(ptr, oldval, newval) _InterlockedCompareExchange((long volatile*)(ptr), (long)(newval), (long)(oldval))
#define atomic_val_compare_exchange_64(ptr, oldval, newval) _InterlockedCompareExchange64((__int64 volatile*)(ptr), (__int64)(newval), (__int64)(oldval))
#define atomic_val_compare_exchange_ptr(ptr, oldval, newval) _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval))
char
interlocked_add_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_add_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_add_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_add_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
char
interlocked_and_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_and_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_and_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_and_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
__int64
interlocked_fetch_and_64
(
__int64
volatile
*
ptr
,
__int64
val
);
char
interlocked_or_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_or_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_or_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_or_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
char
interlocked_xor_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_xor_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_xor_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_xor_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
__int64
interlocked_fetch_xor_64
(
__int64
volatile
*
ptr
,
__int64
val
);
#define atomic_add_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_add_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_add_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_add_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _TD_GO_DLL_
#define atomic_fetch_add_8 __sync_fetch_and_ad
#define atomic_fetch_add_16 __sync_fetch_and_add
#else
#define atomic_fetch_add_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_add_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), (short)(val))
#endif
#define atomic_fetch_add_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_add_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_add_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), (long)(val))
#define atomic_fetch_add_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_sub_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), -(char)(val))
#define atomic_sub_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), -(short)(val))
#define atomic_sub_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), -(long)(val))
#define atomic_sub_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), -(__int64)(val))
#define atomic_fetch_sub_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), -(char)(val))
#define atomic_fetch_sub_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), -(short)(val))
#define atomic_fetch_sub_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), -(long)(val))
#define atomic_fetch_sub_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), -(__int64)(val))
#define atomic_and_fetch_8(ptr, val) interlocked_and_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_and_fetch_16(ptr, val) interlocked_and_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_and_fetch_32(ptr, val) interlocked_and_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_and_fetch_64(ptr, val) interlocked_and_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_fetch_and_8(ptr, val) _InterlockedAnd8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_and_16(ptr, val) _InterlockedAnd16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_and_32(ptr, val) _InterlockedAnd((long volatile*)(ptr), (long)(val))
#define atomic_fetch_and_64(ptr, val) interlocked_fetch_and_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_or_fetch_8(ptr, val) interlocked_or_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_or_fetch_16(ptr, val) interlocked_or_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_or_fetch_32(ptr, val) interlocked_or_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_or_fetch_64(ptr, val) interlocked_or_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_fetch_or_8(ptr, val) _InterlockedOr8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_or_16(ptr, val) _InterlockedOr16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_or_32(ptr, val) _InterlockedOr((long volatile*)(ptr), (long)(val))
#define atomic_fetch_or_64(ptr, val) interlocked_fetch_or_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_xor_fetch_8(ptr, val) interlocked_xor_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_xor_fetch_16(ptr, val) interlocked_xor_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_xor_fetch_32(ptr, val) interlocked_xor_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_xor_fetch_64(ptr, val) interlocked_xor_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_fetch_xor_8(ptr, val) _InterlockedXor8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_xor_16(ptr, val) _InterlockedXor16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_xor_32(ptr, val) _InterlockedXor((long volatile*)(ptr), (long)(val))
#define atomic_fetch_xor_64(ptr, val) interlocked_fetch_xor_64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _WIN64
#define atomic_add_fetch_ptr atomic_add_fetch_64
#define atomic_fetch_add_ptr atomic_fetch_add_64
#define atomic_sub_fetch_ptr atomic_sub_fetch_64
#define atomic_fetch_sub_ptr atomic_fetch_sub_64
#define atomic_and_fetch_ptr atomic_and_fetch_64
#define atomic_fetch_and_ptr atomic_fetch_and_64
#define atomic_or_fetch_ptr atomic_or_fetch_64
#define atomic_fetch_or_ptr atomic_fetch_or_64
#define atomic_xor_fetch_ptr atomic_xor_fetch_64
#define atomic_fetch_xor_ptr atomic_fetch_xor_64
#else
#define atomic_add_fetch_ptr atomic_add_fetch_32
#define atomic_fetch_add_ptr atomic_fetch_add_32
#define atomic_sub_fetch_ptr atomic_sub_fetch_32
#define atomic_fetch_sub_ptr atomic_fetch_sub_32
#define atomic_and_fetch_ptr atomic_and_fetch_32
#define atomic_fetch_and_ptr atomic_fetch_and_32
#define atomic_or_fetch_ptr atomic_or_fetch_32
#define atomic_fetch_or_ptr atomic_fetch_or_32
#define atomic_xor_fetch_ptr atomic_xor_fetch_32
#define atomic_fetch_xor_ptr atomic_fetch_xor_32
#endif
#elif defined(_TD_NINGSI_60)
/*
* type __sync_fetch_and_add (type *ptr, type value);
* type __sync_fetch_and_sub (type *ptr, type value);
* type __sync_fetch_and_or (type *ptr, type value);
* type __sync_fetch_and_and (type *ptr, type value);
* type __sync_fetch_and_xor (type *ptr, type value);
* type __sync_fetch_and_nand (type *ptr, type value);
* type __sync_add_and_fetch (type *ptr, type value);
* type __sync_sub_and_fetch (type *ptr, type value);
* type __sync_or_and_fetch (type *ptr, type value);
* type __sync_and_and_fetch (type *ptr, type value);
* type __sync_xor_and_fetch (type *ptr, type value);
* type __sync_nand_and_fetch (type *ptr, type value);
*
* bool __sync_bool_compare_and_swap (type*ptr, type oldval, type newval, ...)
* type __sync_val_compare_and_swap (type *ptr, type oldval, ?type newval, ...)
* */
#define atomic_load_8(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_16(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_32(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_64(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_ptr(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_store_8(ptr, val) (*(ptr)=(val))
#define atomic_store_16(ptr, val) (*(ptr)=(val))
#define atomic_store_32(ptr, val) (*(ptr)=(val))
#define atomic_store_64(ptr, val) (*(ptr)=(val))
#define atomic_store_ptr(ptr, val) (*(ptr)=(val))
int8_t
atomic_exchange_8_impl
(
int8_t
*
ptr
,
int8_t
val
);
int16_t
atomic_exchange_16_impl
(
int16_t
*
ptr
,
int16_t
val
);
int32_t
atomic_exchange_32_impl
(
int32_t
*
ptr
,
int32_t
val
);
int64_t
atomic_exchange_64_impl
(
int64_t
*
ptr
,
int64_t
val
);
void
*
atomic_exchange_ptr_impl
(
void
**
ptr
,
void
*
val
);
#define atomic_exchange_8(ptr, val) atomic_exchange_8_impl((int8_t*)ptr, (int8_t)val)
#define atomic_exchange_16(ptr, val) atomic_exchange_16_impl((int16_t*)ptr, (int16_t)val)
#define atomic_exchange_32(ptr, val) atomic_exchange_32_impl((int32_t*)ptr, (int32_t)val)
#define atomic_exchange_64(ptr, val) atomic_exchange_64_impl((int64_t*)ptr, (int64_t)val)
#define atomic_exchange_ptr(ptr, val) atomic_exchange_ptr_impl((void **)ptr, (void*)val)
#define atomic_val_compare_exchange_8 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_16 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_32 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_64 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_ptr __sync_val_compare_and_swap
#define atomic_add_fetch_8(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_16(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_32(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_64(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_ptr(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_fetch_add_8(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_16(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_32(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_64(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_ptr(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_sub_fetch_8(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_16(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_32(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_64(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_ptr(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_fetch_sub_8(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_16(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_32(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_64(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_ptr(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_and_fetch_8(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_16(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_32(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_64(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_ptr(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_fetch_and_8(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_16(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_32(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_64(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_ptr(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_or_fetch_8(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_16(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_32(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_64(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_ptr(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_fetch_or_8(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_16(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_32(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_64(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_ptr(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_xor_fetch_8(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_16(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_32(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_64(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_ptr(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_fetch_xor_8(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_16(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_32(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_64(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_ptr(ptr, val) __sync_fetch_and_xor((ptr), (val))
#else
#define atomic_load_8(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_16(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_32(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
...
...
src/os/inc/osDarwin.h
浏览文件 @
0fb150b1
...
...
@@ -71,12 +71,7 @@ extern "C" {
#include <fcntl.h>
#include <sys/utsname.h>
#include <math.h>
#define TAOS_OS_FUNC_FILE_SENDIFLE
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#define TAOS_OS_FUNC_TIMERD
#include "osEok.h"
// specific
typedef
int
(
*
__compar_fn_t
)(
const
void
*
,
const
void
*
);
...
...
@@ -96,15 +91,6 @@ typedef int(*__compar_fn_t)(const void *, const void *);
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
#endif
#include "eok.h"
void
taos_block_sigalrm
(
void
);
#define TAOS_OS_DEF_EPOLL
#define TAOS_EPOLL_WAIT_TIME 500
typedef
int32_t
SOCKET
;
typedef
SOCKET
EpollFd
;
#define EpollClose(pollFd) epoll_close(pollFd)
#ifdef __cplusplus
}
...
...
src/os/inc/osDef.h
浏览文件 @
0fb150b1
...
...
@@ -26,9 +26,6 @@ extern "C" {
#endif
#endif
// #define WCHAR wchar_t
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
...
...
src/os/inc/
e
ok.h
→
src/os/inc/
osE
ok.h
浏览文件 @
0fb150b1
文件已移动
src/os/inc/osNingsi.h
已删除
100644 → 0
浏览文件 @
eda9995a
/*
* 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_OS_NINGSI_H
#define TDENGINE_OS_NINGSI_H
#ifdef __cplusplus
extern
"C"
{
#endif
#define TAOS_OS_FUNC_ATOMIC
/*
* type __sync_fetch_and_add (type *ptr, type value);
* type __sync_fetch_and_sub (type *ptr, type value);
* type __sync_fetch_and_or (type *ptr, type value);
* type __sync_fetch_and_and (type *ptr, type value);
* type __sync_fetch_and_xor (type *ptr, type value);
* type __sync_fetch_and_nand (type *ptr, type value);
* type __sync_add_and_fetch (type *ptr, type value);
* type __sync_sub_and_fetch (type *ptr, type value);
* type __sync_or_and_fetch (type *ptr, type value);
* type __sync_and_and_fetch (type *ptr, type value);
* type __sync_xor_and_fetch (type *ptr, type value);
* type __sync_nand_and_fetch (type *ptr, type value);
*
* bool __sync_bool_compare_and_swap (type*ptr, type oldval, type newval, ...)
* type __sync_val_compare_and_swap (type *ptr, type oldval, ?type newval, ...)
* */
#define atomic_load_8(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_16(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_32(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_64(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_load_ptr(ptr) __sync_fetch_and_add((ptr), 0)
#define atomic_store_8(ptr, val) (*(ptr)=(val))
#define atomic_store_16(ptr, val) (*(ptr)=(val))
#define atomic_store_32(ptr, val) (*(ptr)=(val))
#define atomic_store_64(ptr, val) (*(ptr)=(val))
#define atomic_store_ptr(ptr, val) (*(ptr)=(val))
int8_t
atomic_exchange_8_impl
(
int8_t
*
ptr
,
int8_t
val
);
int16_t
atomic_exchange_16_impl
(
int16_t
*
ptr
,
int16_t
val
);
int32_t
atomic_exchange_32_impl
(
int32_t
*
ptr
,
int32_t
val
);
int64_t
atomic_exchange_64_impl
(
int64_t
*
ptr
,
int64_t
val
);
void
*
atomic_exchange_ptr_impl
(
void
**
ptr
,
void
*
val
);
#define atomic_exchange_8(ptr, val) atomic_exchange_8_impl((int8_t*)ptr, (int8_t)val)
#define atomic_exchange_16(ptr, val) atomic_exchange_16_impl((int16_t*)ptr, (int16_t)val)
#define atomic_exchange_32(ptr, val) atomic_exchange_32_impl((int32_t*)ptr, (int32_t)val)
#define atomic_exchange_64(ptr, val) atomic_exchange_64_impl((int64_t*)ptr, (int64_t)val)
#define atomic_exchange_ptr(ptr, val) atomic_exchange_ptr_impl((void **)ptr, (void*)val)
#define atomic_val_compare_exchange_8 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_16 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_32 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_64 __sync_val_compare_and_swap
#define atomic_val_compare_exchange_ptr __sync_val_compare_and_swap
#define atomic_add_fetch_8(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_16(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_32(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_64(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_add_fetch_ptr(ptr, val) __sync_add_and_fetch((ptr), (val))
#define atomic_fetch_add_8(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_16(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_32(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_64(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_fetch_add_ptr(ptr, val) __sync_fetch_and_add((ptr), (val))
#define atomic_sub_fetch_8(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_16(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_32(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_64(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_sub_fetch_ptr(ptr, val) __sync_sub_and_fetch((ptr), (val))
#define atomic_fetch_sub_8(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_16(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_32(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_64(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_fetch_sub_ptr(ptr, val) __sync_fetch_and_sub((ptr), (val))
#define atomic_and_fetch_8(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_16(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_32(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_64(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_and_fetch_ptr(ptr, val) __sync_and_and_fetch((ptr), (val))
#define atomic_fetch_and_8(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_16(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_32(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_64(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_fetch_and_ptr(ptr, val) __sync_fetch_and_and((ptr), (val))
#define atomic_or_fetch_8(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_16(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_32(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_64(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_or_fetch_ptr(ptr, val) __sync_or_and_fetch((ptr), (val))
#define atomic_fetch_or_8(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_16(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_32(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_64(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_fetch_or_ptr(ptr, val) __sync_fetch_and_or((ptr), (val))
#define atomic_xor_fetch_8(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_16(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_32(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_64(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_xor_fetch_ptr(ptr, val) __sync_xor_and_fetch((ptr), (val))
#define atomic_fetch_xor_8(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_16(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_32(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_64(ptr, val) __sync_fetch_and_xor((ptr), (val))
#define atomic_fetch_xor_ptr(ptr, val) __sync_fetch_and_xor((ptr), (val))
#ifdef __cplusplus
}
#endif
#endif
src/os/inc/osSocket.h
浏览文件 @
0fb150b1
...
...
@@ -20,7 +20,14 @@
extern
"C"
{
#endif
#ifndef TAOS_OS_FUNC_SOCKET_OP
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#define taosSend(sockfd, buf, len, flags) send((SOCKET)sockfd, buf, len, flags)
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto((SOCKET)sockfd, buf, len, flags, dest_addr, addrlen)
#define taosWriteSocket(fd, buf, len) send((SOCKET)fd, buf, len, 0)
#define taosReadSocket(fd, buf, len) recv((SOCKET)fd, buf, len, 0)
#define taosCloseSocketNoCheck(fd) closesocket((SOCKET)fd)
#define taosCloseSocket(fd) closesocket((SOCKET)fd)
#else
#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 taosReadSocket(fd, buf, len) read(fd, buf, len)
...
...
@@ -35,7 +42,21 @@ extern "C" {
}
#endif
#ifndef TAOS_OS_DEF_EPOLL
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#define TAOS_EPOLL_WAIT_TIME 100
typedef
SOCKET
eventfd_t
;
#define eventfd(a, b) -1
typedef
SOCKET
EpollFd
;
#define EpollClose(pollFd) epoll_close(pollFd)
#ifndef EPOLLWAKEUP
#define EPOLLWAKEUP (1u << 29)
#endif
#elif defined(_TD_DARWIN_64)
#define TAOS_EPOLL_WAIT_TIME 500
typedef
int32_t
SOCKET
;
typedef
SOCKET
EpollFd
;
#define EpollClose(pollFd) epoll_close(pollFd)
#else
#define TAOS_EPOLL_WAIT_TIME 500
typedef
int32_t
SOCKET
;
typedef
SOCKET
EpollFd
;
...
...
@@ -59,22 +80,16 @@ extern "C" {
#endif
#endif
// TAOS_OS_FUNC_SOCKET
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
);
void
taosIgnSIGPIPE
();
void
taosBlockSIGPIPE
();
void
taosSetMaskSIGPIPE
();
// TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
);
int32_t
taosGetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
*
optlen
);
// TAOS_OS_FUNC_SOCKET_INET
uint32_t
taosInetAddr
(
char
*
ipAddr
);
const
char
*
taosInetNtoa
(
struct
in_addr
ipInt
);
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
#define htobe64 htonll
#if defined(_TD_GO_DLL_)
...
...
src/os/inc/osWindows.h
浏览文件 @
0fb150b1
...
...
@@ -55,39 +55,6 @@
extern
"C"
{
#endif
#define TAOS_OS_FUNC_FILE
#define TAOS_OS_FUNC_FILE_ISREG
#define TAOS_OS_FUNC_FILE_ISDIR
#define TAOS_OS_FUNC_FILE_ISLNK
#define TAOS_OS_FUNC_FILE_SENDIFLE
#define TAOS_OS_FUNC_FILE_GETTMPFILEPATH
#define TAOS_OS_FUNC_FILE_FTRUNCATE
#define TAOS_OS_FUNC_SOCKET
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#define TAOS_OS_FUNC_SOCKET_OP
#define taosSend(sockfd, buf, len, flags) send((SOCKET)sockfd, buf, len, flags)
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto((SOCKET)sockfd, buf, len, flags, dest_addr, addrlen)
#define taosWriteSocket(fd, buf, len) send((SOCKET)fd, buf, len, 0)
#define taosReadSocket(fd, buf, len) recv((SOCKET)fd, buf, len, 0)
#define taosCloseSocketNoCheck(fd) closesocket((SOCKET)fd)
#define taosCloseSocket(fd) closesocket((SOCKET)fd)
typedef
SOCKET
eventfd_t
;
#define eventfd(a, b) -1
#define TAOS_OS_DEF_EPOLL
#define TAOS_EPOLL_WAIT_TIME 100
typedef
SOCKET
EpollFd
;
#define EpollClose(pollFd) epoll_close(pollFd)
#ifndef EPOLLWAKEUP
#define EPOLLWAKEUP (1u << 29)
#endif
char
*
stpcpy
(
char
*
dest
,
const
char
*
src
);
char
*
stpncpy
(
char
*
dest
,
const
char
*
src
,
size_t
n
);
...
...
@@ -128,12 +95,6 @@ int gettimeofday(struct timeval *ptv, void *pTimeZone);
#define TCP_KEEPINTVL 0x1234
#endif
#ifdef _MSC_VER
//#if _MSC_VER >= 1900
#define TAOS_OS_FUNC_SOCKET_INET
//#endif
#endif
#define SHUT_RDWR SD_BOTH
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
...
...
@@ -161,142 +122,6 @@ void wordfree(wordexp_t *pwordexp);
#define LOG_INFO 1
void
syslog
(
int
unused
,
const
char
*
format
,
...);
#define TAOS_OS_FUNC_ATOMIC
#define atomic_load_8(ptr) (*(char volatile*)(ptr))
#define atomic_load_16(ptr) (*(short volatile*)(ptr))
#define atomic_load_32(ptr) (*(long volatile*)(ptr))
#define atomic_load_64(ptr) (*(__int64 volatile*)(ptr))
#define atomic_load_ptr(ptr) (*(void* volatile*)(ptr))
#define atomic_store_8(ptr, val) ((*(char volatile*)(ptr)) = (char)(val))
#define atomic_store_16(ptr, val) ((*(short volatile*)(ptr)) = (short)(val))
#define atomic_store_32(ptr, val) ((*(long volatile*)(ptr)) = (long)(val))
#define atomic_store_64(ptr, val) ((*(__int64 volatile*)(ptr)) = (__int64)(val))
#define atomic_store_ptr(ptr, val) ((*(void* volatile*)(ptr)) = (void*)(val))
#define atomic_exchange_8(ptr, val) _InterlockedExchange8((char volatile*)(ptr), (char)(val))
#define atomic_exchange_16(ptr, val) _InterlockedExchange16((short volatile*)(ptr), (short)(val))
#define atomic_exchange_32(ptr, val) _InterlockedExchange((long volatile*)(ptr), (long)(val))
#define atomic_exchange_64(ptr, val) _InterlockedExchange64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _WIN64
#define atomic_exchange_ptr(ptr, val) _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val))
#else
#define atomic_exchange_ptr(ptr, val) _InlineInterlockedExchangePointer((void* volatile*)(ptr), (void*)(val))
#endif
#ifdef _TD_GO_DLL_
#define atomic_val_compare_exchange_8 __sync_val_compare_and_swap
#else
#define atomic_val_compare_exchange_8(ptr, oldval, newval) _InterlockedCompareExchange8((char volatile*)(ptr), (char)(newval), (char)(oldval))
#endif
#define atomic_val_compare_exchange_16(ptr, oldval, newval) _InterlockedCompareExchange16((short volatile*)(ptr), (short)(newval), (short)(oldval))
#define atomic_val_compare_exchange_32(ptr, oldval, newval) _InterlockedCompareExchange((long volatile*)(ptr), (long)(newval), (long)(oldval))
#define atomic_val_compare_exchange_64(ptr, oldval, newval) _InterlockedCompareExchange64((__int64 volatile*)(ptr), (__int64)(newval), (__int64)(oldval))
#define atomic_val_compare_exchange_ptr(ptr, oldval, newval) _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval))
char
interlocked_add_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_add_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_add_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_add_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
char
interlocked_and_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_and_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_and_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_and_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
__int64
interlocked_fetch_and_64
(
__int64
volatile
*
ptr
,
__int64
val
);
char
interlocked_or_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_or_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_or_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_or_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
char
interlocked_xor_fetch_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_xor_fetch_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_xor_fetch_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_xor_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
);
__int64
interlocked_fetch_xor_64
(
__int64
volatile
*
ptr
,
__int64
val
);
#define atomic_add_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_add_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_add_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_add_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _TD_GO_DLL_
#define atomic_fetch_add_8 __sync_fetch_and_ad
#define atomic_fetch_add_16 __sync_fetch_and_add
#else
#define atomic_fetch_add_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_add_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), (short)(val))
#endif
#define atomic_fetch_add_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_add_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_add_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), (long)(val))
#define atomic_fetch_add_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_sub_fetch_8(ptr, val) interlocked_add_fetch_8((char volatile*)(ptr), -(char)(val))
#define atomic_sub_fetch_16(ptr, val) interlocked_add_fetch_16((short volatile*)(ptr), -(short)(val))
#define atomic_sub_fetch_32(ptr, val) interlocked_add_fetch_32((long volatile*)(ptr), -(long)(val))
#define atomic_sub_fetch_64(ptr, val) interlocked_add_fetch_64((__int64 volatile*)(ptr), -(__int64)(val))
#define atomic_fetch_sub_8(ptr, val) _InterlockedExchangeAdd8((char volatile*)(ptr), -(char)(val))
#define atomic_fetch_sub_16(ptr, val) _InterlockedExchangeAdd16((short volatile*)(ptr), -(short)(val))
#define atomic_fetch_sub_32(ptr, val) _InterlockedExchangeAdd((long volatile*)(ptr), -(long)(val))
#define atomic_fetch_sub_64(ptr, val) _InterlockedExchangeAdd64((__int64 volatile*)(ptr), -(__int64)(val))
#define atomic_and_fetch_8(ptr, val) interlocked_and_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_and_fetch_16(ptr, val) interlocked_and_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_and_fetch_32(ptr, val) interlocked_and_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_and_fetch_64(ptr, val) interlocked_and_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_fetch_and_8(ptr, val) _InterlockedAnd8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_and_16(ptr, val) _InterlockedAnd16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_and_32(ptr, val) _InterlockedAnd((long volatile*)(ptr), (long)(val))
#define atomic_fetch_and_64(ptr, val) interlocked_fetch_and_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_or_fetch_8(ptr, val) interlocked_or_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_or_fetch_16(ptr, val) interlocked_or_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_or_fetch_32(ptr, val) interlocked_or_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_or_fetch_64(ptr, val) interlocked_or_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_fetch_or_8(ptr, val) _InterlockedOr8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_or_16(ptr, val) _InterlockedOr16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_or_32(ptr, val) _InterlockedOr((long volatile*)(ptr), (long)(val))
#define atomic_fetch_or_64(ptr, val) interlocked_fetch_or_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_xor_fetch_8(ptr, val) interlocked_xor_fetch_8((char volatile*)(ptr), (char)(val))
#define atomic_xor_fetch_16(ptr, val) interlocked_xor_fetch_16((short volatile*)(ptr), (short)(val))
#define atomic_xor_fetch_32(ptr, val) interlocked_xor_fetch_32((long volatile*)(ptr), (long)(val))
#define atomic_xor_fetch_64(ptr, val) interlocked_xor_fetch_64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_fetch_xor_8(ptr, val) _InterlockedXor8((char volatile*)(ptr), (char)(val))
#define atomic_fetch_xor_16(ptr, val) _InterlockedXor16((short volatile*)(ptr), (short)(val))
#define atomic_fetch_xor_32(ptr, val) _InterlockedXor((long volatile*)(ptr), (long)(val))
#define atomic_fetch_xor_64(ptr, val) interlocked_fetch_xor_64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _WIN64
#define atomic_add_fetch_ptr atomic_add_fetch_64
#define atomic_fetch_add_ptr atomic_fetch_add_64
#define atomic_sub_fetch_ptr atomic_sub_fetch_64
#define atomic_fetch_sub_ptr atomic_fetch_sub_64
#define atomic_and_fetch_ptr atomic_and_fetch_64
#define atomic_fetch_and_ptr atomic_fetch_and_64
#define atomic_or_fetch_ptr atomic_or_fetch_64
#define atomic_fetch_or_ptr atomic_fetch_or_64
#define atomic_xor_fetch_ptr atomic_xor_fetch_64
#define atomic_fetch_xor_ptr atomic_fetch_xor_64
#else
#define atomic_add_fetch_ptr atomic_add_fetch_32
#define atomic_fetch_add_ptr atomic_fetch_add_32
#define atomic_sub_fetch_ptr atomic_sub_fetch_32
#define atomic_fetch_sub_ptr atomic_fetch_sub_32
#define atomic_and_fetch_ptr atomic_and_fetch_32
#define atomic_fetch_and_ptr atomic_fetch_and_32
#define atomic_or_fetch_ptr atomic_or_fetch_32
#define atomic_fetch_or_ptr atomic_fetch_or_32
#define atomic_xor_fetch_ptr atomic_xor_fetch_32
#define atomic_fetch_xor_ptr atomic_fetch_xor_32
#endif
#ifdef __cplusplus
}
#endif
...
...
src/os/src/darwin/
e
ok.c
→
src/os/src/darwin/
dwE
ok.c
浏览文件 @
0fb150b1
...
...
@@ -18,7 +18,7 @@
// https://stackoverflow.com/questions/4393197/erlangs-let-it-crash-philosophy-applicable-elsewhere
// experimentally, we follow log-and-crash here
#include "
e
ok.h"
#include "
osE
ok.h"
#include "os.h"
...
...
@@ -415,8 +415,6 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) {
static
struct
timespec
do_timespec_diff
(
struct
timespec
*
from
,
struct
timespec
*
to
);
int
epoll_wait
(
int
epfd
,
struct
epoll_event
*
events
,
int
maxevents
,
int
timeout
)
{
taos_block_sigalrm
();
int
e
=
0
;
if
(
!
events
)
{
errno
=
EINVAL
;
...
...
src/os/src/darwin/dwSemphone.c
浏览文件 @
0fb150b1
...
...
@@ -20,6 +20,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include <stdint.h>>
#include <libproc.h>
...
...
src/os/src/detail/osSleep.c
浏览文件 @
0fb150b1
...
...
@@ -32,9 +32,6 @@ void taosMsleep(int32_t ms) { Sleep(ms); }
pthread_sigmask(SIG_BLOCK, &set, NULL);
*/
void
taosMsleep
(
int32_t
mseconds
)
{
#ifdef _TD_DARWIN_64
taos_block_sigalrm
();
#endif
#if 1
usleep
(
mseconds
*
1000
);
#else
...
...
src/os/src/detail/osSocket.c
浏览文件 @
0fb150b1
...
...
@@ -17,7 +17,7 @@
#include "os.h"
#include "tulog.h"
#if
ndef TAOS_OS_FUNC_SOCKET
#if
!(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
)
{
int32_t
flags
=
0
;
...
...
@@ -65,7 +65,7 @@ void taosSetMaskSIGPIPE() {
#endif
#if
ndef TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#if
!(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) || defined(_TD_DARWIN_32))
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
)
{
return
setsockopt
(
socketfd
,
level
,
optname
,
optval
,
(
socklen_t
)
optlen
);
...
...
@@ -74,9 +74,10 @@ int32_t taosSetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *op
int32_t
taosGetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
*
optlen
)
{
return
getsockopt
(
socketfd
,
level
,
optname
,
optval
,
(
socklen_t
*
)
optlen
);
}
#endif
#if
ndef TAOS_OS_FUNC_SOCKET_INET
#if
!( (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) && defined(_MSC_VER) )
uint32_t
taosInetAddr
(
char
*
ipAddr
)
{
return
inet_addr
(
ipAddr
);
...
...
src/os/src/windows/wSocket.c
浏览文件 @
0fb150b1
...
...
@@ -70,7 +70,8 @@ int32_t taosSetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *op
return
setsockopt
(
socketfd
,
level
,
optname
,
optval
,
optlen
);
}
#ifdef TAOS_OS_FUNC_SOCKET_INET
#ifdef _MSC_VER
//#if _MSC_VER >= 1900
uint32_t
taosInetAddr
(
char
*
ipAddr
)
{
uint32_t
value
;
...
...
@@ -88,6 +89,7 @@ const char *taosInetNtoa(struct in_addr ipInt) {
return
inet_ntop
(
AF_INET
,
&
ipInt
,
tmpDstStr
,
INET6_ADDRSTRLEN
);
}
//#endif
#endif
#if defined(_TD_GO_DLL_)
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
0fb150b1
...
...
@@ -529,9 +529,6 @@ static void *taosProcessTcpData(void *param) {
struct
epoll_event
events
[
maxEvents
];
SRecvInfo
recvInfo
;
#ifdef __APPLE__
taos_block_sigalrm
();
#endif // __APPLE__
while
(
1
)
{
int
fdNum
=
epoll_wait
(
pThreadObj
->
pollFd
,
events
,
maxEvents
,
TAOS_EPOLL_WAIT_TIME
);
if
(
pThreadObj
->
stop
)
{
...
...
tests/examples/c/epoll.c
浏览文件 @
0fb150b1
...
...
@@ -20,7 +20,7 @@
// monitor and compare : glances
#ifdef __APPLE__
#include "
e
ok.h"
#include "
osE
ok.h"
#else // __APPLE__
#include <sys/epoll.h>
#endif // __APPLE__
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录