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