blob: b1ef3ab93fd7071ec19d2353b5887a3a7e13de6a [file] [log] [blame]
Benny Prijono9033e312005-11-21 02:08:39 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono9033e312005-11-21 02:08:39 +00005 *
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 * @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(__GNUC__)
34# include <pj/compat/cc_gcc.h>
Benny Prijonof260e462007-04-30 21:03:32 +000035#elif defined(__CW32__)
36# include <pj/compat/cc_mwcc.h>
37#elif defined(__MWERKS__)
38# include <pj/compat/cc_codew.h>
Benny Prijonob2c96822007-05-03 13:31:21 +000039#elif defined(__GCCE__)
40# include <pj/compat/cc_gcce.h>
41#elif defined(__ARMCC__)
42# include <pj/compat/cc_armcc.h>
Benny Prijono9033e312005-11-21 02:08:39 +000043#else
44# error "Unknown compiler."
45#endif
46
47
48/********************************************************************
49 * Include target OS specific configuration.
50 */
Benny Prijonoc4c61d02006-08-20 20:47:34 +000051#if defined(PJ_AUTOCONF)
52 /*
53 * Autoconf
54 */
55# include <pj/compat/os_auto.h>
56
Benny Prijonof260e462007-04-30 21:03:32 +000057#elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
58 /*
59 * SymbianOS
60 */
61# include <pj/compat/os_symbian.h>
62
Benny Prijonoc4c61d02006-08-20 20:47:34 +000063#elif defined(PJ_WIN32_WINCE) || defined(_WIN32_WCE) || defined(UNDER_CE)
Benny Prijonoc4c8f242006-08-01 23:01:55 +000064 /*
65 * Windows CE
66 */
67# undef PJ_WIN32_WINCE
68# define PJ_WIN32_WINCE 1
69# include <pj/compat/os_win32_wince.h>
70
71 /* Also define Win32 */
72# define PJ_WIN32 1
73
74#elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \
75 defined(_WIN64) || defined(WIN32) || defined(__TOS_WIN__)
76 /*
77 * Win32
78 */
79# undef PJ_WIN32
80# define PJ_WIN32 1
81# include <pj/compat/os_win32.h>
82
Benny Prijono9033e312005-11-21 02:08:39 +000083#elif defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +000084 /*
85 * Linux kernel
86 */
Benny Prijono9033e312005-11-21 02:08:39 +000087# include <pj/compat/os_linux_kernel.h>
Benny Prijonoc4c8f242006-08-01 23:01:55 +000088
89#elif defined(PJ_LINUX) || defined(linux) || defined(__linux)
90 /*
91 * Linux
92 */
93# undef PJ_LINUX
94# define PJ_LINUX 1
95# include <pj/compat/os_linux.h>
96
Benny Prijono9033e312005-11-21 02:08:39 +000097#elif defined(PJ_PALMOS) && PJ_PALMOS!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +000098 /*
99 * Palm
100 */
Benny Prijono9033e312005-11-21 02:08:39 +0000101# include <pj/compat/os_palmos.h>
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000102
103#elif defined(PJ_SUNOS) || defined(sun) || defined(__sun)
104 /*
105 * SunOS
106 */
107# undef PJ_SUNOS
108# define PJ_SUNOS 1
109# include <pj/compat/os_sunos.h>
110
Benny Prijono5b2b4452009-01-22 20:30:32 +0000111#elif defined(PJ_DARWINOS) || defined(__MACOSX__) || \
112 defined (__APPLE__) || defined (__MACH__)
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000113 /*
114 * MacOS X
115 */
116# undef PJ_DARWINOS
117# define PJ_DARWINOS 1
118# include <pj/compat/os_darwinos.h>
119
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000120#elif defined(PJ_RTEMS) && PJ_RTEMS!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000121 /*
122 * RTEMS
123 */
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000124# include <pj/compat/os_rtems.h>
Benny Prijono9033e312005-11-21 02:08:39 +0000125#else
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000126# error "Please specify target os."
Benny Prijono9033e312005-11-21 02:08:39 +0000127#endif
128
129
130/********************************************************************
131 * Target machine specific configuration.
132 */
Benny Prijonoc4c61d02006-08-20 20:47:34 +0000133#if defined(PJ_AUTOCONF)
134 /*
135 * Autoconf configured
136 */
137#include <pj/compat/m_auto.h>
138
139#elif defined (PJ_M_I386) || defined(_i386_) || defined(i_386_) || \
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000140 defined(_X86_) || defined(x86) || defined(__i386__) || \
141 defined(__i386) || defined(_M_IX86) || defined(__I86__)
142 /*
143 * Generic i386 processor family, little-endian
144 */
145# undef PJ_M_I386
146# define PJ_M_I386 1
147# define PJ_M_NAME "i386"
148# define PJ_HAS_PENTIUM 1
149# define PJ_IS_LITTLE_ENDIAN 1
150# define PJ_IS_BIG_ENDIAN 0
151
152
153#elif defined (PJ_M_X86_64) || defined(__amd64__) || defined(__amd64) || \
154 defined(__x86_64__) || defined(__x86_64)
155 /*
156 * AMD 64bit processor, little endian
157 */
158# undef PJ_M_X86_64
159# define PJ_M_X86_64 1
160# define PJ_M_NAME "x86_64"
161# define PJ_HAS_PENTIUM 1
162# define PJ_IS_LITTLE_ENDIAN 1
163# define PJ_IS_BIG_ENDIAN 0
164
165#elif defined(PJ_M_IA64) || defined(__ia64__) || defined(_IA64) || \
166 defined(__IA64__) || defined( _M_IA64)
167 /*
168 * Intel IA64 processor, little endian
169 */
170# undef PJ_M_IA64
171# define PJ_M_IA64 1
172# define PJ_M_NAME "ia64"
173# define PJ_HAS_PENTIUM 1
174# define PJ_IS_LITTLE_ENDIAN 1
175# define PJ_IS_BIG_ENDIAN 0
176
Benny Prijono9033e312005-11-21 02:08:39 +0000177#elif defined (PJ_M_M68K) && PJ_M_M68K != 0
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000178
179 /*
Benny Prijono16b20532010-01-20 19:42:46 +0000180 * Motorola m68k processor, big endian
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000181 */
182# undef PJ_M_M68K
183# define PJ_M_M68K 1
184# define PJ_M_NAME "m68k"
185# define PJ_HAS_PENTIUM 0
Benny Prijono16b20532010-01-20 19:42:46 +0000186# define PJ_IS_LITTLE_ENDIAN 0
187# define PJ_IS_BIG_ENDIAN 1
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000188
189
190#elif defined (PJ_M_ALPHA) || defined (__alpha__) || defined (__alpha) || \
191 defined (_M_ALPHA)
192 /*
193 * DEC Alpha processor, little endian
194 */
195# undef PJ_M_ALPHA
196# define PJ_M_ALPHA 1
197# define PJ_M_NAME "alpha"
198# define PJ_HAS_PENTIUM 0
199# define PJ_IS_LITTLE_ENDIAN 1
200# define PJ_IS_BIG_ENDIAN 0
201
202
Benny Prijonod79f25c2006-08-02 19:41:37 +0000203#elif defined(PJ_M_MIPS) || defined(__mips__) || defined(__mips) || \
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000204 defined(__MIPS__) || defined(MIPS) || defined(_MIPS_)
205 /*
Benny Prijonod79f25c2006-08-02 19:41:37 +0000206 * MIPS, default to little endian
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000207 */
208# undef PJ_M_MIPS
209# define PJ_M_MIPS 1
210# define PJ_M_NAME "mips"
211# define PJ_HAS_PENTIUM 0
Benny Prijonod79f25c2006-08-02 19:41:37 +0000212# if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN)
213# define PJ_IS_LITTLE_ENDIAN 1
214# define PJ_IS_BIG_ENDIAN 0
215# endif
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000216
217
218#elif defined (PJ_M_SPARC) || defined( __sparc__) || defined(__sparc)
219 /*
220 * Sun Sparc, big endian
221 */
222# undef PJ_M_SPARC
223# define PJ_M_SPARC 1
224# define PJ_M_NAME "sparc"
225# define PJ_HAS_PENTIUM 0
226# define PJ_IS_LITTLE_ENDIAN 0
227# define PJ_IS_BIG_ENDIAN 1
228
229#elif defined (PJ_M_ARMV4) || defined(ARM) || defined(_ARM_) || \
230 defined(ARMV4) || defined(__arm__)
231 /*
Benny Prijono8f9faae2006-08-04 17:18:37 +0000232 * ARM, default to little endian
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000233 */
234# undef PJ_M_ARMV4
235# define PJ_M_ARMV4 1
236# define PJ_M_NAME "armv4"
237# define PJ_HAS_PENTIUM 0
238# if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN)
239# define PJ_IS_LITTLE_ENDIAN 1
240# define PJ_IS_BIG_ENDIAN 0
241# endif
242
243#elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \
244 defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \
245 defined(_ARCH_PPC)
246 /*
247 * PowerPC, big endian
248 */
249# undef PJ_M_POWERPC
250# define PJ_M_POWERPC 1
251# define PJ_M_NAME "powerpc"
252# define PJ_HAS_PENTIUM 0
Benny Prijonod79f25c2006-08-02 19:41:37 +0000253# define PJ_IS_LITTLE_ENDIAN 0
254# define PJ_IS_BIG_ENDIAN 1
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000255
Benny Prijono93713fb2008-05-07 13:28:06 +0000256#elif defined (PJ_M_NIOS2) || defined(__nios2) || defined(__nios2__) || \
257 defined(__NIOS2__) || defined(__M_NIOS2) || defined(_ARCH_NIOS2)
258 /*
259 * Nios2, little endian
260 */
261# undef PJ_M_NIOS2
262# define PJ_M_NIOS2 1
263# define PJ_M_NAME "nios2"
264# define PJ_HAS_PENTIUM 0
265# define PJ_IS_LITTLE_ENDIAN 1
266# define PJ_IS_BIG_ENDIAN 0
267
Benny Prijono9033e312005-11-21 02:08:39 +0000268#else
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000269# error "Please specify target machine."
Benny Prijono9033e312005-11-21 02:08:39 +0000270#endif
271
272/* Include size_t definition. */
273#include <pj/compat/size_t.h>
274
275/* Include site/user specific configuration to control PJLIB features.
276 * YOU MUST CREATE THIS FILE YOURSELF!!
277 */
278#include <pj/config_site.h>
279
280/********************************************************************
281 * PJLIB Features.
282 */
283
284/* Overrides for DOXYGEN */
285#ifdef DOXYGEN
286# undef PJ_FUNCTIONS_ARE_INLINED
287# undef PJ_HAS_FLOATING_POINT
288# undef PJ_LOG_MAX_LEVEL
289# undef PJ_LOG_MAX_SIZE
290# undef PJ_LOG_USE_STACK_BUFFER
291# undef PJ_TERM_HAS_COLOR
292# undef PJ_POOL_DEBUG
293# undef PJ_HAS_TCP
294# undef PJ_MAX_HOSTNAME
295# undef PJ_IOQUEUE_MAX_HANDLES
296# undef FD_SETSIZE
297# undef PJ_HAS_SEMAPHORE
298# undef PJ_HAS_EVENT_OBJ
299# undef PJ_ENABLE_EXTRA_CHECK
Benny Prijono99683ae2005-11-21 16:59:47 +0000300# undef PJ_EXCEPTION_USE_WIN32_SEH
Benny Prijono11852992006-03-18 12:28:03 +0000301# undef PJ_HAS_ERROR_STRING
Benny Prijonoe3f79fd2008-02-13 15:17:28 +0000302
303# define PJ_HAS_IPV6 1
Benny Prijono9033e312005-11-21 02:08:39 +0000304#endif
305
306/**
307 * @defgroup pj_config Build Configuration
Benny Prijono9033e312005-11-21 02:08:39 +0000308 * @{
309 *
310 * This section contains macros that can set during PJLIB build process
311 * to controll various aspects of the library.
312 *
313 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
314 * macro values during the build process.
315 */
316
317/**
318 * If this macro is set to 1, it will enable some debugging checking
319 * in the library.
320 *
321 * Default: equal to (NOT NDEBUG).
322 */
323#ifndef PJ_DEBUG
324# ifndef NDEBUG
325# define PJ_DEBUG 1
326# else
327# define PJ_DEBUG 0
328# endif
329#endif
330
331/**
Benny Prijonobe6d5db2009-07-22 11:12:35 +0000332 * Enable this macro to activate logging to mutex/semaphore related events.
333 * This is useful to troubleshoot concurrency problems such as deadlocks.
334 * In addition, you should also add PJ_LOG_HAS_THREAD_ID flag to the
335 * log decoration to assist the troubleshooting.
336 *
337 * Default: 0
338 */
339#ifndef PJ_DEBUG_MUTEX
340# define PJ_DEBUG_MUTEX 0
341#endif
342
343/**
Benny Prijono9033e312005-11-21 02:08:39 +0000344 * Expand functions in *_i.h header files as inline.
345 *
346 * Default: 0.
347 */
348#ifndef PJ_FUNCTIONS_ARE_INLINED
349# define PJ_FUNCTIONS_ARE_INLINED 0
350#endif
351
352/**
353 * Use floating point computations in the library.
354 *
355 * Default: 1.
356 */
357#ifndef PJ_HAS_FLOATING_POINT
358# define PJ_HAS_FLOATING_POINT 1
359#endif
360
361/**
362 * Declare maximum logging level/verbosity. Lower number indicates higher
363 * importance, with the highest importance has level zero. The least
364 * important level is five in this implementation, but this can be extended
365 * by supplying the appropriate implementation.
366 *
367 * The level conventions:
368 * - 0: fatal error
369 * - 1: error
370 * - 2: warning
371 * - 3: info
372 * - 4: debug
373 * - 5: trace
374 * - 6: more detailed trace
375 *
376 * Default: 4
377 */
378#ifndef PJ_LOG_MAX_LEVEL
379# define PJ_LOG_MAX_LEVEL 5
380#endif
381
382/**
383 * Maximum message size that can be sent to output device for each call
384 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
385 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
386 * flag is set.
387 *
Benny Prijonodc752ca2006-09-22 16:55:42 +0000388 * Default: 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000389 */
390#ifndef PJ_LOG_MAX_SIZE
Benny Prijonodc752ca2006-09-22 16:55:42 +0000391# define PJ_LOG_MAX_SIZE 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000392#endif
393
394/**
395 * Log buffer.
396 * Does the log get the buffer from the stack? (default is yes).
397 * If the value is set to NO, then the buffer will be taken from static
398 * buffer, which in this case will make the log function non-reentrant.
399 *
400 * Default: 1
401 */
402#ifndef PJ_LOG_USE_STACK_BUFFER
403# define PJ_LOG_USE_STACK_BUFFER 1
404#endif
405
406
407/**
408 * Colorfull terminal (for logging etc).
409 *
410 * Default: 1
411 */
412#ifndef PJ_TERM_HAS_COLOR
413# define PJ_TERM_HAS_COLOR 1
414#endif
415
Benny Prijono8508aa02006-03-30 15:56:01 +0000416
Benny Prijono9033e312005-11-21 02:08:39 +0000417/**
Benny Prijonoba4abc92007-06-01 07:26:21 +0000418 * Set this flag to non-zero to enable various checking for pool
419 * operations. When this flag is set, assertion must be enabled
420 * in the application.
421 *
422 * This will slow down pool creation and destruction and will add
423 * few bytes of overhead, so application would normally want to
424 * disable this feature on release build.
425 *
426 * Default: 0
427 */
428#ifndef PJ_SAFE_POOL
429# define PJ_SAFE_POOL 0
430#endif
431
432
433/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000434 * If pool debugging is used, then each memory allocation from the pool
435 * will call malloc(), and pool will release all memory chunks when it
436 * is destroyed. This works better when memory verification programs
437 * such as Rational Purify is used.
Benny Prijono9033e312005-11-21 02:08:39 +0000438 *
439 * Default: 0
440 */
441#ifndef PJ_POOL_DEBUG
442# define PJ_POOL_DEBUG 0
443#endif
444
Benny Prijono8508aa02006-03-30 15:56:01 +0000445
446/**
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000447 * Specify this as \a stack_size argument in #pj_thread_create() to specify
448 * that thread should use default stack size for the current platform.
449 *
450 * Default: 8192
451 */
452#ifndef PJ_THREAD_DEFAULT_STACK_SIZE
453# define PJ_THREAD_DEFAULT_STACK_SIZE 8192
454#endif
455
456
457/**
Benny Prijono467edf02008-01-02 07:56:38 +0000458 * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of
459 * the stack. The OS implementation may check that no stack overflow
460 * occurs, and it also may collect statistic about stack usage. Note
461 * that this will increase the footprint of the libraries since it
462 * tracks the filename and line number of each functions.
463 */
464#ifndef PJ_OS_HAS_CHECK_STACK
465# define PJ_OS_HAS_CHECK_STACK 0
466#endif
467
468/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000469 * Do we have alternate pool implementation?
470 *
471 * Default: 0
472 */
473#ifndef PJ_HAS_POOL_ALT_API
474# define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
475#endif
476
477
Benny Prijono9033e312005-11-21 02:08:39 +0000478/**
Benny Prijono9033e312005-11-21 02:08:39 +0000479 * Support TCP in the library.
480 * Disabling TCP will reduce the footprint slightly (about 6KB).
481 *
482 * Default: 1
483 */
484#ifndef PJ_HAS_TCP
485# define PJ_HAS_TCP 1
486#endif
487
488/**
Benny Prijonoc16c6e32007-11-18 14:53:47 +0000489 * Support IPv6 in the library. If this support is disabled, some IPv6
490 * related functions will return PJ_EIPV6NOTSUP.
491 *
492 * Default: 0 (disabled, for now)
493 */
494#ifndef PJ_HAS_IPV6
495# define PJ_HAS_IPV6 0
496#endif
497
498 /**
Benny Prijono9033e312005-11-21 02:08:39 +0000499 * Maximum hostname length.
500 * Libraries sometimes needs to make copy of an address to stack buffer;
501 * the value here affects the stack usage.
502 *
503 * Default: 128
504 */
505#ifndef PJ_MAX_HOSTNAME
506# define PJ_MAX_HOSTNAME (128)
507#endif
508
509/**
510 * Constants for declaring the maximum handles that can be supported by
511 * a single IOQ framework. This constant might not be relevant to the
512 * underlying I/O queue impelementation, but still, developers should be
513 * aware of this constant, to make sure that the program will not break when
514 * the underlying implementation changes.
Benny Prijono9033e312005-11-21 02:08:39 +0000515 */
516#ifndef PJ_IOQUEUE_MAX_HANDLES
Benny Prijono40fe9082008-02-08 15:21:41 +0000517# define PJ_IOQUEUE_MAX_HANDLES (64)
Benny Prijono9033e312005-11-21 02:08:39 +0000518#endif
519
Benny Prijono8508aa02006-03-30 15:56:01 +0000520
521/**
522 * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
523 * things to ensure thread safety of handle unregistration operation by
524 * employing reference counter to each handle.
525 *
526 * In addition, the ioqueue will preallocate memory for the handles,
527 * according to the maximum number of handles that is specified during
528 * ioqueue creation.
529 *
530 * All applications would normally want this enabled, but you may disable
531 * this if:
532 * - there is no dynamic unregistration to all ioqueues.
533 * - there is no threading, or there is no preemptive multitasking.
534 *
535 * Default: 1
536 */
537#ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
538# define PJ_IOQUEUE_HAS_SAFE_UNREG 1
539#endif
540
541
542/**
Benny Prijonoe3f79fd2008-02-13 15:17:28 +0000543 * Default concurrency setting for sockets/handles registered to ioqueue.
544 * This controls whether the ioqueue is allowed to call the key's callback
545 * concurrently/in parallel. The default is yes, which means that if there
546 * are more than one pending operations complete simultaneously, more
547 * than one threads may call the key's callback at the same time. This
548 * generally would promote good scalability for application, at the
549 * expense of more complexity to manage the concurrent accesses.
550 *
551 * Please see the ioqueue documentation for more info.
552 */
553#ifndef PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY
554# define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY 1
555#endif
556
557
558/* Sanity check:
559 * if ioqueue concurrency is disallowed, PJ_IOQUEUE_HAS_SAFE_UNREG
560 * must be enabled.
561 */
562#if (PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY==0) && (PJ_IOQUEUE_HAS_SAFE_UNREG==0)
563# error PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if ioqueue concurrency \
564 is disabled
565#endif
566
567
568/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000569 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
570 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
571 * ioqueue key is kept in closing state before it can be reused.
572 *
573 * The value is in miliseconds.
574 *
575 * Default: 500 msec.
576 */
577#ifndef PJ_IOQUEUE_KEY_FREE_DELAY
578# define PJ_IOQUEUE_KEY_FREE_DELAY 500
579#endif
580
581
Benny Prijono9033e312005-11-21 02:08:39 +0000582/**
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000583 * Determine if FD_SETSIZE is changeable/set-able. If so, then we will
Benny Prijono40fe9082008-02-08 15:21:41 +0000584 * set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking
585 * for Winsock.
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000586 */
Benny Prijono40fe9082008-02-08 15:21:41 +0000587#ifndef PJ_FD_SETSIZE_SETABLE
Benny Prijono57affd02008-02-18 12:22:15 +0000588# if (defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H!=0) || \
589 (defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H!=0)
Benny Prijono40fe9082008-02-08 15:21:41 +0000590# define PJ_FD_SETSIZE_SETABLE 1
591# else
592# define PJ_FD_SETSIZE_SETABLE 0
593# endif
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000594#endif
595
596/**
Benny Prijono9033e312005-11-21 02:08:39 +0000597 * Overrides FD_SETSIZE so it is consistent throughout the library.
Benny Prijono40fe9082008-02-08 15:21:41 +0000598 * We only do this if we detected that FD_SETSIZE is changeable. If
599 * FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be
600 * set to value lower than FD_SETSIZE.
Benny Prijono9033e312005-11-21 02:08:39 +0000601 */
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000602#if PJ_FD_SETSIZE_SETABLE
603 /* Only override FD_SETSIZE if the value has not been set */
604# ifndef FD_SETSIZE
605# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
606# endif
607#else
608 /* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES
609 * is lower than FD_SETSIZE value.
610 */
611# ifdef FD_SETSIZE
612# if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
613# error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE"
614# endif
615# endif
Benny Prijono9033e312005-11-21 02:08:39 +0000616#endif
617
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000618
Benny Prijono9033e312005-11-21 02:08:39 +0000619/**
Benny Prijono1d6b8952008-07-07 21:31:02 +0000620 * Specify whether #pj_enum_ip_interface() function should exclude
621 * loopback interfaces.
622 *
623 * Default: 1
624 */
625#ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
626# define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
627#endif
628
629
630/**
Benny Prijono9033e312005-11-21 02:08:39 +0000631 * Has semaphore functionality?
632 *
633 * Default: 1
634 */
635#ifndef PJ_HAS_SEMAPHORE
636# define PJ_HAS_SEMAPHORE 1
637#endif
638
639
640/**
641 * Event object (for synchronization, e.g. in Win32)
642 *
643 * Default: 1
644 */
645#ifndef PJ_HAS_EVENT_OBJ
646# define PJ_HAS_EVENT_OBJ 1
647#endif
648
649
650/**
Benny Prijonoa66c3312007-01-21 23:12:40 +0000651 * Maximum file name length.
652 */
653#ifndef PJ_MAXPATH
654# define PJ_MAXPATH 260
655#endif
656
657
658/**
Benny Prijono9033e312005-11-21 02:08:39 +0000659 * Enable library's extra check.
660 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
661 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
662 * will simply evaluate to #pj_assert().
663 *
664 * You can disable this macro to reduce size, at the risk of crashes
665 * if invalid value (e.g. NULL) is passed to the library.
666 *
667 * Default: 1
668 */
669#ifndef PJ_ENABLE_EXTRA_CHECK
670# define PJ_ENABLE_EXTRA_CHECK 1
671#endif
672
673
674/**
675 * Enable name registration for exceptions with #pj_exception_id_alloc().
676 * If this feature is enabled, then the library will keep track of
677 * names associated with each exception ID requested by application via
678 * #pj_exception_id_alloc().
679 *
680 * Disabling this macro will reduce the code and .bss size by a tad bit.
681 * See also #PJ_MAX_EXCEPTION_ID.
682 *
683 * Default: 1
684 */
685#ifndef PJ_HAS_EXCEPTION_NAMES
686# define PJ_HAS_EXCEPTION_NAMES 1
687#endif
688
689/**
690 * Maximum number of unique exception IDs that can be requested
691 * with #pj_exception_id_alloc(). For each entry, a small record will
692 * be allocated in the .bss segment.
693 *
694 * Default: 16
695 */
696#ifndef PJ_MAX_EXCEPTION_ID
697# define PJ_MAX_EXCEPTION_ID 16
698#endif
699
Benny Prijono99683ae2005-11-21 16:59:47 +0000700/**
701 * Should we use Windows Structured Exception Handling (SEH) for the
702 * PJLIB exceptions.
703 *
704 * Default: 0
705 */
706#ifndef PJ_EXCEPTION_USE_WIN32_SEH
707# define PJ_EXCEPTION_USE_WIN32_SEH 0
708#endif
709
710/**
711 * Should we attempt to use Pentium's rdtsc for high resolution
712 * timestamp.
713 *
714 * Default: 0
715 */
716#ifndef PJ_TIMESTAMP_USE_RDTSC
717# define PJ_TIMESTAMP_USE_RDTSC 0
718#endif
719
Benny Prijono11852992006-03-18 12:28:03 +0000720/**
Benny Prijono5d542642007-05-02 18:54:19 +0000721 * Is native platform error positive number?
722 * Default: 1 (yes)
723 */
724#ifndef PJ_NATIVE_ERR_POSITIVE
725# define PJ_NATIVE_ERR_POSITIVE 1
726#endif
727
728/**
Benny Prijono11852992006-03-18 12:28:03 +0000729 * Include error message string in the library (pj_strerror()).
730 * This is very much desirable!
731 *
732 * Default: 1
733 */
734#ifndef PJ_HAS_ERROR_STRING
735# define PJ_HAS_ERROR_STRING 1
736#endif
737
Benny Prijono99683ae2005-11-21 16:59:47 +0000738
Benny Prijonodcf29962006-03-23 18:03:40 +0000739/**
740 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
741 * functions to compare alnum strings. On some systems, they're faster
742 * then stricmp/strcasecmp, but they can be slower on other systems.
743 * When disabled, pjlib will fallback to stricmp/strnicmp.
744 *
745 * Default: 0
746 */
747#ifndef PJ_HAS_STRICMP_ALNUM
748# define PJ_HAS_STRICMP_ALNUM 0
749#endif
750
Benny Prijono4d79b0f2009-10-25 09:02:07 +0000751
752/*
753 * Types of QoS backend implementation.
754 */
755
756/**
757 * Dummy QoS backend implementation, will always return error on all
758 * the APIs.
759 */
760#define PJ_QOS_DUMMY 1
761
762/** QoS backend based on setsockopt(IP_TOS) */
763#define PJ_QOS_BSD 2
764
765/** QoS backend for Windows Mobile 6 */
766#define PJ_QOS_WM 3
767
768/** QoS backend for Symbian */
769#define PJ_QOS_SYMBIAN 4
770
771/**
772 * Force the use of some QoS backend API for some platforms.
773 */
774#ifndef PJ_QOS_IMPLEMENTATION
775# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE && _WIN32_WCE >= 0x502
776 /* Windows Mobile 6 or later */
777# define PJ_QOS_IMPLEMENTATION PJ_QOS_WM
778# endif
779#endif
780
781
Nanang Izzuddinea6d3c42009-10-26 15:47:52 +0000782/**
783 * Enable secure socket. For most platforms, this is implemented using
784 * OpenSSL, so this will require OpenSSL to be installed. For Symbian
785 * platform, this is implemented natively using CSecureSocket.
786 *
787 * Default: 0 (for now)
788 */
789#ifndef PJ_HAS_SSL_SOCK
790# define PJ_HAS_SSL_SOCK 0
791#endif
792
793
Benny Prijono9033e312005-11-21 02:08:39 +0000794/** @} */
795
796/********************************************************************
797 * General macros.
798 */
799
800/**
Benny Prijono31ff4d32007-11-23 03:49:20 +0000801 * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO)
802 * @ingroup pj_config
803 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000804 *
805 * The libraries support generation of dynamic link libraries for
Benny Prijono31ff4d32007-11-23 03:49:20 +0000806 * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian
807 * terms). Similar procedures may be applied for Win32 DLL with some
808 * modification.
809 *
810 * Depending on the platforms, these steps may be necessary in order to
811 * produce the dynamic libraries:
812 * - Create the (Visual Studio) projects to produce DLL output. PJLIB
813 * does not provide ready to use project files to produce DLL, so
814 * you need to create these projects yourself. For Symbian, the MMP
815 * files have been setup to produce DSO files for targets that
816 * require them.
817 * - In the (Visual Studio) projects, some macros need to be declared
818 * so that appropriate modifiers are added to symbol declarations
819 * and definitions. Please see the macro section below for information
820 * regarding these macros. For Symbian, these have been taken care by the
821 * MMP files.
822 * - Some build systems require .DEF file to be specified when creating
823 * the DLL. For Symbian, .DEF files are included in pjlib distribution,
824 * in <tt>pjlib/build.symbian</tt> directory. These DEF files are
825 * created by running <tt>./makedef.sh all</tt> from this directory,
826 * inside Mingw.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000827 *
828 * Macros related for building DLL/DSO files:
829 * - For platforms that supports dynamic link libraries generation,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000830 * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000831 * the prefix to be added to symbol definition, to export this
832 * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000833 * value of this macro is \a __declspec(dllexport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000834 * ABIv2/Symbian, the value is \a EXPORT_C.
835 * - For platforms that supports linking with dynamic link libraries,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000836 * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000837 * the prefix to be added to symbol declaration, to import this
838 * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000839 * value of this macro is \a __declspec(dllimport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000840 * ABIv2/Symbian, the value is \a IMPORT_C.
Benny Prijono31ff4d32007-11-23 03:49:20 +0000841 * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt>
842 * macros above can be declared in your \a config_site.h if they are not
843 * declared by pjlib.
844 * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and
845 * <tt>PJ_EXPORTING</tt> macros must be declared, so that
846 * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function
847 * definition.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000848 * - When application wants to link dynamically with PJLIB, then it
Benny Prijono31ff4d32007-11-23 03:49:20 +0000849 * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header,
850 * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into
851 * symbol declarations.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000852 *
Benny Prijono31ff4d32007-11-23 03:49:20 +0000853 * When <b>PJ_DLL</b> macro is not declared, static linking is assumed.
854 *
855 * For example, here are some settings to produce DLLs with Visual Studio
856 * on Windows/Win32:
857 * - Create Visual Studio projects to produce DLL. Add the appropriate
858 * project dependencies to avoid link errors.
859 * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt>
860 * macros.
861 * - Declare these macros in your <tt>config_site.h</tt>:
862 \verbatim
863 #define PJ_EXPORT_SPECIFIER __declspec(dllexport)
864 #define PJ_IMPORT_SPECIFIER __declspec(dllimport)
865 \endverbatim
866 * - And in the application (that links with the DLL) project, add
867 * <tt>PJ_DLL</tt> in the macro declarations.
868 */
869
870/** @} */
871
872/**
873 * @defgroup pj_config Build Configuration
Benny Prijono31ff4d32007-11-23 03:49:20 +0000874 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000875 */
876
877/**
Benny Prijono9033e312005-11-21 02:08:39 +0000878 * @def PJ_INLINE(type)
879 * @param type The return type of the function.
880 * Expand the function as inline.
881 */
882#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
883
884/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000885 * This macro declares platform/compiler specific specifier prefix
886 * to be added to symbol declaration to export the symbol when PJLIB
887 * is built as dynamic library.
888 *
889 * This macro should have been added by platform specific headers,
890 * if the platform supports building dynamic library target.
891 */
892#ifndef PJ_EXPORT_DECL_SPECIFIER
893# define PJ_EXPORT_DECL_SPECIFIER
894#endif
895
896
897/**
898 * This macro declares platform/compiler specific specifier prefix
899 * to be added to symbol definition to export the symbol when PJLIB
900 * is built as dynamic library.
901 *
902 * This macro should have been added by platform specific headers,
903 * if the platform supports building dynamic library target.
904 */
905#ifndef PJ_EXPORT_DEF_SPECIFIER
906# define PJ_EXPORT_DEF_SPECIFIER
907#endif
908
909
910/**
911 * This macro declares platform/compiler specific specifier prefix
912 * to be added to symbol declaration to import the symbol.
913 *
914 * This macro should have been added by platform specific headers,
915 * if the platform supports building dynamic library target.
916 */
917#ifndef PJ_IMPORT_DECL_SPECIFIER
918# define PJ_IMPORT_DECL_SPECIFIER
919#endif
920
921
922/**
923 * This macro has been deprecated. It will evaluate to nothing.
924 */
925#ifndef PJ_EXPORT_SYMBOL
926# define PJ_EXPORT_SYMBOL(x)
927#endif
928
929
930/**
931 * @def PJ_DECL(type)
932 * @param type The return type of the function.
933 * Declare a function.
934 */
935#if defined(PJ_DLL)
936# if defined(PJ_EXPORTING)
937# define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
938# else
939# define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
940# endif
941#elif !defined(PJ_DECL)
942# if defined(__cplusplus)
943# define PJ_DECL(type) type
944# else
945# define PJ_DECL(type) extern type
946# endif
947#endif
948
949
Benny Prijono9033e312005-11-21 02:08:39 +0000950/**
951 * @def PJ_DEF(type)
952 * @param type The return type of the function.
953 * Define a function.
954 */
Benny Prijono8ab968f2007-07-20 08:08:30 +0000955#if defined(PJ_DLL) && defined(PJ_EXPORTING)
956# define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
957#elif !defined(PJ_DEF)
958# define PJ_DEF(type) type
959#endif
960
Benny Prijono9033e312005-11-21 02:08:39 +0000961
962/**
Benny Prijono225b2222007-11-16 03:49:01 +0000963 * @def PJ_DECL_NO_RETURN(type)
964 * @param type The return type of the function.
965 * Declare a function that will not return.
966 */
967/**
Benny Prijonoa7b376b2008-01-25 16:06:33 +0000968 * @def PJ_IDECL_NO_RETURN(type)
969 * @param type The return type of the function.
970 * Declare an inline function that will not return.
971 */
972/**
Benny Prijono225b2222007-11-16 03:49:01 +0000973 * @def PJ_BEGIN_DECL
974 * Mark beginning of declaration section in a header file.
975 */
976/**
977 * @def PJ_END_DECL
978 * Mark end of declaration section in a header file.
979 */
980#ifdef __cplusplus
981# define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
982# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
983# define PJ_BEGIN_DECL extern "C" {
984# define PJ_END_DECL }
985#else
986# define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
987# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
988# define PJ_BEGIN_DECL
989# define PJ_END_DECL
990#endif
991
992
993
994/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000995 * @def PJ_DECL_DATA(type)
996 * @param type The data type.
997 * Declare a global data.
998 */
999#if defined(PJ_DLL)
1000# if defined(PJ_EXPORTING)
1001# define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
1002# else
1003# define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
1004# endif
1005#elif !defined(PJ_DECL_DATA)
1006# define PJ_DECL_DATA(type) extern type
Benny Prijono9033e312005-11-21 02:08:39 +00001007#endif
1008
Benny Prijono8ab968f2007-07-20 08:08:30 +00001009
1010/**
1011 * @def PJ_DEF_DATA(type)
1012 * @param type The data type.
1013 * Define a global data.
1014 */
1015#if defined(PJ_DLL) && defined(PJ_EXPORTING)
1016# define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
1017#elif !defined(PJ_DEF_DATA)
1018# define PJ_DEF_DATA(type) type
1019#endif
1020
1021
Benny Prijono9033e312005-11-21 02:08:39 +00001022/**
1023 * @def PJ_IDECL(type)
1024 * @param type The function's return type.
1025 * Declare a function that may be expanded as inline.
1026 */
1027/**
1028 * @def PJ_IDEF(type)
1029 * @param type The function's return type.
1030 * Define a function that may be expanded as inline.
1031 */
1032
1033#if PJ_FUNCTIONS_ARE_INLINED
1034# define PJ_IDECL(type) PJ_INLINE(type)
1035# define PJ_IDEF(type) PJ_INLINE(type)
1036#else
1037# define PJ_IDECL(type) PJ_DECL(type)
1038# define PJ_IDEF(type) PJ_DEF(type)
1039#endif
1040
Benny Prijono8ab968f2007-07-20 08:08:30 +00001041
Benny Prijono9033e312005-11-21 02:08:39 +00001042/**
1043 * @def PJ_UNUSED_ARG(arg)
1044 * @param arg The argument name.
1045 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
1046 */
1047#define PJ_UNUSED_ARG(arg) (void)arg
1048
1049/**
1050 * @def PJ_TODO(id)
1051 * @param id Any identifier that will be printed as TODO message.
1052 * PJ_TODO macro will display TODO message as warning during compilation.
1053 * Example: PJ_TODO(CLEAN_UP_ERROR);
1054 */
1055#ifndef PJ_TODO
1056# define PJ_TODO(id) TODO___##id:
1057#endif
1058
1059/**
1060 * Function attributes to inform that the function may throw exception.
1061 *
1062 * @param x The exception list, enclosed in parenthesis.
1063 */
1064#define __pj_throw__(x)
1065
Benny Prijono31ff4d32007-11-23 03:49:20 +00001066/** @} */
Benny Prijono9033e312005-11-21 02:08:39 +00001067
1068/********************************************************************
1069 * Sanity Checks
1070 */
1071#ifndef PJ_HAS_HIGH_RES_TIMER
1072# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
1073#endif
1074
1075#if !defined(PJ_HAS_PENTIUM)
1076# error "PJ_HAS_PENTIUM is not defined!"
1077#endif
1078
1079#if !defined(PJ_IS_LITTLE_ENDIAN)
1080# error "PJ_IS_LITTLE_ENDIAN is not defined!"
1081#endif
1082
1083#if !defined(PJ_IS_BIG_ENDIAN)
1084# error "PJ_IS_BIG_ENDIAN is not defined!"
1085#endif
1086
Benny Prijono42c5b9e2006-05-10 19:24:40 +00001087#if !defined(PJ_EMULATE_RWMUTEX)
1088# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
1089#endif
Benny Prijono9033e312005-11-21 02:08:39 +00001090
Benny Prijono42c5b9e2006-05-10 19:24:40 +00001091#if !defined(PJ_THREAD_SET_STACK_SIZE)
1092# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
1093#endif
1094
1095#if !defined(PJ_THREAD_ALLOCATE_STACK)
1096# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
1097#endif
Benny Prijono9033e312005-11-21 02:08:39 +00001098
1099PJ_BEGIN_DECL
1100
1101/**
Benny Prijonod51a37a2007-07-28 02:44:55 +00001102 * PJLIB version string constant. @see pj_get_version()
Benny Prijono9033e312005-11-21 02:08:39 +00001103 */
Benny Prijonod51a37a2007-07-28 02:44:55 +00001104PJ_DECL_DATA(const char*) PJ_VERSION;
1105
1106/**
1107 * Get PJLIB version string.
1108 *
1109 * @return #PJ_VERSION constant.
1110 */
1111PJ_DECL(const char*) pj_get_version(void);
Benny Prijono9033e312005-11-21 02:08:39 +00001112
1113/**
1114 * Dump configuration to log with verbosity equal to info(3).
1115 */
1116PJ_DECL(void) pj_dump_config(void);
1117
1118PJ_END_DECL
1119
1120
1121#endif /* __PJ_CONFIG_H__ */
1122