blob: 23fc68d69d89abd9416b268bdabb47916f3166f4 [file] [log] [blame]
Tristan Matthews0a329cc2013-07-17 13:20:14 -04001/* $Id: config.h 4537 2013-06-19 06:47:43Z riza $ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJ_CONFIG_H__
21#define __PJ_CONFIG_H__
22
23
24/**
25 * @file config.h
26 * @brief PJLIB Main configuration settings.
27 */
28
29/********************************************************************
30 * Include compiler specific configuration.
31 */
32#if defined(_MSC_VER)
33# include <pj/compat/cc_msvc.h>
34#elif defined(__GNUC__)
35# include <pj/compat/cc_gcc.h>
36#elif defined(__CW32__)
37# include <pj/compat/cc_mwcc.h>
38#elif defined(__MWERKS__)
39# include <pj/compat/cc_codew.h>
40#elif defined(__GCCE__)
41# include <pj/compat/cc_gcce.h>
42#elif defined(__ARMCC__)
43# include <pj/compat/cc_armcc.h>
44#else
45# error "Unknown compiler."
46#endif
47
48/* PJ_ALIGN_DATA is compiler specific directive to align data address */
49#ifndef PJ_ALIGN_DATA
50# error "PJ_ALIGN_DATA is not defined!"
51#endif
52
53/********************************************************************
54 * Include target OS specific configuration.
55 */
56#if defined(PJ_AUTOCONF)
57 /*
58 * Autoconf
59 */
60# include <pj/compat/os_auto.h>
61
62#elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
63 /*
64 * SymbianOS
65 */
66# include <pj/compat/os_symbian.h>
67
68#elif defined(PJ_WIN32_WINCE) || defined(_WIN32_WCE) || defined(UNDER_CE)
69 /*
70 * Windows CE
71 */
72# undef PJ_WIN32_WINCE
73# define PJ_WIN32_WINCE 1
74# include <pj/compat/os_win32_wince.h>
75
76 /* Also define Win32 */
77# define PJ_WIN32 1
78
79#elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \
80 defined(WIN32) || defined(PJ_WIN64) || defined(_WIN64) || \
81 defined(WIN64) || defined(__TOS_WIN__)
82# if defined(PJ_WIN64) || defined(_WIN64) || defined(WIN64)
83 /*
84 * Win64
85 */
86# undef PJ_WIN64
87# define PJ_WIN64 1
88# endif
89# undef PJ_WIN32
90# define PJ_WIN32 1
91# include <pj/compat/os_win32.h>
92
93#elif defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL!=0
94 /*
95 * Linux kernel
96 */
97# include <pj/compat/os_linux_kernel.h>
98
99#elif defined(PJ_LINUX) || defined(linux) || defined(__linux)
100 /*
101 * Linux
102 */
103# undef PJ_LINUX
104# define PJ_LINUX 1
105# include <pj/compat/os_linux.h>
106
107#elif defined(PJ_PALMOS) && PJ_PALMOS!=0
108 /*
109 * Palm
110 */
111# include <pj/compat/os_palmos.h>
112
113#elif defined(PJ_SUNOS) || defined(sun) || defined(__sun)
114 /*
115 * SunOS
116 */
117# undef PJ_SUNOS
118# define PJ_SUNOS 1
119# include <pj/compat/os_sunos.h>
120
121#elif defined(PJ_DARWINOS) || defined(__MACOSX__) || \
122 defined (__APPLE__) || defined (__MACH__)
123 /*
124 * MacOS X
125 */
126# undef PJ_DARWINOS
127# define PJ_DARWINOS 1
128# include <pj/compat/os_darwinos.h>
129
130#elif defined(PJ_RTEMS) && PJ_RTEMS!=0
131 /*
132 * RTEMS
133 */
134# include <pj/compat/os_rtems.h>
135#else
136# error "Please specify target os."
137#endif
138
139
140/********************************************************************
141 * Target machine specific configuration.
142 */
143#if defined(PJ_AUTOCONF)
144 /*
145 * Autoconf configured
146 */
147#include <pj/compat/m_auto.h>
148
149#elif defined (PJ_M_I386) || defined(_i386_) || defined(i_386_) || \
150 defined(_X86_) || defined(x86) || defined(__i386__) || \
151 defined(__i386) || defined(_M_IX86) || defined(__I86__)
152 /*
153 * Generic i386 processor family, little-endian
154 */
155# undef PJ_M_I386
156# define PJ_M_I386 1
157# define PJ_M_NAME "i386"
158# define PJ_HAS_PENTIUM 1
159# define PJ_IS_LITTLE_ENDIAN 1
160# define PJ_IS_BIG_ENDIAN 0
161
162
163#elif defined (PJ_M_X86_64) || defined(__amd64__) || defined(__amd64) || \
164 defined(__x86_64__) || defined(__x86_64)
165 /*
166 * AMD 64bit processor, little endian
167 */
168# undef PJ_M_X86_64
169# define PJ_M_X86_64 1
170# define PJ_M_NAME "x86_64"
171# define PJ_HAS_PENTIUM 1
172# define PJ_IS_LITTLE_ENDIAN 1
173# define PJ_IS_BIG_ENDIAN 0
174
175#elif defined(PJ_M_IA64) || defined(__ia64__) || defined(_IA64) || \
176 defined(__IA64__) || defined( _M_IA64)
177 /*
178 * Intel IA64 processor, default to little endian
179 */
180# undef PJ_M_IA64
181# define PJ_M_IA64 1
182# define PJ_M_NAME "ia64"
183# define PJ_HAS_PENTIUM 1
184# define PJ_IS_LITTLE_ENDIAN 1
185# define PJ_IS_BIG_ENDIAN 0
186
187#elif defined (PJ_M_M68K) && PJ_M_M68K != 0
188
189 /*
190 * Motorola m68k processor, big endian
191 */
192# undef PJ_M_M68K
193# define PJ_M_M68K 1
194# define PJ_M_NAME "m68k"
195# define PJ_HAS_PENTIUM 0
196# define PJ_IS_LITTLE_ENDIAN 0
197# define PJ_IS_BIG_ENDIAN 1
198
199
200#elif defined (PJ_M_ALPHA) || defined (__alpha__) || defined (__alpha) || \
201 defined (_M_ALPHA)
202 /*
203 * DEC Alpha processor, little endian
204 */
205# undef PJ_M_ALPHA
206# define PJ_M_ALPHA 1
207# define PJ_M_NAME "alpha"
208# define PJ_HAS_PENTIUM 0
209# define PJ_IS_LITTLE_ENDIAN 1
210# define PJ_IS_BIG_ENDIAN 0
211
212
213#elif defined(PJ_M_MIPS) || defined(__mips__) || defined(__mips) || \
214 defined(__MIPS__) || defined(MIPS) || defined(_MIPS_)
215 /*
216 * MIPS, bi-endian, so raise error if endianness is not configured
217 */
218# undef PJ_M_MIPS
219# define PJ_M_MIPS 1
220# define PJ_M_NAME "mips"
221# define PJ_HAS_PENTIUM 0
222# if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
223# error Endianness must be declared for this processor
224# endif
225
226
227#elif defined (PJ_M_SPARC) || defined( __sparc__) || defined(__sparc)
228 /*
229 * Sun Sparc, big endian
230 */
231# undef PJ_M_SPARC
232# define PJ_M_SPARC 1
233# define PJ_M_NAME "sparc"
234# define PJ_HAS_PENTIUM 0
235# define PJ_IS_LITTLE_ENDIAN 0
236# define PJ_IS_BIG_ENDIAN 1
237
238#elif defined (PJ_M_ARMV4) || defined(ARM) || defined(_ARM_) || \
239 defined(ARMV4) || defined(__arm__)
240 /*
241 * ARM, bi-endian, so raise error if endianness is not configured
242 */
243# undef PJ_M_ARMV4
244# define PJ_M_ARMV4 1
245# define PJ_M_NAME "armv4"
246# define PJ_HAS_PENTIUM 0
247# if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
248# error Endianness must be declared for this processor
249# endif
250
251#elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \
252 defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \
253 defined(_ARCH_PPC)
254 /*
255 * PowerPC, bi-endian, so raise error if endianness is not configured
256 */
257# undef PJ_M_POWERPC
258# define PJ_M_POWERPC 1
259# define PJ_M_NAME "powerpc"
260# define PJ_HAS_PENTIUM 0
261# if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
262# error Endianness must be declared for this processor
263# endif
264
265#elif defined (PJ_M_NIOS2) || defined(__nios2) || defined(__nios2__) || \
266 defined(__NIOS2__) || defined(__M_NIOS2) || defined(_ARCH_NIOS2)
267 /*
268 * Nios2, little endian
269 */
270# undef PJ_M_NIOS2
271# define PJ_M_NIOS2 1
272# define PJ_M_NAME "nios2"
273# define PJ_HAS_PENTIUM 0
274# define PJ_IS_LITTLE_ENDIAN 1
275# define PJ_IS_BIG_ENDIAN 0
276
277#else
278# error "Please specify target machine."
279#endif
280
281/* Include size_t definition. */
282#include <pj/compat/size_t.h>
283
284/* Include site/user specific configuration to control PJLIB features.
285 * YOU MUST CREATE THIS FILE YOURSELF!!
286 */
287#include <pj/config_site.h>
288
289/********************************************************************
290 * PJLIB Features.
291 */
292
293/* Overrides for DOXYGEN */
294#ifdef DOXYGEN
295# undef PJ_FUNCTIONS_ARE_INLINED
296# undef PJ_HAS_FLOATING_POINT
297# undef PJ_LOG_MAX_LEVEL
298# undef PJ_LOG_MAX_SIZE
299# undef PJ_LOG_USE_STACK_BUFFER
300# undef PJ_TERM_HAS_COLOR
301# undef PJ_POOL_DEBUG
302# undef PJ_HAS_TCP
303# undef PJ_MAX_HOSTNAME
304# undef PJ_IOQUEUE_MAX_HANDLES
305# undef FD_SETSIZE
306# undef PJ_HAS_SEMAPHORE
307# undef PJ_HAS_EVENT_OBJ
308# undef PJ_ENABLE_EXTRA_CHECK
309# undef PJ_EXCEPTION_USE_WIN32_SEH
310# undef PJ_HAS_ERROR_STRING
311
312# define PJ_HAS_IPV6 1
313#endif
314
315/**
316 * @defgroup pj_config Build Configuration
317 * @{
318 *
319 * This section contains macros that can set during PJLIB build process
320 * to controll various aspects of the library.
321 *
322 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
323 * macro values during the build process.
324 */
325
326/**
327 * If this macro is set to 1, it will enable some debugging checking
328 * in the library.
329 *
330 * Default: equal to (NOT NDEBUG).
331 */
332#ifndef PJ_DEBUG
333# ifndef NDEBUG
334# define PJ_DEBUG 1
335# else
336# define PJ_DEBUG 0
337# endif
338#endif
339
340/**
341 * Enable this macro to activate logging to mutex/semaphore related events.
342 * This is useful to troubleshoot concurrency problems such as deadlocks.
343 * In addition, you should also add PJ_LOG_HAS_THREAD_ID flag to the
344 * log decoration to assist the troubleshooting.
345 *
346 * Default: 0
347 */
348#ifndef PJ_DEBUG_MUTEX
349# define PJ_DEBUG_MUTEX 0
350#endif
351
352/**
353 * Expand functions in *_i.h header files as inline.
354 *
355 * Default: 0.
356 */
357#ifndef PJ_FUNCTIONS_ARE_INLINED
358# define PJ_FUNCTIONS_ARE_INLINED 0
359#endif
360
361/**
362 * Use floating point computations in the library.
363 *
364 * Default: 1.
365 */
366#ifndef PJ_HAS_FLOATING_POINT
367# define PJ_HAS_FLOATING_POINT 1
368#endif
369
370/**
371 * Declare maximum logging level/verbosity. Lower number indicates higher
372 * importance, with the highest importance has level zero. The least
373 * important level is five in this implementation, but this can be extended
374 * by supplying the appropriate implementation.
375 *
376 * The level conventions:
377 * - 0: fatal error
378 * - 1: error
379 * - 2: warning
380 * - 3: info
381 * - 4: debug
382 * - 5: trace
383 * - 6: more detailed trace
384 *
385 * Default: 4
386 */
387#ifndef PJ_LOG_MAX_LEVEL
388# define PJ_LOG_MAX_LEVEL 5
389#endif
390
391/**
392 * Maximum message size that can be sent to output device for each call
393 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
394 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
395 * flag is set.
396 *
397 * Default: 4000
398 */
399#ifndef PJ_LOG_MAX_SIZE
400# define PJ_LOG_MAX_SIZE 4000
401#endif
402
403/**
404 * Log buffer.
405 * Does the log get the buffer from the stack? (default is yes).
406 * If the value is set to NO, then the buffer will be taken from static
407 * buffer, which in this case will make the log function non-reentrant.
408 *
409 * Default: 1
410 */
411#ifndef PJ_LOG_USE_STACK_BUFFER
412# define PJ_LOG_USE_STACK_BUFFER 1
413#endif
414
415/**
416 * Enable log indentation feature.
417 *
418 * Default: 1
419 */
420#ifndef PJ_LOG_ENABLE_INDENT
421# define PJ_LOG_ENABLE_INDENT 1
422#endif
423
424/**
425 * Number of PJ_LOG_INDENT_CHAR to put every time pj_log_push_indent()
426 * is called.
427 *
428 * Default: 1
429 */
430#ifndef PJ_LOG_INDENT_SIZE
431# define PJ_LOG_INDENT_SIZE 1
432#endif
433
434/**
435 * Log indentation character.
436 *
437 * Default: space
438 */
439#ifndef PJ_LOG_INDENT_CHAR
440# define PJ_LOG_INDENT_CHAR '.'
441#endif
442
443/**
444 * Colorfull terminal (for logging etc).
445 *
446 * Default: 1
447 */
448#ifndef PJ_TERM_HAS_COLOR
449# define PJ_TERM_HAS_COLOR 1
450#endif
451
452
453/**
454 * Set this flag to non-zero to enable various checking for pool
455 * operations. When this flag is set, assertion must be enabled
456 * in the application.
457 *
458 * This will slow down pool creation and destruction and will add
459 * few bytes of overhead, so application would normally want to
460 * disable this feature on release build.
461 *
462 * Default: 0
463 */
464#ifndef PJ_SAFE_POOL
465# define PJ_SAFE_POOL 0
466#endif
467
468
469/**
470 * If pool debugging is used, then each memory allocation from the pool
471 * will call malloc(), and pool will release all memory chunks when it
472 * is destroyed. This works better when memory verification programs
473 * such as Rational Purify is used.
474 *
475 * Default: 0
476 */
477#ifndef PJ_POOL_DEBUG
478# define PJ_POOL_DEBUG 0
479#endif
480
481
482/**
483 * Enable timer heap debugging facility. When this is enabled, application
484 * can call pj_timer_heap_dump() to show the contents of the timer heap
485 * along with the source location where the timer entries were scheduled.
486 * See https://trac.pjsip.org/repos/ticket/1527 for more info.
487 *
488 * Default: 0
489 */
490#ifndef PJ_TIMER_DEBUG
491# define PJ_TIMER_DEBUG 0
492#endif
493
494
495/**
496 * Set this to 1 to enable debugging on the group lock. Default: 0
497 */
498#ifndef PJ_GRP_LOCK_DEBUG
499# define PJ_GRP_LOCK_DEBUG 0
500#endif
501
502
503/**
504 * Specify this as \a stack_size argument in #pj_thread_create() to specify
505 * that thread should use default stack size for the current platform.
506 *
507 * Default: 8192
508 */
509#ifndef PJ_THREAD_DEFAULT_STACK_SIZE
510# define PJ_THREAD_DEFAULT_STACK_SIZE 8192
511#endif
512
513
514/**
515 * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of
516 * the stack. The OS implementation may check that no stack overflow
517 * occurs, and it also may collect statistic about stack usage. Note
518 * that this will increase the footprint of the libraries since it
519 * tracks the filename and line number of each functions.
520 */
521#ifndef PJ_OS_HAS_CHECK_STACK
522# define PJ_OS_HAS_CHECK_STACK 0
523#endif
524
525/**
526 * Do we have alternate pool implementation?
527 *
528 * Default: 0
529 */
530#ifndef PJ_HAS_POOL_ALT_API
531# define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
532#endif
533
534
535/**
536 * Support TCP in the library.
537 * Disabling TCP will reduce the footprint slightly (about 6KB).
538 *
539 * Default: 1
540 */
541#ifndef PJ_HAS_TCP
542# define PJ_HAS_TCP 1
543#endif
544
545/**
546 * Support IPv6 in the library. If this support is disabled, some IPv6
547 * related functions will return PJ_EIPV6NOTSUP.
548 *
549 * Default: 0 (disabled, for now)
550 */
551#ifndef PJ_HAS_IPV6
552# define PJ_HAS_IPV6 0
553#endif
554
555 /**
556 * Maximum hostname length.
557 * Libraries sometimes needs to make copy of an address to stack buffer;
558 * the value here affects the stack usage.
559 *
560 * Default: 128
561 */
562#ifndef PJ_MAX_HOSTNAME
563# define PJ_MAX_HOSTNAME (128)
564#endif
565
566/**
567 * Maximum consecutive identical error for accept() operation before
568 * activesock stops calling the next ioqueue accept.
569 *
570 * Default: 50
571 */
572#ifndef PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR
573# define PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR 50
574#endif
575
576/**
577 * Constants for declaring the maximum handles that can be supported by
578 * a single IOQ framework. This constant might not be relevant to the
579 * underlying I/O queue impelementation, but still, developers should be
580 * aware of this constant, to make sure that the program will not break when
581 * the underlying implementation changes.
582 */
583#ifndef PJ_IOQUEUE_MAX_HANDLES
584# define PJ_IOQUEUE_MAX_HANDLES (64)
585#endif
586
587
588/**
589 * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
590 * things to ensure thread safety of handle unregistration operation by
591 * employing reference counter to each handle.
592 *
593 * In addition, the ioqueue will preallocate memory for the handles,
594 * according to the maximum number of handles that is specified during
595 * ioqueue creation.
596 *
597 * All applications would normally want this enabled, but you may disable
598 * this if:
599 * - there is no dynamic unregistration to all ioqueues.
600 * - there is no threading, or there is no preemptive multitasking.
601 *
602 * Default: 1
603 */
604#ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
605# define PJ_IOQUEUE_HAS_SAFE_UNREG 1
606#endif
607
608
609/**
610 * Default concurrency setting for sockets/handles registered to ioqueue.
611 * This controls whether the ioqueue is allowed to call the key's callback
612 * concurrently/in parallel. The default is yes, which means that if there
613 * are more than one pending operations complete simultaneously, more
614 * than one threads may call the key's callback at the same time. This
615 * generally would promote good scalability for application, at the
616 * expense of more complexity to manage the concurrent accesses.
617 *
618 * Please see the ioqueue documentation for more info.
619 */
620#ifndef PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY
621# define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY 1
622#endif
623
624
625/* Sanity check:
626 * if ioqueue concurrency is disallowed, PJ_IOQUEUE_HAS_SAFE_UNREG
627 * must be enabled.
628 */
629#if (PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY==0) && (PJ_IOQUEUE_HAS_SAFE_UNREG==0)
630# error PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if ioqueue concurrency \
631 is disabled
632#endif
633
634
635/**
636 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
637 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
638 * ioqueue key is kept in closing state before it can be reused.
639 *
640 * The value is in miliseconds.
641 *
642 * Default: 500 msec.
643 */
644#ifndef PJ_IOQUEUE_KEY_FREE_DELAY
645# define PJ_IOQUEUE_KEY_FREE_DELAY 500
646#endif
647
648
649/**
650 * Determine if FD_SETSIZE is changeable/set-able. If so, then we will
651 * set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking
652 * for Winsock.
653 */
654#ifndef PJ_FD_SETSIZE_SETABLE
655# if (defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H!=0) || \
656 (defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H!=0)
657# define PJ_FD_SETSIZE_SETABLE 1
658# else
659# define PJ_FD_SETSIZE_SETABLE 0
660# endif
661#endif
662
663/**
664 * Overrides FD_SETSIZE so it is consistent throughout the library.
665 * We only do this if we detected that FD_SETSIZE is changeable. If
666 * FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be
667 * set to value lower than FD_SETSIZE.
668 */
669#if PJ_FD_SETSIZE_SETABLE
670 /* Only override FD_SETSIZE if the value has not been set */
671# ifndef FD_SETSIZE
672# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
673# endif
674#else
675 /* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES
676 * is lower than FD_SETSIZE value.
677 */
678# ifdef FD_SETSIZE
679# if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
680# error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE"
681# endif
682# endif
683#endif
684
685
686/**
687 * Specify whether #pj_enum_ip_interface() function should exclude
688 * loopback interfaces.
689 *
690 * Default: 1
691 */
692#ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
693# define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
694#endif
695
696
697/**
698 * Has semaphore functionality?
699 *
700 * Default: 1
701 */
702#ifndef PJ_HAS_SEMAPHORE
703# define PJ_HAS_SEMAPHORE 1
704#endif
705
706
707/**
708 * Event object (for synchronization, e.g. in Win32)
709 *
710 * Default: 1
711 */
712#ifndef PJ_HAS_EVENT_OBJ
713# define PJ_HAS_EVENT_OBJ 1
714#endif
715
716
717/**
718 * Maximum file name length.
719 */
720#ifndef PJ_MAXPATH
721# define PJ_MAXPATH 260
722#endif
723
724
725/**
726 * Enable library's extra check.
727 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
728 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
729 * will simply evaluate to #pj_assert().
730 *
731 * You can disable this macro to reduce size, at the risk of crashes
732 * if invalid value (e.g. NULL) is passed to the library.
733 *
734 * Default: 1
735 */
736#ifndef PJ_ENABLE_EXTRA_CHECK
737# define PJ_ENABLE_EXTRA_CHECK 1
738#endif
739
740
741/**
742 * Enable name registration for exceptions with #pj_exception_id_alloc().
743 * If this feature is enabled, then the library will keep track of
744 * names associated with each exception ID requested by application via
745 * #pj_exception_id_alloc().
746 *
747 * Disabling this macro will reduce the code and .bss size by a tad bit.
748 * See also #PJ_MAX_EXCEPTION_ID.
749 *
750 * Default: 1
751 */
752#ifndef PJ_HAS_EXCEPTION_NAMES
753# define PJ_HAS_EXCEPTION_NAMES 1
754#endif
755
756/**
757 * Maximum number of unique exception IDs that can be requested
758 * with #pj_exception_id_alloc(). For each entry, a small record will
759 * be allocated in the .bss segment.
760 *
761 * Default: 16
762 */
763#ifndef PJ_MAX_EXCEPTION_ID
764# define PJ_MAX_EXCEPTION_ID 16
765#endif
766
767/**
768 * Should we use Windows Structured Exception Handling (SEH) for the
769 * PJLIB exceptions.
770 *
771 * Default: 0
772 */
773#ifndef PJ_EXCEPTION_USE_WIN32_SEH
774# define PJ_EXCEPTION_USE_WIN32_SEH 0
775#endif
776
777/**
778 * Should we attempt to use Pentium's rdtsc for high resolution
779 * timestamp.
780 *
781 * Default: 0
782 */
783#ifndef PJ_TIMESTAMP_USE_RDTSC
784# define PJ_TIMESTAMP_USE_RDTSC 0
785#endif
786
787/**
788 * Is native platform error positive number?
789 * Default: 1 (yes)
790 */
791#ifndef PJ_NATIVE_ERR_POSITIVE
792# define PJ_NATIVE_ERR_POSITIVE 1
793#endif
794
795/**
796 * Include error message string in the library (pj_strerror()).
797 * This is very much desirable!
798 *
799 * Default: 1
800 */
801#ifndef PJ_HAS_ERROR_STRING
802# define PJ_HAS_ERROR_STRING 1
803#endif
804
805
806/**
807 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
808 * functions to compare alnum strings. On some systems, they're faster
809 * then stricmp/strcasecmp, but they can be slower on other systems.
810 * When disabled, pjlib will fallback to stricmp/strnicmp.
811 *
812 * Default: 0
813 */
814#ifndef PJ_HAS_STRICMP_ALNUM
815# define PJ_HAS_STRICMP_ALNUM 0
816#endif
817
818
819/*
820 * Types of QoS backend implementation.
821 */
822
823/**
824 * Dummy QoS backend implementation, will always return error on all
825 * the APIs.
826 */
827#define PJ_QOS_DUMMY 1
828
829/** QoS backend based on setsockopt(IP_TOS) */
830#define PJ_QOS_BSD 2
831
832/** QoS backend for Windows Mobile 6 */
833#define PJ_QOS_WM 3
834
835/** QoS backend for Symbian */
836#define PJ_QOS_SYMBIAN 4
837
838/**
839 * Force the use of some QoS backend API for some platforms.
840 */
841#ifndef PJ_QOS_IMPLEMENTATION
842# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE && _WIN32_WCE >= 0x502
843 /* Windows Mobile 6 or later */
844# define PJ_QOS_IMPLEMENTATION PJ_QOS_WM
845# endif
846#endif
847
848
849/**
850 * Enable secure socket. For most platforms, this is implemented using
851 * OpenSSL, so this will require OpenSSL to be installed. For Symbian
852 * platform, this is implemented natively using CSecureSocket.
853 *
854 * Default: 0 (for now)
855 */
856#ifndef PJ_HAS_SSL_SOCK
857# define PJ_HAS_SSL_SOCK 0
858#endif
859
860
861/**
862 * Disable WSAECONNRESET error for UDP sockets on Win32 platforms. See
863 * https://trac.pjsip.org/repos/ticket/1197.
864 *
865 * Default: 1
866 */
867#ifndef PJ_SOCK_DISABLE_WSAECONNRESET
868# define PJ_SOCK_DISABLE_WSAECONNRESET 1
869#endif
870
871
872/** @} */
873
874/********************************************************************
875 * General macros.
876 */
877
878/**
879 * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO)
880 * @ingroup pj_config
881 * @{
882 *
883 * The libraries support generation of dynamic link libraries for
884 * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian
885 * terms). Similar procedures may be applied for Win32 DLL with some
886 * modification.
887 *
888 * Depending on the platforms, these steps may be necessary in order to
889 * produce the dynamic libraries:
890 * - Create the (Visual Studio) projects to produce DLL output. PJLIB
891 * does not provide ready to use project files to produce DLL, so
892 * you need to create these projects yourself. For Symbian, the MMP
893 * files have been setup to produce DSO files for targets that
894 * require them.
895 * - In the (Visual Studio) projects, some macros need to be declared
896 * so that appropriate modifiers are added to symbol declarations
897 * and definitions. Please see the macro section below for information
898 * regarding these macros. For Symbian, these have been taken care by the
899 * MMP files.
900 * - Some build systems require .DEF file to be specified when creating
901 * the DLL. For Symbian, .DEF files are included in pjlib distribution,
902 * in <tt>pjlib/build.symbian</tt> directory. These DEF files are
903 * created by running <tt>./makedef.sh all</tt> from this directory,
904 * inside Mingw.
905 *
906 * Macros related for building DLL/DSO files:
907 * - For platforms that supports dynamic link libraries generation,
908 * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains
909 * the prefix to be added to symbol definition, to export this
910 * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
911 * value of this macro is \a __declspec(dllexport), and for ARM
912 * ABIv2/Symbian, the value is \a EXPORT_C.
913 * - For platforms that supports linking with dynamic link libraries,
914 * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains
915 * the prefix to be added to symbol declaration, to import this
916 * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
917 * value of this macro is \a __declspec(dllimport), and for ARM
918 * ABIv2/Symbian, the value is \a IMPORT_C.
919 * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt>
920 * macros above can be declared in your \a config_site.h if they are not
921 * declared by pjlib.
922 * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and
923 * <tt>PJ_EXPORTING</tt> macros must be declared, so that
924 * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function
925 * definition.
926 * - When application wants to link dynamically with PJLIB, then it
927 * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header,
928 * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into
929 * symbol declarations.
930 *
931 * When <b>PJ_DLL</b> macro is not declared, static linking is assumed.
932 *
933 * For example, here are some settings to produce DLLs with Visual Studio
934 * on Windows/Win32:
935 * - Create Visual Studio projects to produce DLL. Add the appropriate
936 * project dependencies to avoid link errors.
937 * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt>
938 * macros.
939 * - Declare these macros in your <tt>config_site.h</tt>:
940 \verbatim
941 #define PJ_EXPORT_SPECIFIER __declspec(dllexport)
942 #define PJ_IMPORT_SPECIFIER __declspec(dllimport)
943 \endverbatim
944 * - And in the application (that links with the DLL) project, add
945 * <tt>PJ_DLL</tt> in the macro declarations.
946 */
947
948/** @} */
949
950/**
951 * @defgroup pj_config Build Configuration
952 * @{
953 */
954
955/**
956 * @def PJ_INLINE(type)
957 * @param type The return type of the function.
958 * Expand the function as inline.
959 */
960#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
961
962/**
963 * This macro declares platform/compiler specific specifier prefix
964 * to be added to symbol declaration to export the symbol when PJLIB
965 * is built as dynamic library.
966 *
967 * This macro should have been added by platform specific headers,
968 * if the platform supports building dynamic library target.
969 */
970#ifndef PJ_EXPORT_DECL_SPECIFIER
971# define PJ_EXPORT_DECL_SPECIFIER
972#endif
973
974
975/**
976 * This macro declares platform/compiler specific specifier prefix
977 * to be added to symbol definition to export the symbol when PJLIB
978 * is built as dynamic library.
979 *
980 * This macro should have been added by platform specific headers,
981 * if the platform supports building dynamic library target.
982 */
983#ifndef PJ_EXPORT_DEF_SPECIFIER
984# define PJ_EXPORT_DEF_SPECIFIER
985#endif
986
987
988/**
989 * This macro declares platform/compiler specific specifier prefix
990 * to be added to symbol declaration to import the symbol.
991 *
992 * This macro should have been added by platform specific headers,
993 * if the platform supports building dynamic library target.
994 */
995#ifndef PJ_IMPORT_DECL_SPECIFIER
996# define PJ_IMPORT_DECL_SPECIFIER
997#endif
998
999
1000/**
1001 * This macro has been deprecated. It will evaluate to nothing.
1002 */
1003#ifndef PJ_EXPORT_SYMBOL
1004# define PJ_EXPORT_SYMBOL(x)
1005#endif
1006
1007
1008/**
1009 * @def PJ_DECL(type)
1010 * @param type The return type of the function.
1011 * Declare a function.
1012 */
1013#if defined(PJ_DLL)
1014# if defined(PJ_EXPORTING)
1015# define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
1016# else
1017# define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
1018# endif
1019#elif !defined(PJ_DECL)
1020# if defined(__cplusplus)
1021# define PJ_DECL(type) type
1022# else
1023# define PJ_DECL(type) extern type
1024# endif
1025#endif
1026
1027
1028/**
1029 * @def PJ_DEF(type)
1030 * @param type The return type of the function.
1031 * Define a function.
1032 */
1033#if defined(PJ_DLL) && defined(PJ_EXPORTING)
1034# define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
1035#elif !defined(PJ_DEF)
1036# define PJ_DEF(type) type
1037#endif
1038
1039
1040/**
1041 * @def PJ_DECL_NO_RETURN(type)
1042 * @param type The return type of the function.
1043 * Declare a function that will not return.
1044 */
1045/**
1046 * @def PJ_IDECL_NO_RETURN(type)
1047 * @param type The return type of the function.
1048 * Declare an inline function that will not return.
1049 */
1050/**
1051 * @def PJ_BEGIN_DECL
1052 * Mark beginning of declaration section in a header file.
1053 */
1054/**
1055 * @def PJ_END_DECL
1056 * Mark end of declaration section in a header file.
1057 */
1058#ifdef __cplusplus
1059# define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
1060# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
1061# define PJ_BEGIN_DECL extern "C" {
1062# define PJ_END_DECL }
1063#else
1064# define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
1065# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
1066# define PJ_BEGIN_DECL
1067# define PJ_END_DECL
1068#endif
1069
1070
1071
1072/**
1073 * @def PJ_DECL_DATA(type)
1074 * @param type The data type.
1075 * Declare a global data.
1076 */
1077#if defined(PJ_DLL)
1078# if defined(PJ_EXPORTING)
1079# define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
1080# else
1081# define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
1082# endif
1083#elif !defined(PJ_DECL_DATA)
1084# define PJ_DECL_DATA(type) extern type
1085#endif
1086
1087
1088/**
1089 * @def PJ_DEF_DATA(type)
1090 * @param type The data type.
1091 * Define a global data.
1092 */
1093#if defined(PJ_DLL) && defined(PJ_EXPORTING)
1094# define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
1095#elif !defined(PJ_DEF_DATA)
1096# define PJ_DEF_DATA(type) type
1097#endif
1098
1099
1100/**
1101 * @def PJ_IDECL(type)
1102 * @param type The function's return type.
1103 * Declare a function that may be expanded as inline.
1104 */
1105/**
1106 * @def PJ_IDEF(type)
1107 * @param type The function's return type.
1108 * Define a function that may be expanded as inline.
1109 */
1110
1111#if PJ_FUNCTIONS_ARE_INLINED
1112# define PJ_IDECL(type) PJ_INLINE(type)
1113# define PJ_IDEF(type) PJ_INLINE(type)
1114#else
1115# define PJ_IDECL(type) PJ_DECL(type)
1116# define PJ_IDEF(type) PJ_DEF(type)
1117#endif
1118
1119
1120/**
1121 * @def PJ_UNUSED_ARG(arg)
1122 * @param arg The argument name.
1123 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
1124 */
1125#define PJ_UNUSED_ARG(arg) (void)arg
1126
1127/**
1128 * @def PJ_TODO(id)
1129 * @param id Any identifier that will be printed as TODO message.
1130 * PJ_TODO macro will display TODO message as warning during compilation.
1131 * Example: PJ_TODO(CLEAN_UP_ERROR);
1132 */
1133#ifndef PJ_TODO
1134# define PJ_TODO(id) TODO___##id:
1135#endif
1136
1137/**
1138 * Simulate race condition by sleeping the thread in strategic locations.
1139 * Default: no!
1140 */
1141#ifndef PJ_RACE_ME
1142# define PJ_RACE_ME(x)
1143#endif
1144
1145/**
1146 * Function attributes to inform that the function may throw exception.
1147 *
1148 * @param x The exception list, enclosed in parenthesis.
1149 */
1150#define __pj_throw__(x)
1151
1152/** @} */
1153
1154/********************************************************************
1155 * Sanity Checks
1156 */
1157#ifndef PJ_HAS_HIGH_RES_TIMER
1158# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
1159#endif
1160
1161#if !defined(PJ_HAS_PENTIUM)
1162# error "PJ_HAS_PENTIUM is not defined!"
1163#endif
1164
1165#if !defined(PJ_IS_LITTLE_ENDIAN)
1166# error "PJ_IS_LITTLE_ENDIAN is not defined!"
1167#endif
1168
1169#if !defined(PJ_IS_BIG_ENDIAN)
1170# error "PJ_IS_BIG_ENDIAN is not defined!"
1171#endif
1172
1173#if !defined(PJ_EMULATE_RWMUTEX)
1174# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
1175#endif
1176
1177#if !defined(PJ_THREAD_SET_STACK_SIZE)
1178# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
1179#endif
1180
1181#if !defined(PJ_THREAD_ALLOCATE_STACK)
1182# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
1183#endif
1184
1185PJ_BEGIN_DECL
1186
1187/** PJLIB version major number. */
1188#define PJ_VERSION_NUM_MAJOR 2
1189
1190/** PJLIB version minor number. */
1191#define PJ_VERSION_NUM_MINOR 1
1192
1193/** PJLIB version revision number. */
1194#define PJ_VERSION_NUM_REV 0
1195
1196/**
1197 * Extra suffix for the version (e.g. "-trunk"), or empty for
1198 * web release version.
1199 */
1200#define PJ_VERSION_NUM_EXTRA "-svn"
1201
1202/**
1203 * PJLIB version number consists of three bytes with the following format:
1204 * 0xMMIIRR00, where MM: major number, II: minor number, RR: revision
1205 * number, 00: always zero for now.
1206 */
1207#define PJ_VERSION_NUM ((PJ_VERSION_NUM_MAJOR << 24) | \
1208 (PJ_VERSION_NUM_MINOR << 16) | \
1209 (PJ_VERSION_NUM_REV << 8))
1210
1211/**
1212 * PJLIB version string constant. @see pj_get_version()
1213 */
1214PJ_DECL_DATA(const char*) PJ_VERSION;
1215
1216/**
1217 * Get PJLIB version string.
1218 *
1219 * @return #PJ_VERSION constant.
1220 */
1221PJ_DECL(const char*) pj_get_version(void);
1222
1223/**
1224 * Dump configuration to log with verbosity equal to info(3).
1225 */
1226PJ_DECL(void) pj_dump_config(void);
1227
1228PJ_END_DECL
1229
1230
1231#endif /* __PJ_CONFIG_H__ */
1232