Modify licenses
[scp/ocu/5gnr.git] / Include / vos_types.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2020 ICT/CAS.
4 *
5 *   Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       https://www.o-ran.org/software
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19
20
21 #include "vos_sys_diff.h"
22
23 #ifndef _VOS_TYPES_H_
24 #define _VOS_TYPES_H_
25
26 #ifdef __cplusplus
27     extern "C" {
28 #endif
29 #include <stddef.h>
30
31 #define VOS_NAME_MAX_LENGTH     128                 /* VOS有名字的对象的名字的最大长度. */
32
33
34 #define VOS_YES    (1)
35 #define VOS_NO     (0)
36
37 #define VOS_OK     (0)
38 #define VOS_ERROR (-1)
39
40 #define VOS_FALSE               (0)
41 #define VOS_TRUE                (1)
42
43 #define CONST               const
44 #define VOS_PACKED          __attribute__((packed))
45
46 typedef struct VOS_MAC_addr_s{
47     unsigned char addr[6];
48 }VOS_PACKED VOS_MAC_addr_t;
49
50 typedef struct VOS_IPv4_addr_s{
51     unsigned long addr;
52 }VOS_PACKED VOS_IPv4_addr_t;
53
54 typedef struct VOS_IPv6_addr_s{
55     unsigned char addr[16];
56 }VOS_PACKED VOS_IPv6_addr_t;
57
58
59 typedef void                VOID;
60 typedef int                 BOOL;
61
62 typedef char                CHAR;
63 typedef unsigned char       UCHAR;
64
65 typedef short               SHORT;
66 typedef unsigned short      USHORT;
67
68
69 typedef int                 INT;
70 typedef unsigned int        UINT;
71
72 typedef long                LONG;
73 typedef unsigned long       ULONG;
74
75 typedef unsigned char       BYTE;
76 typedef unsigned short      WORD;
77 typedef unsigned long       DWORD;
78 typedef float               FLOAT;
79
80
81 typedef char                *LPSTR;
82 typedef const char          *LPCSTR;
83 typedef unsigned long       *PULONG;
84
85 typedef LONG                 LRESULT;
86 typedef void                *VOS_HANDLE;
87
88
89 typedef char                 INT8;
90 typedef unsigned char        UINT8;
91
92 typedef short                INT16;
93 typedef unsigned short       UINT16;
94
95 typedef int                  INT32;
96 typedef unsigned int         UINT32;
97
98 typedef long                 INT64;
99 typedef unsigned long        UINT64;
100
101
102 #if 0
103 #if defined __GNUG__
104 #define NULL (__null)
105 #else
106 #if !defined(__cplusplus) && 0
107 #define NULL ((void*)0)
108 #else
109 #define NULL (0)
110 #endif
111 #endif
112 #endif
113
114 #if defined (OS_LINUX)
115
116 #ifndef HAVE_DOUBLE
117 #define HAVE_DOUBLE
118 typedef double              DOUBLE;
119 #endif
120
121 #ifndef HAVE_PUSHORT
122 #define HAVE_PUSHORT
123 typedef unsigned short      *PUSHORT;
124 #endif
125
126 #ifndef HAVE_PUCHAR
127 #define HAVE_PUCHAR
128 typedef unsigned char       *PUCHAR;
129 #endif
130
131
132 #ifndef HAVE_PFLOAT
133 #define HAVE_PFLOAT
134 typedef FLOAT               *PFLOAT;
135 #endif
136
137 #ifndef HAVE_PBOOL
138 #define HAVE_PBOOL
139 typedef int                 *PBOOL;
140 #endif
141
142 #ifndef HAVE_LPBOOL
143 #define HAVE_LPBOOL
144 typedef int                 *LPBOOL;
145 #endif
146
147 #ifndef HAVE_PBYTE
148 #define HAVE_PBYTE
149 typedef BYTE                *PBYTE;
150 #endif
151
152 #ifndef HAVE_LPBYTE
153 #define HAVE_LPBYTE
154 typedef BYTE                *LPBYTE;
155 #endif
156
157 #ifndef HAVE_PINT
158 #define HAVE_PINT
159 typedef int                 *PINT;
160 #endif
161
162 #ifndef HAVE_LPINT
163 #define HAVE_LPINT
164 typedef int                 *LPINT;
165 #endif
166
167 #ifndef HAVE_PWORD
168 #define HAVE_PWORD
169 typedef WORD                *PWORD;
170 #endif
171
172 #ifndef HAVE_LPWORD
173 #define HAVE_LPWORD
174 typedef WORD                *LPWORD;
175 #endif
176
177 #ifndef HAVE_LPLONG
178 #define HAVE_LPLONG
179 typedef long                *LPLONG;
180 #endif
181
182 #ifndef HAVE_PDWORD
183 #define HAVE_PDWORD
184 typedef DWORD               *PDWORD;
185 #endif
186
187 #ifndef HAVE_LPDWORD
188 #define HAVE_LPDWORD
189 typedef DWORD               *LPDWORD;
190 #endif
191
192 #ifndef HAVE_LPVOID
193 #define HAVE_LPVOID
194 typedef void                *LPVOID;
195 #endif
196
197 #ifndef HAVE_LPCVOID
198 #define HAVE_LPCVOID
199 typedef const void          *LPCVOID;
200 #endif
201
202 #ifndef HAVE_PUINT
203 #define HAVE_PUINT
204 typedef unsigned int        *PUINT;
205 #endif
206
207 /* Types use for passing & returning polymorphic values */
208 #ifndef HAVE_WPARAM
209 #define HAVE_WPARAM
210 typedef unsigned int        WPARAM;
211 #endif
212
213 #ifndef HAVE_LPARAM
214 #define HAVE_LPARAM
215 typedef LONG                LPARAM;
216 #endif
217
218 #ifndef HAVE_LRESULT
219 #define HAVE_LRESULT
220 typedef LONG                LRESULT;
221 #endif
222
223
224 #ifndef HAVE_LONGLONG
225 #define HAVE_LONGLONG
226 typedef long long           LONGLONG;
227 #endif
228
229 #ifndef HAVE_ULONGLONG
230 #define HAVE_ULONGLONG
231 typedef unsigned long long  ULONGLONG;
232 #endif
233
234 #ifndef HAVE_longlong
235 #define HAVE_longlong
236 typedef long long longlong;
237 #endif
238
239 #ifndef HAVE_ulonglong
240 #define HAVE_ulonglong
241 typedef unsigned long long ulonglong;
242 #endif
243
244 #if OS_LINUX
245 #define inline
246 #define _inline
247 #define __inline__
248 #define __const__  const
249 #define __signed__ signed
250 #define __const__ const
251 #endif
252
253 /* base 32*/
254
255 #define VOS_ERR_OUT VOS_Printf("error! %s(%u),%s\r\n",__FILE__,__LINE__,__func__)
256 #define VOS_VAL_OUT(a) VOS_Printf("\r\n var(%s),value(%d),%s(%u),%s\r\n",(#a),(a),__FILE__,__LINE__,__func__)
257 #define VOS_VAL_OUT_U(a) VOS_Printf("\r\n var(%s),value(%u),%s(%u),%s\r\n",(#a),(a),__FILE__,__LINE__,__func__)
258 #define VOS_STR_OUT(a) VOS_Printf("\r\n %s,%s(%u),%s\r\n",(a),__FILE__,__LINE__,__func__)
259
260
261 /* 求余 */
262 #define __VOS_RESIDUE( _n, _2_exp )     (((_n)<<(32-(_2_exp)))>>(32-(_2_exp)))
263
264 /* 求商 */
265 #define __VOS_QUOTIENT( _n, _2_exp )    ((_n)>>(_2_exp))
266
267 /* 去尾取整 */
268 #define __VOS_INTZERO( _n, _2_exp )     (__VOS_QUOTIENT( _n, _2_exp )<<(_2_exp))
269
270 /* 进位取整 */
271 #define __VOS_INTINCR( _n, _2_exp )     \
272         ((__VOS_QUOTIENT( _n, _2_exp ) + (0==__VOS_QUOTIENT( __VOS_RESIDUE( _n, _2_exp ), _2_exp ))?0:1)<<(_2_exp))
273
274
275 #endif
276
277 #define CL_LIB_AF_INET6 10
278 #define CL_LIB_AF_INET  2
279
280 typedef struct{
281     UINT family;
282     union {
283         /** IPv4 addr  */
284         UINT ip4;
285         /** IPv6 addr structure */
286         union
287         {
288             UCHAR     addr8[16];
289             USHORT    addr16[8];
290             UINT      addr32[4];
291         } ip6;
292     }addr;
293 }VOS_IP_t;
294
295 #define VOS_SNMP_DateAndTime_SIZE 8
296 typedef struct VOS_SNMP_DateAndTime_s{
297     CHAR DateAndTime[VOS_SNMP_DateAndTime_SIZE];
298 }VOS_SNMP_DateAndTime_t;
299
300
301 #ifdef __cplusplus
302     }
303 #endif
304
305 #endif /*_VOS_TYPES_H_*/