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