• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef POSIX_HELP_H
17 #define POSIX_HELP_H
18 
19 #include <errno.h>
20 #include <strings.h>
21 #include <stdint.h>
22 #include <netinet/in.h>
23 #include <pthread.h>
24 
25 #if __cplusplus
26 extern "C" {
27 #endif
28 
29 #define HI_USLEEP_MS    1000
30 
31 /*
32  * Socketpair通道
33  * Socketpair channel
34  */
35 typedef struct SkPair {
36     int in; // in fd
37     int out; // out fd
38 } SkPair;
39 
40 /*
41  * 创建Socketpair
42  * Socketpair create
43  */
44 int SkPairCreate(SkPair* chn);
45 
46 /*
47  * 读完整的消息
48  * Read complete message
49  */
50 int FdReadMsg(int fd, HI_VOID* msgBuf, int msgSize);
51 
52 /*
53  * 写完整的消息
54  * Write complete message
55  */
56 int FdWriteMsg(int fd, const HI_VOID* msgData, int msgLen);
57 
58 /*
59  * 销毁socketpair
60  * Socketpair destroy
61  */
62 void SkPairDestroy(SkPair* chn);
63 
64 /*
65  * 初始化recursive pmutex
66  * Init recursive pmutex
67  */
68 void RecurMutexInit(pthread_mutex_t* mutex);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 #endif
74