rtc.avd_SDK-C++  3.2.0
defines.h
浏览该文件的文档.
1 
2 #ifndef RTCDEFINES_H
3 #define RTCDEFINES_H
4 
6 // First definition: choose OS
8 
9 #ifdef WIN32
10  #ifndef RT_WIN32
11  #define RT_WIN32
12  #endif // RT_WIN32
13 #endif // WIN32
14 
15 #ifdef UNIX
16  #ifndef RT_UNIX
17  #define RT_UNIX
18  #endif // RT_UNIX
19 #endif // UNIX
20 
21 #ifdef LINUX
22  #ifndef RT_LINUX
23  #define RT_LINUX
24  #endif // RT_LINUX
25  #ifndef RT_UNIX
26  #define RT_UNIX
27  #endif // RT_UNIX
28 #endif // LINUX
29 
30 #ifdef ANDROID
31  #ifndef RT_ANDROID
32  #define RT_ANDROID
33  #endif // RT_LINUX
34  #ifndef RT_UNIX
35  #define RT_UNIX
36  #endif // RT_UNIX
37 #endif // ANDROID
38 
39 #ifdef MACOS
40  #ifndef RT_MACOS
41  #define RT_MACOS
42  #endif // RT_MACOS
43 #endif // MACOS
44 
45 #ifdef TARGET_OS_MAC
46  #ifndef RT_MAC
47  #define RT_MAC
48  #endif // RT_MACOS
49 #endif // MACOS
50 
51 #ifdef IOS
52 #ifndef RT_IOS
53 #define RT_IOS
54 #endif // RT_IOS
55 #endif // IOS
56 
57 #ifdef OHOS
58  #ifndef RT_OHOS
59  #define RT_OHOS
60  #endif // RT_OHOS
61 #endif // OHOS
62 
63 //visionOS
64 #ifdef XROS
65  #ifndef RT_XROS
66  #define RT_XROS
67  #endif // RT_XROS
68 #endif // XROS
69 
70 #if (defined(RT_LINUX) && !defined(RT_ANDROID) && defined(RT_X11)) || defined(RT_WIN32) || defined(RT_OHOS)/*|| (defined(RT_MAC) && !defined(RT_IOS))*/
71 #ifndef RT_DESKTOP
72 #define RT_DESKTOP
73 #endif // RT_DESKTOP
74 #endif
75 
76 #if defined(RT_DESKTOP)
77 #ifndef HAVE_WEBRTC_SCREEN
78 #define HAVE_WEBRTC_SCREEN
79 #endif
80 #endif
81 // OS API definition
84 
85 #ifdef RT_MACOS
86  #define _BSD_TIME_T_ long /* time() */
87  typedef _BSD_TIME_T_ time_t;
88  #ifndef MachOSupport
89  # define socklen_t int
90  #endif //MachOSupport
91  #define EINPROGRESS 36 /* Operation now in progress */
92  #define EINTR 4
93  #define EPERM 1
94  typedef int sem_t;
95  #define RLIMIT_NOFILE 8
96  //#define RT_HAS_BUILTIN_ATOMIC_OP 1
97  enum
98  {
99  PTHREAD_MUTEX_TIMED_NP,
100  PTHREAD_MUTEX_RECURSIVE_NP,
101  PTHREAD_MUTEX_ERRORCHECK_NP,
102  PTHREAD_MUTEX_ADAPTIVE_NP
103 
104  , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_ADAPTIVE_NP
105  };
106 
107  #ifndef MachOSupport
108  #include "ioccom.h"
109  #endif //MachOSupport
110 
111  /* Generic file-descriptor ioctl's. */
112  #define FIOCLEX _IO('f', 1) /* set close on exec on fd */
113  #define FIONCLEX _IO('f', 2) /* remove close on exec */
114  #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
115  #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
116  #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
117  #define FIOSETOWN _IOW('f', 124, int) /* set owner */
118  #define FIOGETOWN _IOR('f', 123, int) /* get owner */
119  #define FIODTYPE _IOR('f', 122, int) /* get d_type */
120 
121  //for TCP
122  #ifndef MachOSupport
123  #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
124  #endif
125 
126  #ifndef MachOSupport
127  #define TCP_MAXSEG 0x02 /* set maximum segment size */
128  #endif
129 
130  #define TCP_NOPUSH 0x04 /* don't push last block of write */
131  #define TCP_NOOPT 0x08 /* don't use TCP options */
132 
133  #ifndef MachOSupport
134  #define TCP_KEEPALIVE 0x10 /* idle time used when SO_KEEPALIVE is enabled */
135  #endif
136 //pthread
137 
138  #define PTHREAD_CREATE_JOINABLE 1
139  #define PTHREAD_CREATE_DETACHED 2
140 
141  #define PTHREAD_INHERIT_SCHED 1
142  #define PTHREAD_EXPLICIT_SCHED 2
143 
144  #define PTHREAD_CANCEL_ENABLE 0x01 /* Cancel takes place at next cancellation point */
145  #define PTHREAD_CANCEL_DISABLE 0x00 /* Cancel postponed */
146  #define PTHREAD_CANCEL_DEFERRED 0x02 /* Cancel waits until cancellation point */
147  #define PTHREAD_CANCEL_ASYNCHRONOUS 0x00 /* Cancel occurs immediately */
148 
149  /* We only support PTHREAD_SCOPE_SYSTEM */
150  #define PTHREAD_SCOPE_SYSTEM 1
151  #define PTHREAD_SCOPE_PROCESS 2
152 
153  /* We only support PTHREAD_PROCESS_PRIVATE */
154  #define PTHREAD_PROCESS_SHARED 1
155  #define PTHREAD_PROCESS_PRIVATE 2
156 
157  //extern CHARSET_INFO *default_charset_info;
158  //#define my_ctype (default_charset_info->ctype)
159  //#define isspace(c) ((my_ctype+1)[(uchar) (c)] & _S)
160  // temp define for compiler
161 
162  #ifndef MachOSupport
163  struct timespec {
164  time_t tv_sec; /* seconds */
165  long tv_nsec; /* and nanoseconds */
166  };
167 
168  //#define EAGAIN 35
169  //#define EWOULDBLOCK EAGAIN
170  #define EWOULDBLOCK 35
171  #endif //MachOSupport
172 #endif
173 
174 #ifdef RT_WIN32
175 #ifndef _CRT_SECURE_NO_WARNINGS
176  #define _CRT_SECURE_NO_WARNINGS
177 #endif
178 
179 #ifndef _SCL_SECURE_NO_DEPRECATE
180  #define _SCL_SECURE_NO_DEPRECATE
181 #endif
182 
183 #ifndef _CRT_NONSTDC_NO_WARNINGS
184 #define _CRT_NONSTDC_NO_WARNINGS
185 #endif
186 
187 #ifndef _CRT_NONSTDC_NO_DEPRECATE
188 #define _CRT_NONSTDC_NO_DEPRECATE
189 #endif
190 #endif
191 
192 #ifdef RT_SOLARIS
193  #define INADDR_NONE 0xffffffff
194 #endif
195 
196 
197 #ifdef RT_WIN32
198  #if defined (_LIB) || (RT_OS_BUILD_LIB)
199  #define RT_API_EXPORT
200  #else
201  #if defined (_USRDLL) || (RT_OS_BUILD_DLL)||(_WINDLL)
202  #define RT_API_EXPORT __declspec(dllexport)
203  #else
204  #define RT_API_EXPORT __declspec(dllimport)
205  #endif // _USRDLL || RT_OS_BUILD_DLL
206  #endif // _LIB || RT_OS_BUILD_LIB
207 
208  #ifdef RT_API_EXPORT_NONEED // for not expect plugin exports api add by oz
209  #undef RT_API_EXPORT
210  #define RT_API_EXPORT
211  #endif
212 
213 #elif defined (RT_LINUX) || defined(RT_MAC) || defined(RT_OHOS)
214  #define RT_API_EXPORT __attribute__((visibility("default")))
215 #else
216  #define RT_API_EXPORT
217 #endif // !RT_WIN32
218 
219 
220 #if defined (RT_WIN32) || defined(RT_MAC)
221  #define RT_OS_SEPARATE '\\'
222 #elif defined (RT_UNIX) || defined(RT_MACOS) || defined(RT_IOS) || defined(RT_LINUX) || defined(RT_OHOS)
223  #define RT_OS_SEPARATE '/'
224 #endif
225 
226 #define RT_BIT_ENABLED(dword, bit) (((dword) & (bit)) != 0)
227 #define RT_BIT_DISABLED(dword, bit) (((dword) & (bit)) == 0)
228 #define RT_BIT_CMP_MASK(dword, bit, mask) (((dword) & (bit)) == mask)
229 #define RT_SET_BITS(dword, bits) (dword |= (bits))
230 #define RT_CLR_BITS(dword, bits) (dword &= ~(bits))
231 
233 // Assert
235 
236 #ifdef RT_WIN32
237  #include <crtdbg.h>
238  #ifdef _DEBUG
239  #define RT_DEBUG
240  #endif // _DEBUG
241 
242  #if defined (RT_DEBUG)
243  #define RT_ASSERTE _ASSERTE
244  #endif // RT_DEBUG
245 #endif // RT_WIN32
246 
247 #ifdef RT_UNIX
248  #include <assert.h>
249  #if defined (RT_DEBUG) && !defined (RT_DISABLE_ASSERTE)
250  #define RT_ASSERTE assert
251  #endif // RT_DEBUG
252 #endif // RT_UNIX
253 
254 
255 
256 #ifdef RT_DISABLE_ASSERTE
257 #include "debug.h"
258 #ifdef RT_ASSERTE
259 #undef RT_ASSERTE
260 #endif
261 #define RT_ASSERTE(expr) \
262  do { \
263  if (!(expr)) { \
264  LOG_ERROR(__FILE__ << ":" << __LINE__ << " Assert failed: " << #expr); \
265  } \
266  } while (0)
267 #endif // RT_DISABLE_ASSERTE
268 
269 #ifndef RT_ASSERTE
270 #define RT_ASSERTE(expr)
271 #endif // RT_ASSERTE
272 
273 
274 // mainly copied from ace/Basic_Types.h
275 // Byte-order (endian-ness) determination.
276 # if defined (BYTE_ORDER)
277 # if (BYTE_ORDER == LITTLE_ENDIAN)
278 # define RT_LITTLE_ENDIAN 0x0123
279 # define RT_BYTE_ORDER RT_LITTLE_ENDIAN
280 # elif (BYTE_ORDER == BIG_ENDIAN)
281 # define RT_BIG_ENDIAN 0x3210
282 # define RT_BYTE_ORDER RT_BIG_ENDIAN
283 # else
284 # error: unknown BYTE_ORDER!
285 # endif /* BYTE_ORDER */
286 # elif defined (_BYTE_ORDER)
287 # if (_BYTE_ORDER == _LITTLE_ENDIAN)
288 # define RT_LITTLE_ENDIAN 0x0123
289 # define RT_BYTE_ORDER RT_LITTLE_ENDIAN
290 # elif (_BYTE_ORDER == _BIG_ENDIAN)
291 # define RT_BIG_ENDIAN 0x3210
292 # define RT_BYTE_ORDER RT_BIG_ENDIAN
293 # else
294 # error: unknown _BYTE_ORDER!
295 # endif /* _BYTE_ORDER */
296 # elif defined (__BYTE_ORDER)
297 # if (__BYTE_ORDER == __LITTLE_ENDIAN)
298 # define RT_LITTLE_ENDIAN 0x0123
299 # define RT_BYTE_ORDER RT_LITTLE_ENDIAN
300 # elif (__BYTE_ORDER == __BIG_ENDIAN)
301 # define RT_BIG_ENDIAN 0x3210
302 # define RT_BYTE_ORDER RT_BIG_ENDIAN
303 # else
304 # error: unknown __BYTE_ORDER!
305 # endif /* __BYTE_ORDER */
306 # else /* ! BYTE_ORDER && ! __BYTE_ORDER */
307  // We weren't explicitly told, so we have to figure it out . . .
308 # if defined (i386) || defined (__i386__) || defined (_M_IX86) || \
309  defined (vax) || defined (__alpha) || defined (__LITTLE_ENDIAN__) ||\
310  defined (ARM) || defined (_M_IA64)
311  // We know these are little endian.
312 # define RT_LITTLE_ENDIAN 0x0123
313 # define RT_BYTE_ORDER RT_LITTLE_ENDIAN
314 # else
315  // Otherwise, we assume big endian.
316 # define RT_BIG_ENDIAN 0x3210
317 # define RT_BYTE_ORDER RT_BIG_ENDIAN
318 # endif
319 # endif /* ! BYTE_ORDER && ! __BYTE_ORDER */
320 
321 #ifdef RT_WIN32
322 # define RT_LL_PREFIX "I64"
323 #else
324 #if (defined(RT_LINUX) && !defined(RT_ANDROID)) // linux
325 # define RT_LL_PREFIX "l"
326 #else
327 # define RT_LL_PREFIX "ll"
328 #endif
329 #endif
330 
331 //#include <stddef.h> // for NULL, size_t
332 #if !(defined(_MSC_VER) && (_MSC_VER < 1600))
333 #include <stdint.h> // for uintptr_t
334 #endif
335 
336 #if !defined(INT_TYPES_DEFINED)
337 #define INT_TYPES_DEFINED
338 #ifdef COMPILER_MSVC
339 typedef unsigned __int64 uint64;
340 typedef __int64 int64;
341 #ifndef INT64_C
342 #define INT64_C(x) x ## I64
343 #endif
344 #ifndef UINT64_C
345 #define UINT64_C(x) x ## UI64
346 #endif
347 #define INT64_F "I64"
348 #else // COMPILER_MSVC
349 // On Mac OS X, cssmconfig.h defines uint64 as uint64_t
350 // TODO(fbarchard): Use long long for compatibility with chromium on BSD/OSX.
351 #if defined(RT_MAC) && !defined(RT_IOS)
352 typedef uint64_t uint64;
353 typedef int64_t int64;
354 typedef uint32_t uint32;
355 
356 #ifndef INT64_C
357 #define INT64_C(x) x ## LL
358 #endif
359 #ifndef UINT64_C
360 #define UINT64_C(x) x ## ULL
361 #endif
362 #define INT64_F "l"
363 #elif defined(__LP64__)
364 #if defined(RT_LINUX) || defined(RT_ANDROID) || defined(RT_IOS) || defined(RT_OHOS) || defined(RT_XROS)
365 typedef unsigned long uint64; // NOLINT
366 #endif
367 typedef long int64; // NOLINT
368 #ifndef INT64_C
369 #define INT64_C(x) x ## L
370 #endif
371 #ifndef UINT64_C
372 #define UINT64_C(x) x ## UL
373 #endif
374 #define INT64_F "l"
375 #else // __LP64__
376 typedef unsigned long long uint64; // NOLINT
377 typedef long long int64; // NOLINT
378 #ifndef INT64_C
379 #define INT64_C(x) x ## LL
380 #endif
381 #ifndef UINT64_C
382 #define UINT64_C(x) x ## ULL
383 #endif
384 #define INT64_F "ll"
385 #endif // __LP64__
386 #endif // COMPILER_MSVC
387 typedef unsigned int uint32;
388 typedef int int32;
389 typedef unsigned short uint16; // NOLINT
390 typedef short int16; // NOLINT
391 typedef unsigned char uint8;
392 typedef signed char int8;
393 #endif // INT_TYPES_DEFINED
394 
395 #ifdef RT_LINUX
396 #ifndef LONG_MAX // added for linux build
397 #define LONG_MAX (2147483647L)
398 #endif
399 #endif
400 
401 #endif // !RTCDEFINES_H
unsigned short uint16
Definition: defines.h:389
int int32
Definition: defines.h:388
unsigned int uint32
Definition: defines.h:387
long long int64
Definition: defines.h:377
unsigned long long uint64
Definition: defines.h:376
signed char int8
Definition: defines.h:392
unsigned char uint8
Definition: defines.h:391
short int16
Definition: defines.h:390