mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-27 10:50:41 +00:00
优化宏定义转换
Signed-off-by: zourongchun <zourongchun@huawei.com>
This commit is contained in:
parent
cef9ef1c62
commit
b4b75eb289
@ -25,6 +25,7 @@ if (defined(ohos_lite)) {
|
||||
config("dsoftbus_adapter_common_interface") {
|
||||
include_dirs = [
|
||||
"$softbus_adapter_common/include",
|
||||
"$softbus_adapter_common/include/OS_adapter_define/linux",
|
||||
"$softbus_adapter_config/spec_config",
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$hilog_lite_include_path",
|
||||
@ -102,6 +103,7 @@ if (defined(ohos_lite)) {
|
||||
config("config_adapter_common") {
|
||||
include_dirs = [
|
||||
"$softbus_adapter_common/include",
|
||||
"$softbus_adapter_common/include/OS_adapter_define/linux",
|
||||
"$dsoftbus_standard_feature_product_config_path/spec_config",
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
]
|
||||
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOFTBUS_ADAPTER_DEFINE_H
|
||||
#define SOFTBUS_ADAPTER_DEFINE_H
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* sys/socket.h */
|
||||
#define SOFTBUS_PF_INET_ PF_INET
|
||||
#define SOFTBUS_AF_INET_ AF_INET
|
||||
|
||||
#define SOFTBUS_SOCK_STREAM_ SOCK_STREAM
|
||||
#define SOFTBUS_SOCK_DGRAM_ SOCK_DGRAM
|
||||
|
||||
#define SOFTBUS_SOCK_CLOEXEC_ SOCK_CLOEXEC
|
||||
#define SOFTBUS_SOCK_NONBLOCK_ SOCK_NONBLOCK
|
||||
|
||||
#define SOFTBUS_SOL_SOCKET_ SOL_SOCKET
|
||||
|
||||
#define SOFTBUS_SO_REUSEADDR_ SO_REUSEADDR
|
||||
#define SOFTBUS_SO_KEEPALIVE_ SO_KEEPALIVE
|
||||
#define SOFTBUS_SO_REUSEPORT_ SO_REUSEPORT
|
||||
|
||||
#define SOFTBUS_TCP_KEEPIDLE_ TCP_KEEPIDLE
|
||||
#define SOFTBUS_TCP_KEEPINTVL_ TCP_KEEPINTVL
|
||||
#define SOFTBUS_TCP_KEEPCNT_ TCP_KEEPCNT
|
||||
|
||||
#define SOFTBUS_SHUT_RD_ SHUT_RD
|
||||
#define SOFTBUS_SHUT_WR_ SHUT_WR
|
||||
#define SOFTBUS_SHUT_RDWR_ SHUT_RDWR
|
||||
|
||||
/* netinet/in.h */
|
||||
#define SOFTBUS_IPPROTO_IP_ IPPROTO_IP
|
||||
#define SOFTBUS_IPPROTO_TCP_ IPPROTO_TCP
|
||||
|
||||
#define SOFTBUS_IP_TOS_ IP_TOS
|
||||
|
||||
/* netinet/tcp.h */
|
||||
#define SOFTBUS_TCP_NODELAY_ TCP_NODELAY
|
||||
|
||||
/* fcntl.h */
|
||||
#define SOFTBUS_F_GETFL_ F_GETFL
|
||||
#define SOFTBUS_F_SETFL_ F_SETFL
|
||||
|
||||
#define SOFTBUS_O_NONBLOCK_ O_NONBLOCK
|
||||
|
||||
/* select.h */
|
||||
/* linux support 1024, liteos support 640 */
|
||||
#define SOFTBUS_FD_SETSIZE_ FD_SETSIZE
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/select.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "softbus_adapter_define.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@ -30,47 +30,47 @@ extern "C" {
|
||||
#define ADDR_IN_RESER_SIZE (8)
|
||||
|
||||
/* sys/socket.h */
|
||||
#define SOFTBUS_PF_INET (2)
|
||||
#define SOFTBUS_AF_INET SOFTBUS_PF_INET
|
||||
#define SOFTBUS_PF_INET SOFTBUS_PF_INET_
|
||||
#define SOFTBUS_AF_INET SOFTBUS_AF_INET_
|
||||
|
||||
#define SOFTBUS_SOCK_STREAM (1)
|
||||
#define SOFTBUS_SOCK_DGRAM (2)
|
||||
#define SOFTBUS_SOCK_STREAM SOFTBUS_SOCK_STREAM_
|
||||
#define SOFTBUS_SOCK_DGRAM SOFTBUS_SOCK_DGRAM_
|
||||
|
||||
#define SOFTBUS_SOCK_CLOEXEC (02000000)
|
||||
#define SOFTBUS_SOCK_NONBLOCK (04000)
|
||||
#define SOFTBUS_SOCK_CLOEXEC SOFTBUS_SOCK_CLOEXEC_
|
||||
#define SOFTBUS_SOCK_NONBLOCK SOFTBUS_SOCK_NONBLOCK_
|
||||
|
||||
#define SOFTBUS_SOL_SOCKET (1)
|
||||
#define SOFTBUS_SOL_SOCKET SOFTBUS_SOL_SOCKET_
|
||||
|
||||
#define SOFTBUS_SO_REUSEADDR (2)
|
||||
#define SOFTBUS_SO_KEEPALIVE (9)
|
||||
#define SOFTBUS_SO_REUSEPORT (15)
|
||||
#define SOFTBUS_SO_REUSEADDR SOFTBUS_SO_REUSEADDR_
|
||||
#define SOFTBUS_SO_KEEPALIVE SOFTBUS_SO_KEEPALIVE_
|
||||
#define SOFTBUS_SO_REUSEPORT SOFTBUS_SO_REUSEPORT_
|
||||
|
||||
#define SOFTBUS_TCP_KEEPIDLE (4)
|
||||
#define SOFTBUS_TCP_KEEPINTVL (5)
|
||||
#define SOFTBUS_TCP_KEEPCNT (6)
|
||||
#define SOFTBUS_TCP_KEEPIDLE SOFTBUS_TCP_KEEPIDLE_
|
||||
#define SOFTBUS_TCP_KEEPINTVL SOFTBUS_TCP_KEEPINTVL_
|
||||
#define SOFTBUS_TCP_KEEPCNT SOFTBUS_TCP_KEEPCNT_
|
||||
|
||||
#define SOFTBUS_SHUT_RD (0)
|
||||
#define SOFTBUS_SHUT_WR (1)
|
||||
#define SOFTBUS_SHUT_RDWR (2)
|
||||
#define SOFTBUS_SHUT_RD SOFTBUS_SHUT_RD_
|
||||
#define SOFTBUS_SHUT_WR SOFTBUS_SHUT_WR_
|
||||
#define SOFTBUS_SHUT_RDWR SOFTBUS_SHUT_RDWR_
|
||||
|
||||
/* netinet/in.h */
|
||||
#define SOFTBUS_IPPROTO_IP (0)
|
||||
#define SOFTBUS_IPPROTO_TCP (6)
|
||||
#define SOFTBUS_IPPROTO_IP SOFTBUS_IPPROTO_IP_
|
||||
#define SOFTBUS_IPPROTO_TCP SOFTBUS_IPPROTO_TCP_
|
||||
|
||||
#define SOFTBUS_IP_TOS (1)
|
||||
#define SOFTBUS_IP_TOS SOFTBUS_IP_TOS_
|
||||
|
||||
/* netinet/tcp.h */
|
||||
#define SOFTBUS_TCP_NODELAY (1)
|
||||
#define SOFTBUS_TCP_NODELAY SOFTBUS_TCP_NODELAY_
|
||||
|
||||
/* fcntl.h */
|
||||
#define SOFTBUS_F_GETFL (3)
|
||||
#define SOFTBUS_F_SETFL (4)
|
||||
#define SOFTBUS_F_GETFL SOFTBUS_F_GETFL_
|
||||
#define SOFTBUS_F_SETFL SOFTBUS_F_SETFL_
|
||||
|
||||
#define SOFTBUS_O_NONBLOCK (04000)
|
||||
#define SOFTBUS_O_NONBLOCK SOFTBUS_O_NONBLOCK_
|
||||
|
||||
/* select.h */
|
||||
/* linux support 1024, liteos support 640 */
|
||||
#define SOFTBUS_FD_SETSIZE (1024)
|
||||
#define SOFTBUS_FD_SETSIZE SOFTBUS_FD_SETSIZE_
|
||||
|
||||
/* netinet/in.h */
|
||||
typedef struct {
|
||||
|
@ -186,14 +186,7 @@ int32_t InitSoftBus(const char *pkgName)
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
if (g_isInited == true) {
|
||||
//(void)pthread_mutex_lock(&g_isInitedLock);
|
||||
(void)ClientRegisterPkgName(pkgName);
|
||||
//pthread_mutex_unlock(&g_isInitedLock);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
if (SoftBusMutexInit(&g_isInitedLock, NULL) != SOFTBUS_OK) {
|
||||
if ((g_isInited == false) && (SoftBusMutexInit(&g_isInitedLock, NULL) != SOFTBUS_OK)) {
|
||||
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "lock init failed");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user