Debian Codegraph @

Xpjproject/pjlib/include/pj/config.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef __PJ_CONFIG_H__
20 #define __PJ_CONFIG_H__
21
22
23 /**
24 * @file config.h
25 * @brief PJLIB Main configuration settings.
26 */
27
28 /********************************************************************
29 * Include compiler specific configuration.
30 */
31 #if defined(_MSC_VER)
32 # include <pj/compat/cc_msvc.h>
33 #elif defined(__clang__)
34 # include <pj/compat/cc_clang.h>
35 #elif defined(__GNUC__)
36 # include <pj/compat/cc_gcc.h>
37 #elif defined(__CW32__)
38 # include <pj/compat/cc_mwcc.h>
39 #elif defined(__MWERKS__)
40 # include <pj/compat/cc_codew.h>
41 #elif defined(__GCCE__)
42 # include <pj/compat/cc_gcce.h>
43 #elif defined(__ARMCC__)
44 # include <pj/compat/cc_armcc.h>
45 #else
46 # error "Unknown compiler."
47 #endif
48
49 /* PJ_ALIGN_DATA is compiler specific directive to align data address */
50 #ifndef PJ_ALIGN_DATA
51 # error "PJ_ALIGN_DATA is not defined!"
52 #endif
53
54 /********************************************************************
55 * Include target OS specific configuration.
56 */
57 #if defined(PJ_AUTOCONF)
58 /*
59 * Autoconf
60 */
61 # include <pj/compat/os_auto.h>
62
63 #elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
64 /*
65 * SymbianOS
66 */
67 # include <pj/compat/os_symbian.h>
68
69 #elif defined(PJ_WIN32_WINCE) || defined(_WIN32_WCE) || defined(UNDER_CE)
70 /*
71 * Windows CE
72 */
73 # undef PJ_WIN32_WINCE
74 # define PJ_WIN32_WINCE 1
75 # include <pj/compat/os_win32_wince.h>
76
77 /* Also define Win32 */
78 # define PJ_WIN32 1
79
80 #elif defined(PJ_WIN32_WINPHONE8) || defined(_WIN32_WINPHONE8)
81 /*
82 * Windows Phone 8
83 */
84 # undef PJ_WIN32_WINPHONE8
85 # define PJ_WIN32_WINPHONE8 1
86 # include <pj/compat/os_winphone8.h>
87
88 /* Also define Win32 */
89 # define PJ_WIN32 1
90
91 #elif defined(PJ_WIN32_UWP) || defined(_WIN32_UWP)
92 /*
93 * Windows UWP
94 */
95 # undef PJ_WIN32_UWP
96 # define PJ_WIN32_UWP 1
97 # include <pj/compat/os_winuwp.h>
98
99 /* Define Windows phone */
100 # define PJ_WIN32_WINPHONE8 1
101
102 /* Also define Win32 */
103 # define PJ_WIN32 1
104
105 #elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \
106 defined(WIN32) || defined(PJ_WIN64) || defined(_WIN64) || \
107 defined(WIN64) || defined(__TOS_WIN__)
108 # if defined(PJ_WIN64) || defined(_WIN64) || defined(WIN64)
109 /*
110 * Win64
111 */
112 # undef PJ_WIN64
113 # define PJ_WIN64 1
114 # endif
115 # undef PJ_WIN32
116 # define PJ_WIN32 1
117 # include <pj/compat/os_win32.h>
118
119 #elif defined(PJ_LINUX) || defined(linux) || defined(__linux)
120 /*
121 * Linux
122 */
123 # undef PJ_LINUX
124 # define PJ_LINUX 1
125 # include <pj/compat/os_linux.h>
126
127 #elif defined(PJ_PALMOS) && PJ_PALMOS!=0
128 /*
129 * Palm
130 */
131 # include <pj/compat/os_palmos.h>
132
133 #elif defined(PJ_SUNOS) || defined(sun) || defined(__sun)
134 /*
135 * SunOS
136 */
137 # undef PJ_SUNOS
138 # define PJ_SUNOS 1
139 # include <pj/compat/os_sunos.h>
140
141 #elif defined(PJ_DARWINOS) || defined(__MACOSX__) || \
142 defined (__APPLE__) || defined (__MACH__)
143 /*
144 * MacOS X
145 */
146 # undef PJ_DARWINOS
147 # define PJ_DARWINOS 1
148 # include <pj/compat/os_darwinos.h>
149
150 #elif defined(PJ_RTEMS) && PJ_RTEMS!=0
151 /*
152 * RTEMS
153 */
154 # include <pj/compat/os_rtems.h>
155 #else
156 # error "Please specify target os."
157 #endif
158
159
160 /********************************************************************
161 * Target machine specific configuration.
162 */
163 #if defined(PJ_AUTOCONF)
164 /*
165 * Autoconf configured
166 */
167 #include <pj/compat/m_auto.h>
168
169 #elif defined (PJ_M_I386) || defined(_i386_) || defined(i_386_) || \
170 defined(_X86_) || defined(x86) || defined(__i386__) || \
171 defined(__i386) || defined(_M_IX86) || defined(__I86__)
172 /*
173 * Generic i386 processor family, little-endian
174 */
175 # undef PJ_M_I386
176 # define PJ_M_I386 1
177 # define PJ_M_NAME "i386"
178 # define PJ_HAS_PENTIUM 1
179 # define PJ_IS_LITTLE_ENDIAN 1
180 # define PJ_IS_BIG_ENDIAN 0
181
182 #elif defined (PJ_M_X86_64) || defined(__amd64__) || defined(__amd64) || \
183 defined(__x86_64__) || defined(__x86_64) || \
184 defined(_M_X64) || defined(_M_AMD64)
185 /*
186 * AMD 64bit processor, little endian
187 */
188 # undef PJ_M_X86_64
189 # define PJ_M_X86_64 1
190 # define PJ_M_NAME "x86_64"
191 # define PJ_HAS_PENTIUM 1
192 # define PJ_IS_LITTLE_ENDIAN 1
193 # define PJ_IS_BIG_ENDIAN 0
194
195 #elif defined(PJ_M_IA64) || defined(__ia64__) || defined(_IA64) || \
196 defined(__IA64__) || defined( _M_IA64)
197 /*
198 * Intel IA64 processor, default to little endian
199 */
200 # undef PJ_M_IA64
201 # define PJ_M_IA64 1
202 # define PJ_M_NAME "ia64"
203 # define PJ_HAS_PENTIUM 1
204 # define PJ_IS_LITTLE_ENDIAN 1
205 # define PJ_IS_BIG_ENDIAN 0
206
207 #elif defined (PJ_M_M68K) && PJ_M_M68K != 0
208
209 /*
210 * Motorola m68k processor, big endian
211 */
212 # undef PJ_M_M68K
213 # define PJ_M_M68K 1
214 # define PJ_M_NAME "m68k"
215 # define PJ_HAS_PENTIUM 0
216 # define PJ_IS_LITTLE_ENDIAN 0
217 # define PJ_IS_BIG_ENDIAN 1
218
219
220 #elif defined (PJ_M_ALPHA) || defined (__alpha__) || defined (__alpha) || \
221 defined (_M_ALPHA)
222 /*
223 * DEC Alpha processor, little endian
224 */
225 # undef PJ_M_ALPHA
226 # define PJ_M_ALPHA 1
227 # define PJ_M_NAME "alpha"
228 # define PJ_HAS_PENTIUM 0
229 # define PJ_IS_LITTLE_ENDIAN 1
230 # define PJ_IS_BIG_ENDIAN 0
231
232
233 #elif defined(PJ_M_MIPS) || defined(__mips__) || defined(__mips) || \
234 defined(__MIPS__) || defined(MIPS) || defined(_MIPS_)
235 /*
236 * MIPS, bi-endian, so raise error if endianness is not configured
237 */
238 # undef PJ_M_MIPS
239 # define PJ_M_MIPS 1
240 # define PJ_M_NAME "mips"
241 # define PJ_HAS_PENTIUM 0
242 # if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
243 # error Endianness must be declared for this processor
244 # endif
245
246
247 #elif defined (PJ_M_SPARC) || defined( __sparc__) || defined(__sparc)
248 /*
249 * Sun Sparc, big endian
250 */
251 # undef PJ_M_SPARC
252 # define PJ_M_SPARC 1
253 # define PJ_M_NAME "sparc"
254 # define PJ_HAS_PENTIUM 0
255 # define PJ_IS_LITTLE_ENDIAN 0
256 # define PJ_IS_BIG_ENDIAN 1
257
258 #elif defined(ARM) || defined(_ARM_) || defined(__arm__) || \
259 defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__)
260 # define PJ_HAS_PENTIUM 0
261 /*
262 * ARM, bi-endian, so raise error if endianness is not configured
263 */
264 # if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
265 # error Endianness must be declared for this processor
266 # endif
267 # if defined (PJ_M_ARMV7) || defined(ARMV7)
268 # undef PJ_M_ARMV7
269 # define PJ_M_ARM7 1
270 # define PJ_M_NAME "armv7"
271 # elif defined (PJ_M_ARMV4) || defined(ARMV4)
272 # undef PJ_M_ARMV4
273 # define PJ_M_ARMV4 1
274 # define PJ_M_NAME "armv4"
275 # elif defined (PJ_M_ARM64) || defined(ARM64) || defined(__aarch64__)
276 # undef PJ_M_ARM64
277 # define PJ_M_ARM64 1
278 # define PJ_M_NAME "arm64"
279 # endif
280
281 #elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \
282 defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \
283 defined(_ARCH_PPC)
284 /*
285 * PowerPC, bi-endian, so raise error if endianness is not configured
286 */
287 # undef PJ_M_POWERPC
288 # define PJ_M_POWERPC 1
289 # define PJ_M_NAME "powerpc"
290 # define PJ_HAS_PENTIUM 0
291 # if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
292 # error Endianness must be declared for this processor
293 # endif
294
295 #elif defined (PJ_M_NIOS2) || defined(__nios2) || defined(__nios2__) || \
296 defined(__NIOS2__) || defined(__M_NIOS2) || defined(_ARCH_NIOS2)
297 /*
298 * Nios2, little endian
299 */
300 # undef PJ_M_NIOS2
301 # define PJ_M_NIOS2 1
302 # define PJ_M_NAME "nios2"
303 # define PJ_HAS_PENTIUM 0
304 # define PJ_IS_LITTLE_ENDIAN 1
305 # define PJ_IS_BIG_ENDIAN 0
306
307 #else
308 # error "Please specify target machine."
309 #endif
310
311 /* Include size_t definition. */
312 #include <pj/compat/size_t.h>
313
314 /* Include site/user specific configuration to control PJLIB features.
315 * YOU MUST CREATE THIS FILE YOURSELF!!
316 */
317 #include <pj/config_site.h>
318
319 /********************************************************************
320 * PJLIB Features.
321 */
322
323 /* Overrides for DOXYGEN */
324 #ifdef DOXYGEN
325 # undef PJ_FUNCTIONS_ARE_INLINED
326 # undef PJ_HAS_FLOATING_POINT
327 # undef PJ_LOG_MAX_LEVEL
328 # undef PJ_LOG_MAX_SIZE
329 # undef PJ_LOG_USE_STACK_BUFFER
330 # undef PJ_TERM_HAS_COLOR
331 # undef PJ_POOL_DEBUG
332 # undef PJ_HAS_TCP
333 # undef PJ_MAX_HOSTNAME
334 # undef PJ_IOQUEUE_MAX_HANDLES
335 # undef FD_SETSIZE
336 # undef PJ_HAS_SEMAPHORE
337 # undef PJ_HAS_EVENT_OBJ
338 # undef PJ_EXCEPTION_USE_WIN32_SEH
339 # undef PJ_HAS_ERROR_STRING
340
341 # define PJ_HAS_IPV6 1
342 #endif
343
344 /**
345 * @defgroup pj_config Build Configuration
346 * @{
347 *
348 * This section contains macros that can set during PJLIB build process
349 * to controll various aspects of the library.
350 *
351 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
352 * macro values during the build process.
353 */
354
355 /**
356 * If this macro is set to 1, it will enable some debugging checking
357 * in the library.
358 *
359 * Default: equal to (NOT NDEBUG).
360 */
361 #ifndef PJ_DEBUG
362 # ifndef NDEBUG
363 # define PJ_DEBUG 1
364 # else
365 # define PJ_DEBUG 0
366 # endif
367 #endif
368
369 /**
370 * Enable this macro to activate logging to mutex/semaphore related events.
371 * This is useful to troubleshoot concurrency problems such as deadlocks.
372 * In addition, you should also add PJ_LOG_HAS_THREAD_ID flag to the
373 * log decoration to assist the troubleshooting.
374 *
375 * Default: 0
376 */
377 #ifndef PJ_DEBUG_MUTEX
378 # define PJ_DEBUG_MUTEX 0
379 #endif
380
381 /**
382 * Expand functions in *_i.h header files as inline.
383 *
384 * Default: 0.
385 */
386 #ifndef PJ_FUNCTIONS_ARE_INLINED
387 # define PJ_FUNCTIONS_ARE_INLINED 0
388 #endif
389
390 /**
391 * Use floating point computations in the library.
392 *
393 * Default: 1.
394 */
395 #ifndef PJ_HAS_FLOATING_POINT
396 # define PJ_HAS_FLOATING_POINT 1
397 #endif
398
399 /**
400 * Declare maximum logging level/verbosity. Lower number indicates higher
401 * importance, with the highest importance has level zero. The least
402 * important level is five in this implementation, but this can be extended
403 * by supplying the appropriate implementation.
404 *
405 * The level conventions:
406 * - 0: fatal error
407 * - 1: error
408 * - 2: warning
409 * - 3: info
410 * - 4: debug
411 * - 5: trace
412 * - 6: more detailed trace
413 *
414 * Default: 4
415 */
416 #ifndef PJ_LOG_MAX_LEVEL
417 # define PJ_LOG_MAX_LEVEL 5
418 #endif
419
420 /**
421 * Maximum message size that can be sent to output device for each call
422 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
423 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
424 * flag is set.
425 *
426 * Default: 4000
427 */
428 #ifndef PJ_LOG_MAX_SIZE
429 # define PJ_LOG_MAX_SIZE 4000
430 #endif
431
432 /**
433 * Log buffer.
434 * Does the log get the buffer from the stack? (default is yes).
435 * If the value is set to NO, then the buffer will be taken from static
436 * buffer, which in this case will make the log function non-reentrant.
437 *
438 * Default: 1
439 */
440 #ifndef PJ_LOG_USE_STACK_BUFFER
441 # define PJ_LOG_USE_STACK_BUFFER 1
442 #endif
443
444 /**
445 * Enable log indentation feature.
446 *
447 * Default: 1
448 */
449 #ifndef PJ_LOG_ENABLE_INDENT
450 # define PJ_LOG_ENABLE_INDENT 1
451 #endif
452
453 /**
454 * Number of PJ_LOG_INDENT_CHAR to put every time pj_log_push_indent()
455 * is called.
456 *
457 * Default: 1
458 */
459 #ifndef PJ_LOG_INDENT_SIZE
460 # define PJ_LOG_INDENT_SIZE 1
461 #endif
462
463 /**
464 * Log indentation character.
465 *
466 * Default: space
467 */
468 #ifndef PJ_LOG_INDENT_CHAR
469 # define PJ_LOG_INDENT_CHAR '.'
470 #endif
471
472 /**
473 * Log sender width.
474 *
475 * Default: 22 (for 64-bit machines), 14 otherwise
476 */
477 #ifndef PJ_LOG_SENDER_WIDTH
478 # if PJ_HAS_STDINT_H
479 # include <stdint.h>
480 # if (UINTPTR_MAX == 0xffffffffffffffff)
481 # define PJ_LOG_SENDER_WIDTH 22
482 # else
483 # define PJ_LOG_SENDER_WIDTH 14
484 # endif
485 # else
486 # define PJ_LOG_SENDER_WIDTH 14
487 # endif
488 #endif
489
490 /**
491 * Log thread name width.
492 *
493 * Default: 12
494 */
495 #ifndef PJ_LOG_THREAD_WIDTH
496 # define PJ_LOG_THREAD_WIDTH 12
497 #endif
498
499 /**
500 * Colorfull terminal (for logging etc).
501 *
502 * Default: 1
503 */
504 #ifndef PJ_TERM_HAS_COLOR
505 # define PJ_TERM_HAS_COLOR 1
506 #endif
507
508
509 /**
510 * Set this flag to non-zero to enable various checking for pool
511 * operations. When this flag is set, assertion must be enabled
512 * in the application.
513 *
514 * This will slow down pool creation and destruction and will add
515 * few bytes of overhead, so application would normally want to
516 * disable this feature on release build.
517 *
518 * Default: 0
519 */
520 #ifndef PJ_SAFE_POOL
521 # define PJ_SAFE_POOL 0
522 #endif
523
524
525 /**
526 * If pool debugging is used, then each memory allocation from the pool
527 * will call malloc(), and pool will release all memory chunks when it
528 * is destroyed. This works better when memory verification programs
529 * such as Rational Purify is used.
530 *
531 * Default: 0
532 */
533 #ifndef PJ_POOL_DEBUG
534 # define PJ_POOL_DEBUG 0
535 #endif
536
537
538 /**
539 * If enabled, when calling pj_pool_release(), the memory pool content
540 * will be wiped out first before released.
541 *
542 * Default: 0
543 */
544 #ifndef PJ_POOL_RELEASE_WIPE_DATA
545 # define PJ_POOL_RELEASE_WIPE_DATA 0
546 #endif
547
548
549 /**
550 * If enabled, when allocating memory, pool will only search for a maximum
551 * number of blocks specified before deciding that the pool is full and
552 * a new memory block needs to be created.
553 *
554 * Set it to 0 to disable the limitation (i.e. it will search all blocks).
555 *
556 * Default: 5
557 */
558 #ifndef PJ_POOL_MAX_SEARCH_BLOCK_COUNT
559 # define PJ_POOL_MAX_SEARCH_BLOCK_COUNT 5
560 #endif
561
562
563 /**
564 * Enable timer debugging facility. When this is enabled, application
565 * can call pj_timer_heap_dump() to show the contents of the timer
566 * along with the source location where the timer entries were scheduled.
567 * See https://github.com/pjsip/pjproject/issues/1527 for more info.
568 *
569 * Default: 1
570 */
571 #ifndef PJ_TIMER_DEBUG
572 # define PJ_TIMER_DEBUG 1
573 #endif
574
575
576 /**
577 * If enabled, the timer will keep internal copies of the timer entries.
578 * This will increase the robustness and stability of the timer (against
579 * accidental modification or premature deallocation of the timer entries) and
580 * makes it easier to troubleshoot any timer related issues, with the overhead
581 * of additional memory space required.
582 *
583 * Note that the detection against premature deallocation only works if the
584 * freed memory content has changed (such as if it's been reallocated and
585 * overwritten by another data. Alternatively, you can enable
586 * PJ_POOL_RELEASE_WIPE_DATA which will erase the data first before releasing
587 * the memory).
588 *
589 * Default: 1 (enabled)
590 */
591 #ifndef PJ_TIMER_USE_COPY
592 # define PJ_TIMER_USE_COPY 1
593 #endif
594
595
596 /**
597 * If enabled, the timer use sorted linked list instead of binary heap tree
598 * structure. Note that using sorted linked list is intended for debugging
599 * purposes and will hamper performance significantly when scheduling large
600 * number of entries.
601 *
602 * Default: 0 (Use binary heap tree)
603 */
604 #ifndef PJ_TIMER_USE_LINKED_LIST
605 # define PJ_TIMER_USE_LINKED_LIST 0
606 #endif
607
608 /**
609 * Set this to 1 to enable debugging on the group lock. Default: 0
610 */
611 #ifndef PJ_GRP_LOCK_DEBUG
612 # define PJ_GRP_LOCK_DEBUG 0
613 #endif
614
615
616 /**
617 * Specify this as \a stack_size argument in #pj_thread_create() to specify
618 * that thread should use default stack size for the current platform.
619 *
620 * Default: 8192
621 */
622 #ifndef PJ_THREAD_DEFAULT_STACK_SIZE
623 # define PJ_THREAD_DEFAULT_STACK_SIZE 8192
624 #endif
625
626
627 /**
628 * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of
629 * the stack. The OS implementation may check that no stack overflow
630 * occurs, and it also may collect statistic about stack usage. Note
631 * that this will increase the footprint of the libraries since it
632 * tracks the filename and line number of each functions.
633 */
634 #ifndef PJ_OS_HAS_CHECK_STACK
635 # define PJ_OS_HAS_CHECK_STACK 0
636 #endif
637
638 /**
639 * Do we have alternate pool implementation?
640 *
641 * Default: 0
642 */
643 #ifndef PJ_HAS_POOL_ALT_API
644 # define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
645 #endif
646
647
648 /**
649 * Support TCP in the library.
650 * Disabling TCP will reduce the footprint slightly (about 6KB).
651 *
652 * Default: 1
653 */
654 #ifndef PJ_HAS_TCP
655 # define PJ_HAS_TCP 1
656 #endif
657
658 /**
659 * Support IPv6 in the library. If this support is disabled, some IPv6
660 * related functions will return PJ_EIPV6NOTSUP.
661 *
662 * Default: 0 (disabled, for now)
663 */
664 #ifndef PJ_HAS_IPV6
665 # define PJ_HAS_IPV6 0
666 #endif
667
668 /**
669 * Maximum hostname length.
670 * Libraries sometimes needs to make copy of an address to stack buffer;
671 * the value here affects the stack usage.
672 *
673 * Note that the length here should include the NULL termination. In other
674 * words, the maximum hostname length is PJ_MAX_HOSTNAME with the NULL
675 * termination and PJ_MAX_HOSTNAME-1 without the NULL termination.
676 *
677 * Default: 254
678 */
679 #ifndef PJ_MAX_HOSTNAME
680 # define PJ_MAX_HOSTNAME (254)
681 #endif
682
683 /**
684 * Maximum consecutive identical error for accept() operation before
685 * activesock stops calling the next ioqueue accept.
686 *
687 * Default: 50
688 */
689 #ifndef PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR
690 # define PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR 50
691 #endif
692
693
694 /*
695 * I/O queue implementation backends.
696 * Select one of these implementations in PJ_IOQUEUE_IMP.
697 */
698
699 /** No/dummy I/O queue */
700 #define PJ_IOQUEUE_IMP_NONE 0
701
702 /** Using select() */
703 #define PJ_IOQUEUE_IMP_SELECT 1
704
705 /** Using epoll() (experimental) */
706 #define PJ_IOQUEUE_IMP_EPOLL 2
707
708 /** Using Windows I/O Completion Ports (experimental) */
709 #define PJ_IOQUEUE_IMP_IOCP 3
710
711 /** Using MacOS/BSD kqueue (experimental) */
712 #define PJ_IOQUEUE_IMP_KQUEUE 4
713
714 /** Using Windows UWP socket (deprecated) */
715 #define PJ_IOQUEUE_IMP_UWP 5
716
717 /** Using Symbian (deprecated) */
718 #define PJ_IOQUEUE_IMP_SYMBIAN 6
719
720 /**
721 * I/O queue implementation backend.
722 *
723 * Default: PJ_IOQUEUE_IMP_SELECT
724 */
725 #ifndef PJ_IOQUEUE_IMP
726 # define PJ_IOQUEUE_IMP PJ_IOQUEUE_IMP_SELECT
727 #endif
728
729
730 /**
731 * Constants for declaring the maximum handles that can be supported by
732 * a single IOQ framework. This constant might not be relevant to the
733 * underlying I/O queue impelementation, but still, developers should be
734 * aware of this constant, to make sure that the program will not break when
735 * the underlying implementation changes.
736 */
737 #ifndef PJ_IOQUEUE_MAX_HANDLES
738 # define PJ_IOQUEUE_MAX_HANDLES (64)
739 #endif
740
741
742 /**
743 * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
744 * things to ensure thread safety of handle unregistration operation by
745 * employing reference counter to each handle.
746 *
747 * In addition, the ioqueue will preallocate memory for the handles,
748 * according to the maximum number of handles that is specified during
749 * ioqueue creation.
750 *
751 * All applications would normally want this enabled, but you may disable
752 * this if:
753 * - there is no dynamic unregistration to all ioqueues.
754 * - there is no threading, or there is no preemptive multitasking.
755 *
756 * Default: 1
757 */
758 #ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
759 # define PJ_IOQUEUE_HAS_SAFE_UNREG 1
760 #endif
761
762
763 /**
764 * Default concurrency setting for sockets/handles registered to ioqueue.
765 * This controls whether the ioqueue is allowed to call the key's callback
766 * concurrently/in parallel. The default is yes, which means that if there
767 * are more than one pending operations complete simultaneously, more
768 * than one threads may call the key's callback at the same time. This
769 * generally would promote good scalability for application, at the
770 * expense of more complexity to manage the concurrent accesses.
771 *
772 * Please see the ioqueue documentation for more info.
773 */
774 #ifndef PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY
775 # define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY 1
776 #endif
777
778
779 /* Sanity check:
780 * if ioqueue concurrency is disallowed, PJ_IOQUEUE_HAS_SAFE_UNREG
781 * must be enabled.
782 */
783 #if (PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY==0) && (PJ_IOQUEUE_HAS_SAFE_UNREG==0)
784 # error PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if ioqueue concurrency \
785 is disabled
786 #endif
787
788
789 /**
790 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
791 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
792 * ioqueue key is kept in closing state before it can be reused.
793 *
794 * The value is in miliseconds.
795 *
796 * Default: 500 msec.
797 */
798 #ifndef PJ_IOQUEUE_KEY_FREE_DELAY
799 # define PJ_IOQUEUE_KEY_FREE_DELAY 500
800 #endif
801
802
803 /**
804 * Default flags for epoll_flags member of pj_ioqueue_cfg structure.
805 * The values are combination of pj_ioqueue_epoll_flag constants.
806 *
807 * Default: PJ_IOQUEUE_EPOLL_AUTO
808 */
809 #ifndef PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS
810 # define PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS PJ_IOQUEUE_EPOLL_AUTO
811 #endif
812
813
814 /**
815 * This setting ensures that the read and write callbacks are invoked without
816 * holding the key mutex, even when concurrency is disabled.
817 *
818 * Note: This may introduce a race condition between key unregistration
819 * and the read/write callbacks. Therefore, the application must be prepared
820 * to handle these callbacks even after pj_ioqueue_unregister() has returned.
821 *
822 * Default: 1 (enabled).
823 */
824 #ifndef PJ_IOQUEUE_CALLBACK_NO_LOCK
825 # define PJ_IOQUEUE_CALLBACK_NO_LOCK 1
826 #endif
827
828 /**
829 * Enable the ioqueue "fast track" optimization. When enabled (default),
830 * pj_ioqueue_send(), pj_ioqueue_sendto(), and pj_ioqueue_accept() attempt
831 * the operation immediately before queuing it for async processing.
832 *
833 * This should not be disabled in production. Setting to 0 forces all
834 * operations through the async path, intended only for debugging and
835 * testing the ioqueue completion callback logic. See #4864, #4878.
836 *
837 * Default: 1 (enabled).
838 */
839 #ifndef PJ_IOQUEUE_FAST_TRACK
840 # define PJ_IOQUEUE_FAST_TRACK 1
841 #endif
842
843
844 /**
845 * Maximum number of SSL send operations that can be queued (encrypted
846 * and waiting for the network). When this limit is reached,
847 * pj_ssl_sock_send() returns PJ_EBUSY and the application must retry
848 * later.
849 *
850 * This prevents unbounded memory growth when the network stalls (e.g.,
851 * TCP window full, slow receiver). Each queued operation holds a pool
852 * with the encrypted TLS record (~4-16 KB depending on record size).
853 * Embedded or memory-constrained deployments may set this to bound
854 * memory usage per SSL socket.
855 *
856 * Default: 0 (disabled — consistent with ioqueue write_list which
857 * is also unbounded). Set to a positive value to enable.
858 */
859 #ifndef PJ_SSL_SEND_OP_ACTIVE_MAX
860 # define PJ_SSL_SEND_OP_ACTIVE_MAX 0
861 #endif
862
863
864 /**
865 * Maximum number of completed SSL send operations kept in a free list
866 * for recycling. Each send operation has its own pool (~4-16 KB for
867 * the encrypted TLS record). Recycling avoids repeated pool
868 * allocation/release on busy connections.
869 *
870 * Higher values reduce allocation overhead at the cost of resident
871 * memory per SSL socket. With asynchronous sends (PJ_IOQUEUE_FAST_TRACK
872 * disabled), operations cycle rapidly through alloc-send-free, so a
873 * larger free list reduces churn.
874 *
875 * Set to 0 to disable recycling (always release pools immediately).
876 *
877 * Default: 16
878 */
879 #ifndef PJ_SSL_SEND_OP_FREE_LIST_MAX
880 # define PJ_SSL_SEND_OP_FREE_LIST_MAX 16
881 #endif
882
883
884 /**
885 * Minimum encrypted data buffer size for SSL send operations. When a
886 * send is smaller than this value, the buffer is padded to this size
887 * so that the operation can be reused from the free list for future
888 * sends of varying sizes without reallocation.
889 *
890 * Should be at least as large as a typical TLS record overhead plus
891 * a common application payload (e.g., a SIP response ~1-2 KB).
892 *
893 * Default: 4000
894 */
895 #ifndef PJ_SSL_SEND_OP_MIN_BUF_SIZE
896 # define PJ_SSL_SEND_OP_MIN_BUF_SIZE 4000
897 #endif
898
899
900 /**
901 * Determine if FD_SETSIZE is changeable/set-able. If so, then we will
902 * set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking
903 * for Winsock.
904 */
905 #ifndef PJ_FD_SETSIZE_SETABLE
906 # if (defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H!=0) || \
907 (defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H!=0)
908 # define PJ_FD_SETSIZE_SETABLE 1
909 # else
910 # define PJ_FD_SETSIZE_SETABLE 0
911 # endif
912 #endif
913
914 /**
915 * Overrides FD_SETSIZE so it is consistent throughout the library.
916 * We only do this if we detected that FD_SETSIZE is changeable. If
917 * FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be
918 * set to value lower than FD_SETSIZE.
919 */
920 #if PJ_FD_SETSIZE_SETABLE
921 /* Only override FD_SETSIZE if the value has not been set */
922 # ifndef FD_SETSIZE
923 # define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
924 # endif
925 #else
926 /* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES
927 * is lower than FD_SETSIZE value.
928 *
929 * Update: Not all ioqueue backends require this (such as epoll), so
930 * this check will be done on the ioqueue implementation itself, such as
931 * ioqueue select.
932 */
933 /*
934 # ifdef FD_SETSIZE
935 # if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
936 # error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE"
937 # endif
938 # endif
939 */
940 #endif
941
942
943 /**
944 * Specify whether #pj_enum_ip_interface() function should exclude
945 * loopback interfaces.
946 *
947 * Default: 1
948 */
949 #ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
950 # define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
951 #endif
952
953
954 /**
955 * Has semaphore functionality?
956 *
957 * Default: 1
958 */
959 #ifndef PJ_HAS_SEMAPHORE
960 # define PJ_HAS_SEMAPHORE 1
961 #endif
962
963 /**
964 * Use dispatch semaphores on Darwin.
965 *
966 * Default: 1 on Darwin, 0 otherwise
967 */
968 #ifndef PJ_SEMAPHORE_USE_DISPATCH_SEM
969 # if defined(PJ_DARWINOS) && PJ_DARWINOS != 0
970 # define PJ_SEMAPHORE_USE_DISPATCH_SEM 1
971 # else
972 # define PJ_SEMAPHORE_USE_DISPATCH_SEM 0
973 # endif
974 #endif
975
976
977 /**
978 * Event object (for synchronization, e.g. in Win32)
979 *
980 * Default: 1
981 */
982 #ifndef PJ_HAS_EVENT_OBJ
983 # define PJ_HAS_EVENT_OBJ 1
984 #endif
985
986
987 /**
988 * Maximum file name length.
989 */
990 #ifndef PJ_MAXPATH
991 # define PJ_MAXPATH 260
992 #endif
993
994
995 /**
996 * Enable name registration for exceptions with #pj_exception_id_alloc().
997 * If this feature is enabled, then the library will keep track of
998 * names associated with each exception ID requested by application via
999 * #pj_exception_id_alloc().
1000 *
1001 * Disabling this macro will reduce the code and .bss size by a tad bit.
1002 * See also #PJ_MAX_EXCEPTION_ID.
1003 *
1004 * Default: 1
1005 */
1006 #ifndef PJ_HAS_EXCEPTION_NAMES
1007 # define PJ_HAS_EXCEPTION_NAMES 1
1008 #endif
1009
1010 /**
1011 * Maximum number of unique exception IDs that can be requested
1012 * with #pj_exception_id_alloc(). For each entry, a small record will
1013 * be allocated in the .bss segment.
1014 *
1015 * Default: 16
1016 */
1017 #ifndef PJ_MAX_EXCEPTION_ID
1018 # define PJ_MAX_EXCEPTION_ID 16
1019 #endif
1020
1021 /**
1022 * Should we use Windows Structured Exception Handling (SEH) for the
1023 * PJLIB exceptions.
1024 *
1025 * Default: 0
1026 */
1027 #ifndef PJ_EXCEPTION_USE_WIN32_SEH
1028 # define PJ_EXCEPTION_USE_WIN32_SEH 0
1029 #endif
1030
1031 /**
1032 * Should we attempt to use Pentium's rdtsc for high resolution
1033 * timestamp.
1034 *
1035 * Default: 0
1036 */
1037 #ifndef PJ_TIMESTAMP_USE_RDTSC
1038 # define PJ_TIMESTAMP_USE_RDTSC 0
1039 #endif
1040
1041 /**
1042 * Is native platform error positive number?
1043 * Default: 1 (yes)
1044 */
1045 #ifndef PJ_NATIVE_ERR_POSITIVE
1046 # define PJ_NATIVE_ERR_POSITIVE 1
1047 #endif
1048
1049 /**
1050 * Include error message string in the library (pj_strerror()).
1051 * This is very much desirable!
1052 *
1053 * Default: 1
1054 */
1055 #ifndef PJ_HAS_ERROR_STRING
1056 # define PJ_HAS_ERROR_STRING 1
1057 #endif
1058
1059
1060 /**
1061 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
1062 * functions to compare alnum strings. On some systems, they're faster
1063 * then stricmp/strcasecmp, but they can be slower on other systems.
1064 * When disabled, pjlib will fallback to stricmp/strnicmp.
1065 *
1066 * Default: 0
1067 */
1068 #ifndef PJ_HAS_STRICMP_ALNUM
1069 # define PJ_HAS_STRICMP_ALNUM 0
1070 #endif
1071
1072 /**
1073 * Prohibit the use of unsafe string functions such as strcpy(), strncpy(),
1074 * strcat(), and vsprintf().
1075 */
1076 #ifndef PJ_BAN_UNSAFE_STR_FUNCS
1077 # define PJ_BAN_UNSAFE_STR_FUNCS 0
1078 #endif
1079
1080 /**
1081 * Prohibit the use of strcpy() and pj_ansi_strcpy(), use pj_ansi_strxcpy()
1082 * instead.
1083 */
1084 #ifndef PJ_BAN_STRCPY
1085 # define PJ_BAN_STRCPY PJ_BAN_UNSAFE_STR_FUNCS
1086 #endif
1087
1088 /**
1089 * Prohibit the use of strncpy() and pj_ansi_strncpy(), use pj_ansi_strxcpy()
1090 * instead.
1091 */
1092 #ifndef PJ_BAN_STRNCPY
1093 # define PJ_BAN_STRNCPY PJ_BAN_UNSAFE_STR_FUNCS
1094 #endif
1095
1096 /**
1097 * Prohibit the use of strcat() and pj_ansi_strcat(), use pj_ansi_strxcat()
1098 * instead.
1099 */
1100 #ifndef PJ_BAN_STRCAT
1101 # define PJ_BAN_STRCAT PJ_BAN_UNSAFE_STR_FUNCS
1102 #endif
1103
1104 /**
1105 * Prohibit the use of sprintf() and pj_ansi_sprintf(),
1106 * use pj_ansi_snprintf() instead.
1107 */
1108 #ifndef PJ_BAN_SPRINTF
1109 # define PJ_BAN_SPRINTF PJ_BAN_UNSAFE_STR_FUNCS
1110 #endif
1111
1112 /**
1113 * Prohibit the use of vsprintf() and pj_ansi_vsprintf(),
1114 * use pj_ansi_vsnprintf() instead.
1115 */
1116 #ifndef PJ_BAN_VSPRINTF
1117 # define PJ_BAN_VSPRINTF PJ_BAN_UNSAFE_STR_FUNCS
1118 #endif
1119
1120 /*
1121 * Warn about obsolete macros.
1122 *
1123 * PJ_ENABLE_EXTRA_CHECK has been deprecated in 2.13.
1124 */
1125 #if defined(PJ_ENABLE_EXTRA_CHECK) && PJ_ENABLE_EXTRA_CHECK==0
1126 # ifdef _MSC_VER
1127 # pragma message("Warning: PJ_ENABLE_EXTRA_CHECK macro is deprecated"\
1128 " and has no effect")
1129 # else
1130 # warning "PJ_ENABLE_EXTRA_CHECK macro is deprecated and has no effect"
1131 # endif
1132 #endif
1133
1134
1135 /*
1136 * Types of QoS backend implementation.
1137 */
1138
1139 /**
1140 * Dummy QoS backend implementation, will always return error on all
1141 * the APIs.
1142 */
1143 #define PJ_QOS_DUMMY 1
1144
1145 /** QoS backend based on setsockopt(IP_TOS) */
1146 #define PJ_QOS_BSD 2
1147
1148 /** QoS backend for Windows Mobile 6 */
1149 #define PJ_QOS_WM 3
1150
1151 /** QoS backend for Symbian */
1152 #define PJ_QOS_SYMBIAN 4
1153
1154 /** QoS backend for Darwin */
1155 #define PJ_QOS_DARWIN 5
1156
1157 /**
1158 * Force the use of some QoS backend API for some platforms.
1159 */
1160 #ifndef PJ_QOS_IMPLEMENTATION
1161 # if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE && _WIN32_WCE >= 0x502
1162 /* Windows Mobile 6 or later */
1163 # define PJ_QOS_IMPLEMENTATION PJ_QOS_WM
1164 # elif defined(PJ_DARWINOS)
1165 /* Darwin OS (e.g: iOS, MacOS, tvOS) */
1166 # define PJ_QOS_IMPLEMENTATION PJ_QOS_DARWIN
1167 # endif
1168 #endif
1169
1170
1171 /**
1172 * Enable secure socket. For most platforms, this is implemented using
1173 * OpenSSL or GnuTLS, so this will require one of those libraries to
1174 * be installed. For Symbian platform, this is implemented natively
1175 * using CSecureSocket.
1176 *
1177 * Default: 0 (for now)
1178 */
1179 #ifndef PJ_HAS_SSL_SOCK
1180 # define PJ_HAS_SSL_SOCK 0
1181 #endif
1182
1183
1184 /*
1185 * Secure socket implementation.
1186 * Select one of these implementations in PJ_SSL_SOCK_IMP.
1187 */
1188 /** Disable SSL socket */
1189 #define PJ_SSL_SOCK_IMP_NONE 0
1190
1191 /** Using OpenSSL */
1192 #define PJ_SSL_SOCK_IMP_OPENSSL 1
1193
1194 /** Using GnuTLS */
1195 #define PJ_SSL_SOCK_IMP_GNUTLS 2
1196
1197 /** Using Apple's Secure Transport (deprecated in MacOS 10.15 & iOS 13.0) */
1198 #define PJ_SSL_SOCK_IMP_DARWIN 3
1199
1200 /** Using Apple's Network framework */
1201 #define PJ_SSL_SOCK_IMP_APPLE 4
1202
1203 /** Using Windows's Schannel */
1204 #define PJ_SSL_SOCK_IMP_SCHANNEL 5
1205
1206 /** Using Mbed TLS */
1207 #define PJ_SSL_SOCK_IMP_MBEDTLS 6
1208
1209 /**
1210 * Select which SSL socket implementation to use. Currently pjlib supports
1211 * PJ_SSL_SOCK_IMP_OPENSSL, which uses OpenSSL, and PJ_SSL_SOCK_IMP_GNUTLS,
1212 * which uses GnuTLS. Setting this to PJ_SSL_SOCK_IMP_NONE will disable
1213 * secure socket.
1214 *
1215 * Default is PJ_SSL_SOCK_IMP_NONE if PJ_HAS_SSL_SOCK is not set, otherwise
1216 * it is PJ_SSL_SOCK_IMP_OPENSSL.
1217 */
1218 #ifndef PJ_SSL_SOCK_IMP
1219 # if PJ_HAS_SSL_SOCK==0
1220 # define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_NONE
1221 # else
1222 # define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_OPENSSL
1223 # endif
1224 #endif
1225
1226
1227 /**
1228 * Define the maximum number of ciphers supported by the secure socket.
1229 *
1230 * Default: 256
1231 */
1232 #ifndef PJ_SSL_SOCK_MAX_CIPHERS
1233 # define PJ_SSL_SOCK_MAX_CIPHERS 256
1234 #endif
1235
1236
1237 /**
1238 * Specify what should be set as the available list of SSL_CIPHERs. For
1239 * example, set this as "DEFAULT" to use the default cipher list (Note:
1240 * PJSIP release 2.4 and before used this "DEFAULT" setting).
1241 *
1242 * Default: "HIGH:-COMPLEMENTOFDEFAULT"
1243 */
1244 #ifndef PJ_SSL_SOCK_OSSL_CIPHERS
1245 # define PJ_SSL_SOCK_OSSL_CIPHERS "HIGH:-COMPLEMENTOFDEFAULT"
1246 #endif
1247
1248
1249 /**
1250 * Define the maximum number of curves supported by the secure socket.
1251 *
1252 * Default: 32
1253 */
1254 #ifndef PJ_SSL_SOCK_MAX_CURVES
1255 # define PJ_SSL_SOCK_MAX_CURVES 32
1256 #endif
1257
1258 /**
1259 * Use OpenSSL thread locking callback. This is only applicable for OpenSSL
1260 * version prior to 1.1.0
1261 *
1262 * Default: 1 (enabled)
1263 */
1264 #ifndef PJ_SSL_SOCK_OSSL_USE_THREAD_CB
1265 # define PJ_SSL_SOCK_OSSL_USE_THREAD_CB 1
1266 #else
1267 # define PJ_SSL_SOCK_OSSL_USE_THREAD_CB 0
1268 #endif
1269
1270
1271 /**
1272 * Disable WSAECONNRESET error for UDP sockets on Win32 platforms. See
1273 * https://github.com/pjsip/pjproject/issues/1197.
1274 *
1275 * Default: 1
1276 */
1277 #ifndef PJ_SOCK_DISABLE_WSAECONNRESET
1278 # define PJ_SOCK_DISABLE_WSAECONNRESET 1
1279 #endif
1280
1281
1282 /**
1283 * Maximum number of socket options in pj_sockopt_params.
1284 *
1285 * Default: 4
1286 */
1287 #ifndef PJ_MAX_SOCKOPT_PARAMS
1288 # define PJ_MAX_SOCKOPT_PARAMS 4
1289 #endif
1290
1291
1292 /* Specify if JNI_OnLoad() will be defined in the library. If enabled,
1293 * PJSIP will set the Java Virtual Machine (JVM) inside JNI_OnLoad().
1294 *
1295 * Since there can only be one JNI_OnLoad() in a library loaded from Java,
1296 * you can disable this if the implementation is already defined somewhere
1297 * else. Then you can set the JVM using the API pj_jni_set_jvm() instead.
1298 *
1299 * Default: enabled for Android
1300 */
1301 #ifndef PJ_JNI_HAS_JNI_ONLOAD
1302 # define PJ_JNI_HAS_JNI_ONLOAD PJ_ANDROID
1303 #endif
1304
1305 /**
1306 * pj_atomic_slist implementation.
1307 * Select one of these implementations in PJ_ATOMIC_SLIST_IMPLEMENTATION.
1308 */
1309 /** Using os independent "cross-platform" implementation */
1310 #define PJ_ATOMIC_SLIST_GENERIC 0
1311
1312 /** Using Windows's single linked list */
1313 #define PJ_ATOMIC_SLIST_WIN32 1
1314
1315 /**
1316 * Select which pj_atomic_slist implementation to use. Currently pjlib supports
1317 * PJ_ATOMIC_SLIST_GENERIC, which uses internal pjsip os independent
1318 * "cross-platform" implementation, and
1319 * PJ_ATOMIC_SLIST_WIN32, which uses Windows's single linked list.
1320 * The last option is very fast, but is supported on Windows platform only.
1321 *
1322 * Default is PJ_ATOMIC_SLIST_WIN32 on Windows platform,
1323 * otherwise PJ_ATOMIC_SLIST_GENERIC.
1324 */
1325 #ifndef PJ_ATOMIC_SLIST_IMPLEMENTATION
1326 # ifdef PJ_WIN32
1327 # define PJ_ATOMIC_SLIST_IMPLEMENTATION PJ_ATOMIC_SLIST_WIN32
1328 # else
1329 # define PJ_ATOMIC_SLIST_IMPLEMENTATION PJ_ATOMIC_SLIST_GENERIC
1330 # endif // PJ_WIN32
1331 #endif //PJ_ATOMIC_SLIST_IMPLEMENTATION
1332
1333 /**
1334 * File I/O backend implementation.
1335 * Select one of these implementations in PJ_FILE_IO.
1336 * By default, PJ_FILE_IO_WIN32 is selected on Windows platform,
1337 * otherwise PJ_FILE_IO_ANSI is selected.
1338 *
1339 * select ioqueue supports both backend under Windows, but IOCP
1340 * supports Win32 file I/O only.
1341 */
1342 #define PJ_FILE_IO_WIN32 0 /* Using Win32 file I/O */
1343 #define PJ_FILE_IO_ANSI 1 /* Using ANSI C file I/O */
1344
1345 #ifndef PJ_FILE_IO
1346 # ifdef PJ_WIN32
1347 # define PJ_FILE_IO PJ_FILE_IO_WIN32
1348 # else
1349 # define PJ_FILE_IO PJ_FILE_IO_ANSI
1350 # endif // PJ_WIN32
1351 #elif PJ_FILE_IO == PJ_FILE_IO_ANSI && PJ_IOQUEUE_IMP == PJ_IOQUEUE_IMP_IOCP
1352 # error IOCP ioqueue does not support ANSI file backend
1353 #endif //PJ_FILE_IO
1354
1355 /** @} */
1356
1357 /********************************************************************
1358 * General macros.
1359 */
1360
1361 /**
1362 * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO)
1363 * @ingroup pj_config
1364 * @{
1365 *
1366 * The libraries support generation of dynamic link libraries for
1367 * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian
1368 * terms). Similar procedures may be applied for Win32 DLL with some
1369 * modification.
1370 *
1371 * Depending on the platforms, these steps may be necessary in order to
1372 * produce the dynamic libraries:
1373 * - Create the (Visual Studio) projects to produce DLL output. PJLIB
1374 * does not provide ready to use project files to produce DLL, so
1375 * you need to create these projects yourself. For Symbian, the MMP
1376 * files have been setup to produce DSO files for targets that
1377 * require them.
1378 * - In the (Visual Studio) projects, some macros need to be declared
1379 * so that appropriate modifiers are added to symbol declarations
1380 * and definitions. Please see the macro section below for information
1381 * regarding these macros. For Symbian, these have been taken care by the
1382 * MMP files.
1383 * - Some build systems require .DEF file to be specified when creating
1384 * the DLL. For Symbian, .DEF files are included in pjlib distribution,
1385 * in <tt>pjlib/build.symbian</tt> directory. These DEF files are
1386 * created by running <tt>./makedef.sh all</tt> from this directory,
1387 * inside Mingw.
1388 *
1389 * Macros related for building DLL/DSO files:
1390 * - For platforms that supports dynamic link libraries generation,
1391 * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains
1392 * the prefix to be added to symbol definition, to export this
1393 * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
1394 * value of this macro is \a __declspec(dllexport), and for ARM
1395 * ABIv2/Symbian, the value is \a EXPORT_C.
1396 * - For platforms that supports linking with dynamic link libraries,
1397 * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains
1398 * the prefix to be added to symbol declaration, to import this
1399 * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
1400 * value of this macro is \a __declspec(dllimport), and for ARM
1401 * ABIv2/Symbian, the value is \a IMPORT_C.
1402 * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt>
1403 * macros above can be declared in your \a config_site.h if they are not
1404 * declared by pjlib.
1405 * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and
1406 * <tt>PJ_EXPORTING</tt> macros must be declared, so that
1407 * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function
1408 * definition.
1409 * - When application wants to link dynamically with PJLIB, then it
1410 * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header,
1411 * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into
1412 * symbol declarations.
1413 *
1414 * When <b>PJ_DLL</b> macro is not declared, static linking is assumed.
1415 *
1416 * For example, here are some settings to produce DLLs with Visual Studio
1417 * on Windows/Win32:
1418 * - Create Visual Studio projects to produce DLL. Add the appropriate
1419 * project dependencies to avoid link errors.
1420 * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt>
1421 * macros.
1422 * - Declare these macros in your <tt>config_site.h</tt>:
1423 \verbatim
1424 #define PJ_EXPORT_SPECIFIER __declspec(dllexport)
1425 #define PJ_IMPORT_SPECIFIER __declspec(dllimport)
1426 \endverbatim
1427 * - And in the application (that links with the DLL) project, add
1428 * <tt>PJ_DLL</tt> in the macro declarations.
1429 */
1430
1431 /** @} */
1432
1433 /**
1434 * @defgroup pj_config Build Configuration
1435 * @{
1436 */
1437
1438 /**
1439 * @def PJ_INLINE(type)
1440 * @param type The return type of the function.
1441 * Expand the function as inline.
1442 */
1443 #define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
1444
1445 /**
1446 * This macro declares platform/compiler specific specifier prefix
1447 * to be added to symbol declaration to export the symbol when PJLIB
1448 * is built as dynamic library.
1449 *
1450 * This macro should have been added by platform specific headers,
1451 * if the platform supports building dynamic library target.
1452 */
1453 #ifndef PJ_EXPORT_DECL_SPECIFIER
1454 # define PJ_EXPORT_DECL_SPECIFIER
1455 #endif
1456
1457
1458 /**
1459 * This macro declares platform/compiler specific specifier prefix
1460 * to be added to symbol definition to export the symbol when PJLIB
1461 * is built as dynamic library.
1462 *
1463 * This macro should have been added by platform specific headers,
1464 * if the platform supports building dynamic library target.
1465 */
1466 #ifndef PJ_EXPORT_DEF_SPECIFIER
1467 # define PJ_EXPORT_DEF_SPECIFIER
1468 #endif
1469
1470
1471 /**
1472 * This macro declares platform/compiler specific specifier prefix
1473 * to be added to symbol declaration to import the symbol.
1474 *
1475 * This macro should have been added by platform specific headers,
1476 * if the platform supports building dynamic library target.
1477 */
1478 #ifndef PJ_IMPORT_DECL_SPECIFIER
1479 # define PJ_IMPORT_DECL_SPECIFIER
1480 #endif
1481
1482
1483 /**
1484 * This macro has been deprecated. It will evaluate to nothing.
1485 */
1486 #ifndef PJ_EXPORT_SYMBOL
1487 # define PJ_EXPORT_SYMBOL(x)
1488 #endif
1489
1490
1491 /**
1492 * @def PJ_DECL(type)
1493 * @param type The return type of the function.
1494 * Declare a function.
1495 */
1496 #if defined(PJ_DLL)
1497 # if defined(PJ_EXPORTING)
1498 # define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
1499 # else
1500 # define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
1501 # endif
1502 #elif !defined(PJ_DECL)
1503 # if defined(__cplusplus)
1504 # define PJ_DECL(type) type
1505 # else
1506 # define PJ_DECL(type) extern type
1507 # endif
1508 #endif
1509
1510
1511 /**
1512 * @def PJ_DEF(type)
1513 * @param type The return type of the function.
1514 * Define a function.
1515 */
1516 #if defined(PJ_DLL) && defined(PJ_EXPORTING)
1517 # define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
1518 #elif !defined(PJ_DEF)
1519 # define PJ_DEF(type) type
1520 #endif
1521
1522
1523 /**
1524 * @def PJ_DECL_NO_RETURN(type)
1525 * @param type The return type of the function.
1526 * Declare a function that will not return.
1527 */
1528 /**
1529 * @def PJ_IDECL_NO_RETURN(type)
1530 * @param type The return type of the function.
1531 * Declare an inline function that will not return.
1532 */
1533 /**
1534 * @def PJ_BEGIN_DECL
1535 * Mark beginning of declaration section in a header file.
1536 */
1537 /**
1538 * @def PJ_END_DECL
1539 * Mark end of declaration section in a header file.
1540 */
1541 #ifdef __cplusplus
1542 # define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
1543 # define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
1544 # define PJ_BEGIN_DECL extern "C" {
1545 # define PJ_END_DECL }
1546 #else
1547 # define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
1548 # define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
1549 # define PJ_BEGIN_DECL
1550 # define PJ_END_DECL
1551 #endif
1552
1553
1554
1555 /**
1556 * @def PJ_DECL_DATA(type)
1557 * @param type The data type.
1558 * Declare a global data.
1559 */
1560 #if defined(PJ_DLL)
1561 # if defined(PJ_EXPORTING)
1562 # define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
1563 # else
1564 # define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
1565 # endif
1566 #elif !defined(PJ_DECL_DATA)
1567 # define PJ_DECL_DATA(type) extern type
1568 #endif
1569
1570
1571 /**
1572 * @def PJ_DEF_DATA(type)
1573 * @param type The data type.
1574 * Define a global data.
1575 */
1576 #if defined(PJ_DLL) && defined(PJ_EXPORTING)
1577 # define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
1578 #elif !defined(PJ_DEF_DATA)
1579 # define PJ_DEF_DATA(type) type
1580 #endif
1581
1582
1583 /**
1584 * @def PJ_IDECL(type)
1585 * @param type The function's return type.
1586 * Declare a function that may be expanded as inline.
1587 */
1588 /**
1589 * @def PJ_IDEF(type)
1590 * @param type The function's return type.
1591 * Define a function that may be expanded as inline.
1592 */
1593
1594 #if PJ_FUNCTIONS_ARE_INLINED
1595 # define PJ_IDECL(type) PJ_INLINE(type)
1596 # define PJ_IDEF(type) PJ_INLINE(type)
1597 #else
1598 # define PJ_IDECL(type) PJ_DECL(type)
1599 # define PJ_IDEF(type) PJ_DEF(type)
1600 #endif
1601
1602
1603 /**
1604 * @def PJ_UNUSED_ARG(arg)
1605 * @param arg The argument name.
1606 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
1607 */
1608 #define PJ_UNUSED_ARG(arg) (void)arg
1609
1610 /**
1611 * @def PJ_TODO(id)
1612 * @param id Any identifier that will be printed as TODO message.
1613 * PJ_TODO macro will display TODO message as warning during compilation.
1614 * Example: PJ_TODO(CLEAN_UP_ERROR);
1615 */
1616 #ifndef PJ_TODO
1617 # define PJ_TODO(id) TODO___##id:
1618 #endif
1619
1620 /**
1621 * Simulate race condition by sleeping the thread in strategic locations.
1622 * Default: no!
1623 */
1624 #ifndef PJ_RACE_ME
1625 # define PJ_RACE_ME(x)
1626 #endif
1627
1628 /**
1629 * Function attributes to inform that the function may throw exception.
1630 *
1631 * @param x The exception list, enclosed in parenthesis.
1632 */
1633 #define __pj_throw__(x)
1634
1635 /** @} */
1636
1637 /********************************************************************
1638 * Sanity Checks
1639 */
1640 #ifndef PJ_HAS_HIGH_RES_TIMER
1641 # error "PJ_HAS_HIGH_RES_TIMER is not defined!"
1642 #endif
1643
1644 #if !defined(PJ_HAS_PENTIUM)
1645 # error "PJ_HAS_PENTIUM is not defined!"
1646 #endif
1647
1648 #if !defined(PJ_IS_LITTLE_ENDIAN)
1649 # error "PJ_IS_LITTLE_ENDIAN is not defined!"
1650 #endif
1651
1652 #if !defined(PJ_IS_BIG_ENDIAN)
1653 # error "PJ_IS_BIG_ENDIAN is not defined!"
1654 #endif
1655
1656 #if !defined(PJ_EMULATE_RWMUTEX)
1657 # error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
1658 #endif
1659
1660 #if !defined(PJ_THREAD_SET_STACK_SIZE)
1661 # error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
1662 #endif
1663
1664 #if !defined(PJ_THREAD_ALLOCATE_STACK)
1665 # error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
1666 #endif
1667
1668 PJ_BEGIN_DECL
1669
1670 /** PJLIB version major number. */
1671 #define PJ_VERSION_NUM_MAJOR 2
1672
1673 /** PJLIB version minor number. */
1674 #define PJ_VERSION_NUM_MINOR 17
1675
1676 /** PJLIB version revision number. */
1677 #define PJ_VERSION_NUM_REV 0
1678
1679 /**
1680 * Extra suffix for the version (e.g. "-trunk"), or empty for
1681 * web release version.
1682 */
1683 #define PJ_VERSION_NUM_EXTRA ""
1684
1685 /**
1686 * PJLIB version number consists of three bytes with the following format:
1687 * 0xMMIIRR00, where MM: major number, II: minor number, RR: revision
1688 * number, 00: always zero for now.
1689 */
1690 #define PJ_VERSION_NUM ((PJ_VERSION_NUM_MAJOR << 24) | \
1691 (PJ_VERSION_NUM_MINOR << 16) | \
1692 (PJ_VERSION_NUM_REV << 8))
1693
1694 /**
1695 * PJLIB version string constant. @see pj_get_version()
1696 */
1697 PJ_DECL_DATA(const char*) PJ_VERSION;
1698
1699 /**
1700 * Get PJLIB version string.
1701 *
1702 * @return #PJ_VERSION constant.
1703 */
1704 PJ_DECL(const char*) pj_get_version(void);
1705
1706 /**
1707 * Dump configuration to log with verbosity equal to info(3).
1708 */
1709 PJ_DECL(void) pj_dump_config(void);
1710
1711 PJ_END_DECL
1712
1713
1714 #endif /* __PJ_CONFIG_H__ */
1715