blob: 2940d1aa230099b807360a24a90e78fc1856fe42 [file] [log] [blame]
Benny Prijono9033e312005-11-21 02:08:39 +00001/* $Id$ */
2/*
Benny Prijono32177c02008-06-20 22:44:47 +00003 * Copyright (C)2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono9033e312005-11-21 02:08:39 +00004 *
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 * @file config.h
24 * @brief PJLIB Main configuration settings.
25 */
26
27/********************************************************************
28 * Include compiler specific configuration.
29 */
30#if defined(_MSC_VER)
31# include <pj/compat/cc_msvc.h>
32#elif defined(__GNUC__)
33# include <pj/compat/cc_gcc.h>
Benny Prijonof260e462007-04-30 21:03:32 +000034#elif defined(__CW32__)
35# include <pj/compat/cc_mwcc.h>
36#elif defined(__MWERKS__)
37# include <pj/compat/cc_codew.h>
Benny Prijonob2c96822007-05-03 13:31:21 +000038#elif defined(__GCCE__)
39# include <pj/compat/cc_gcce.h>
40#elif defined(__ARMCC__)
41# include <pj/compat/cc_armcc.h>
Benny Prijono9033e312005-11-21 02:08:39 +000042#else
43# error "Unknown compiler."
44#endif
45
46
47/********************************************************************
48 * Include target OS specific configuration.
49 */
Benny Prijonoc4c61d02006-08-20 20:47:34 +000050#if defined(PJ_AUTOCONF)
51 /*
52 * Autoconf
53 */
54# include <pj/compat/os_auto.h>
55
Benny Prijonof260e462007-04-30 21:03:32 +000056#elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
57 /*
58 * SymbianOS
59 */
60# include <pj/compat/os_symbian.h>
61
Benny Prijonoc4c61d02006-08-20 20:47:34 +000062#elif defined(PJ_WIN32_WINCE) || defined(_WIN32_WCE) || defined(UNDER_CE)
Benny Prijonoc4c8f242006-08-01 23:01:55 +000063 /*
64 * Windows CE
65 */
66# undef PJ_WIN32_WINCE
67# define PJ_WIN32_WINCE 1
68# include <pj/compat/os_win32_wince.h>
69
70 /* Also define Win32 */
71# define PJ_WIN32 1
72
73#elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \
74 defined(_WIN64) || defined(WIN32) || defined(__TOS_WIN__)
75 /*
76 * Win32
77 */
78# undef PJ_WIN32
79# define PJ_WIN32 1
80# include <pj/compat/os_win32.h>
81
Benny Prijono9033e312005-11-21 02:08:39 +000082#elif defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +000083 /*
84 * Linux kernel
85 */
Benny Prijono9033e312005-11-21 02:08:39 +000086# include <pj/compat/os_linux_kernel.h>
Benny Prijonoc4c8f242006-08-01 23:01:55 +000087
88#elif defined(PJ_LINUX) || defined(linux) || defined(__linux)
89 /*
90 * Linux
91 */
92# undef PJ_LINUX
93# define PJ_LINUX 1
94# include <pj/compat/os_linux.h>
95
Benny Prijono9033e312005-11-21 02:08:39 +000096#elif defined(PJ_PALMOS) && PJ_PALMOS!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +000097 /*
98 * Palm
99 */
Benny Prijono9033e312005-11-21 02:08:39 +0000100# include <pj/compat/os_palmos.h>
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000101
102#elif defined(PJ_SUNOS) || defined(sun) || defined(__sun)
103 /*
104 * SunOS
105 */
106# undef PJ_SUNOS
107# define PJ_SUNOS 1
108# include <pj/compat/os_sunos.h>
109
110#elif defined(PJ_DARWINOS) || defined(__MACOSX__)
111 /*
112 * MacOS X
113 */
114# undef PJ_DARWINOS
115# define PJ_DARWINOS 1
116# include <pj/compat/os_darwinos.h>
117
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000118#elif defined(PJ_RTEMS) && PJ_RTEMS!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000119 /*
120 * RTEMS
121 */
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000122# include <pj/compat/os_rtems.h>
Benny Prijono9033e312005-11-21 02:08:39 +0000123#else
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000124# error "Please specify target os."
Benny Prijono9033e312005-11-21 02:08:39 +0000125#endif
126
127
128/********************************************************************
129 * Target machine specific configuration.
130 */
Benny Prijonoc4c61d02006-08-20 20:47:34 +0000131#if defined(PJ_AUTOCONF)
132 /*
133 * Autoconf configured
134 */
135#include <pj/compat/m_auto.h>
136
137#elif defined (PJ_M_I386) || defined(_i386_) || defined(i_386_) || \
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000138 defined(_X86_) || defined(x86) || defined(__i386__) || \
139 defined(__i386) || defined(_M_IX86) || defined(__I86__)
140 /*
141 * Generic i386 processor family, little-endian
142 */
143# undef PJ_M_I386
144# define PJ_M_I386 1
145# define PJ_M_NAME "i386"
146# define PJ_HAS_PENTIUM 1
147# define PJ_IS_LITTLE_ENDIAN 1
148# define PJ_IS_BIG_ENDIAN 0
149
150
151#elif defined (PJ_M_X86_64) || defined(__amd64__) || defined(__amd64) || \
152 defined(__x86_64__) || defined(__x86_64)
153 /*
154 * AMD 64bit processor, little endian
155 */
156# undef PJ_M_X86_64
157# define PJ_M_X86_64 1
158# define PJ_M_NAME "x86_64"
159# define PJ_HAS_PENTIUM 1
160# define PJ_IS_LITTLE_ENDIAN 1
161# define PJ_IS_BIG_ENDIAN 0
162
163#elif defined(PJ_M_IA64) || defined(__ia64__) || defined(_IA64) || \
164 defined(__IA64__) || defined( _M_IA64)
165 /*
166 * Intel IA64 processor, little endian
167 */
168# undef PJ_M_IA64
169# define PJ_M_IA64 1
170# define PJ_M_NAME "ia64"
171# define PJ_HAS_PENTIUM 1
172# define PJ_IS_LITTLE_ENDIAN 1
173# define PJ_IS_BIG_ENDIAN 0
174
Benny Prijono9033e312005-11-21 02:08:39 +0000175#elif defined (PJ_M_M68K) && PJ_M_M68K != 0
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000176
177 /*
178 * Motorola m64k processor, little endian
179 */
180# undef PJ_M_M68K
181# define PJ_M_M68K 1
182# define PJ_M_NAME "m68k"
183# define PJ_HAS_PENTIUM 0
184# define PJ_IS_LITTLE_ENDIAN 1
185# define PJ_IS_BIG_ENDIAN 0
186
187
188#elif defined (PJ_M_ALPHA) || defined (__alpha__) || defined (__alpha) || \
189 defined (_M_ALPHA)
190 /*
191 * DEC Alpha processor, little endian
192 */
193# undef PJ_M_ALPHA
194# define PJ_M_ALPHA 1
195# define PJ_M_NAME "alpha"
196# define PJ_HAS_PENTIUM 0
197# define PJ_IS_LITTLE_ENDIAN 1
198# define PJ_IS_BIG_ENDIAN 0
199
200
Benny Prijonod79f25c2006-08-02 19:41:37 +0000201#elif defined(PJ_M_MIPS) || defined(__mips__) || defined(__mips) || \
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000202 defined(__MIPS__) || defined(MIPS) || defined(_MIPS_)
203 /*
Benny Prijonod79f25c2006-08-02 19:41:37 +0000204 * MIPS, default to little endian
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000205 */
206# undef PJ_M_MIPS
207# define PJ_M_MIPS 1
208# define PJ_M_NAME "mips"
209# define PJ_HAS_PENTIUM 0
Benny Prijonod79f25c2006-08-02 19:41:37 +0000210# if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN)
211# define PJ_IS_LITTLE_ENDIAN 1
212# define PJ_IS_BIG_ENDIAN 0
213# endif
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000214
215
216#elif defined (PJ_M_SPARC) || defined( __sparc__) || defined(__sparc)
217 /*
218 * Sun Sparc, big endian
219 */
220# undef PJ_M_SPARC
221# define PJ_M_SPARC 1
222# define PJ_M_NAME "sparc"
223# define PJ_HAS_PENTIUM 0
224# define PJ_IS_LITTLE_ENDIAN 0
225# define PJ_IS_BIG_ENDIAN 1
226
227#elif defined (PJ_M_ARMV4) || defined(ARM) || defined(_ARM_) || \
228 defined(ARMV4) || defined(__arm__)
229 /*
Benny Prijono8f9faae2006-08-04 17:18:37 +0000230 * ARM, default to little endian
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000231 */
232# undef PJ_M_ARMV4
233# define PJ_M_ARMV4 1
234# define PJ_M_NAME "armv4"
235# define PJ_HAS_PENTIUM 0
236# if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN)
237# define PJ_IS_LITTLE_ENDIAN 1
238# define PJ_IS_BIG_ENDIAN 0
239# endif
240
241#elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \
242 defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \
243 defined(_ARCH_PPC)
244 /*
245 * PowerPC, big endian
246 */
247# undef PJ_M_POWERPC
248# define PJ_M_POWERPC 1
249# define PJ_M_NAME "powerpc"
250# define PJ_HAS_PENTIUM 0
Benny Prijonod79f25c2006-08-02 19:41:37 +0000251# define PJ_IS_LITTLE_ENDIAN 0
252# define PJ_IS_BIG_ENDIAN 1
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000253
Benny Prijono93713fb2008-05-07 13:28:06 +0000254#elif defined (PJ_M_NIOS2) || defined(__nios2) || defined(__nios2__) || \
255 defined(__NIOS2__) || defined(__M_NIOS2) || defined(_ARCH_NIOS2)
256 /*
257 * Nios2, little endian
258 */
259# undef PJ_M_NIOS2
260# define PJ_M_NIOS2 1
261# define PJ_M_NAME "nios2"
262# define PJ_HAS_PENTIUM 0
263# define PJ_IS_LITTLE_ENDIAN 1
264# define PJ_IS_BIG_ENDIAN 0
265
Benny Prijono9033e312005-11-21 02:08:39 +0000266#else
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000267# error "Please specify target machine."
Benny Prijono9033e312005-11-21 02:08:39 +0000268#endif
269
270/* Include size_t definition. */
271#include <pj/compat/size_t.h>
272
273/* Include site/user specific configuration to control PJLIB features.
274 * YOU MUST CREATE THIS FILE YOURSELF!!
275 */
276#include <pj/config_site.h>
277
278/********************************************************************
279 * PJLIB Features.
280 */
281
282/* Overrides for DOXYGEN */
283#ifdef DOXYGEN
284# undef PJ_FUNCTIONS_ARE_INLINED
285# undef PJ_HAS_FLOATING_POINT
286# undef PJ_LOG_MAX_LEVEL
287# undef PJ_LOG_MAX_SIZE
288# undef PJ_LOG_USE_STACK_BUFFER
289# undef PJ_TERM_HAS_COLOR
290# undef PJ_POOL_DEBUG
291# undef PJ_HAS_TCP
292# undef PJ_MAX_HOSTNAME
293# undef PJ_IOQUEUE_MAX_HANDLES
294# undef FD_SETSIZE
295# undef PJ_HAS_SEMAPHORE
296# undef PJ_HAS_EVENT_OBJ
297# undef PJ_ENABLE_EXTRA_CHECK
Benny Prijono99683ae2005-11-21 16:59:47 +0000298# undef PJ_EXCEPTION_USE_WIN32_SEH
Benny Prijono11852992006-03-18 12:28:03 +0000299# undef PJ_HAS_ERROR_STRING
Benny Prijonoe3f79fd2008-02-13 15:17:28 +0000300
301# define PJ_HAS_IPV6 1
Benny Prijono9033e312005-11-21 02:08:39 +0000302#endif
303
304/**
305 * @defgroup pj_config Build Configuration
Benny Prijono9033e312005-11-21 02:08:39 +0000306 * @{
307 *
308 * This section contains macros that can set during PJLIB build process
309 * to controll various aspects of the library.
310 *
311 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
312 * macro values during the build process.
313 */
314
315/**
316 * If this macro is set to 1, it will enable some debugging checking
317 * in the library.
318 *
319 * Default: equal to (NOT NDEBUG).
320 */
321#ifndef PJ_DEBUG
322# ifndef NDEBUG
323# define PJ_DEBUG 1
324# else
325# define PJ_DEBUG 0
326# endif
327#endif
328
329/**
330 * Expand functions in *_i.h header files as inline.
331 *
332 * Default: 0.
333 */
334#ifndef PJ_FUNCTIONS_ARE_INLINED
335# define PJ_FUNCTIONS_ARE_INLINED 0
336#endif
337
338/**
339 * Use floating point computations in the library.
340 *
341 * Default: 1.
342 */
343#ifndef PJ_HAS_FLOATING_POINT
344# define PJ_HAS_FLOATING_POINT 1
345#endif
346
347/**
348 * Declare maximum logging level/verbosity. Lower number indicates higher
349 * importance, with the highest importance has level zero. The least
350 * important level is five in this implementation, but this can be extended
351 * by supplying the appropriate implementation.
352 *
353 * The level conventions:
354 * - 0: fatal error
355 * - 1: error
356 * - 2: warning
357 * - 3: info
358 * - 4: debug
359 * - 5: trace
360 * - 6: more detailed trace
361 *
362 * Default: 4
363 */
364#ifndef PJ_LOG_MAX_LEVEL
365# define PJ_LOG_MAX_LEVEL 5
366#endif
367
368/**
369 * Maximum message size that can be sent to output device for each call
370 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
371 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
372 * flag is set.
373 *
Benny Prijonodc752ca2006-09-22 16:55:42 +0000374 * Default: 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000375 */
376#ifndef PJ_LOG_MAX_SIZE
Benny Prijonodc752ca2006-09-22 16:55:42 +0000377# define PJ_LOG_MAX_SIZE 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000378#endif
379
380/**
381 * Log buffer.
382 * Does the log get the buffer from the stack? (default is yes).
383 * If the value is set to NO, then the buffer will be taken from static
384 * buffer, which in this case will make the log function non-reentrant.
385 *
386 * Default: 1
387 */
388#ifndef PJ_LOG_USE_STACK_BUFFER
389# define PJ_LOG_USE_STACK_BUFFER 1
390#endif
391
392
393/**
394 * Colorfull terminal (for logging etc).
395 *
396 * Default: 1
397 */
398#ifndef PJ_TERM_HAS_COLOR
399# define PJ_TERM_HAS_COLOR 1
400#endif
401
Benny Prijono8508aa02006-03-30 15:56:01 +0000402
Benny Prijono9033e312005-11-21 02:08:39 +0000403/**
Benny Prijonoba4abc92007-06-01 07:26:21 +0000404 * Set this flag to non-zero to enable various checking for pool
405 * operations. When this flag is set, assertion must be enabled
406 * in the application.
407 *
408 * This will slow down pool creation and destruction and will add
409 * few bytes of overhead, so application would normally want to
410 * disable this feature on release build.
411 *
412 * Default: 0
413 */
414#ifndef PJ_SAFE_POOL
415# define PJ_SAFE_POOL 0
416#endif
417
418
419/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000420 * If pool debugging is used, then each memory allocation from the pool
421 * will call malloc(), and pool will release all memory chunks when it
422 * is destroyed. This works better when memory verification programs
423 * such as Rational Purify is used.
Benny Prijono9033e312005-11-21 02:08:39 +0000424 *
425 * Default: 0
426 */
427#ifndef PJ_POOL_DEBUG
428# define PJ_POOL_DEBUG 0
429#endif
430
Benny Prijono8508aa02006-03-30 15:56:01 +0000431
432/**
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000433 * Specify this as \a stack_size argument in #pj_thread_create() to specify
434 * that thread should use default stack size for the current platform.
435 *
436 * Default: 8192
437 */
438#ifndef PJ_THREAD_DEFAULT_STACK_SIZE
439# define PJ_THREAD_DEFAULT_STACK_SIZE 8192
440#endif
441
442
443/**
Benny Prijono467edf02008-01-02 07:56:38 +0000444 * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of
445 * the stack. The OS implementation may check that no stack overflow
446 * occurs, and it also may collect statistic about stack usage. Note
447 * that this will increase the footprint of the libraries since it
448 * tracks the filename and line number of each functions.
449 */
450#ifndef PJ_OS_HAS_CHECK_STACK
451# define PJ_OS_HAS_CHECK_STACK 0
452#endif
453
454/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000455 * Do we have alternate pool implementation?
456 *
457 * Default: 0
458 */
459#ifndef PJ_HAS_POOL_ALT_API
460# define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
461#endif
462
463
Benny Prijono9033e312005-11-21 02:08:39 +0000464/**
Benny Prijono9033e312005-11-21 02:08:39 +0000465 * Support TCP in the library.
466 * Disabling TCP will reduce the footprint slightly (about 6KB).
467 *
468 * Default: 1
469 */
470#ifndef PJ_HAS_TCP
471# define PJ_HAS_TCP 1
472#endif
473
474/**
Benny Prijonoc16c6e32007-11-18 14:53:47 +0000475 * Support IPv6 in the library. If this support is disabled, some IPv6
476 * related functions will return PJ_EIPV6NOTSUP.
477 *
478 * Default: 0 (disabled, for now)
479 */
480#ifndef PJ_HAS_IPV6
481# define PJ_HAS_IPV6 0
482#endif
483
484 /**
Benny Prijono9033e312005-11-21 02:08:39 +0000485 * Maximum hostname length.
486 * Libraries sometimes needs to make copy of an address to stack buffer;
487 * the value here affects the stack usage.
488 *
489 * Default: 128
490 */
491#ifndef PJ_MAX_HOSTNAME
492# define PJ_MAX_HOSTNAME (128)
493#endif
494
495/**
496 * Constants for declaring the maximum handles that can be supported by
497 * a single IOQ framework. This constant might not be relevant to the
498 * underlying I/O queue impelementation, but still, developers should be
499 * aware of this constant, to make sure that the program will not break when
500 * the underlying implementation changes.
Benny Prijono9033e312005-11-21 02:08:39 +0000501 */
502#ifndef PJ_IOQUEUE_MAX_HANDLES
Benny Prijono40fe9082008-02-08 15:21:41 +0000503# define PJ_IOQUEUE_MAX_HANDLES (64)
Benny Prijono9033e312005-11-21 02:08:39 +0000504#endif
505
Benny Prijono8508aa02006-03-30 15:56:01 +0000506
507/**
508 * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
509 * things to ensure thread safety of handle unregistration operation by
510 * employing reference counter to each handle.
511 *
512 * In addition, the ioqueue will preallocate memory for the handles,
513 * according to the maximum number of handles that is specified during
514 * ioqueue creation.
515 *
516 * All applications would normally want this enabled, but you may disable
517 * this if:
518 * - there is no dynamic unregistration to all ioqueues.
519 * - there is no threading, or there is no preemptive multitasking.
520 *
521 * Default: 1
522 */
523#ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
524# define PJ_IOQUEUE_HAS_SAFE_UNREG 1
525#endif
526
527
528/**
Benny Prijonoe3f79fd2008-02-13 15:17:28 +0000529 * Default concurrency setting for sockets/handles registered to ioqueue.
530 * This controls whether the ioqueue is allowed to call the key's callback
531 * concurrently/in parallel. The default is yes, which means that if there
532 * are more than one pending operations complete simultaneously, more
533 * than one threads may call the key's callback at the same time. This
534 * generally would promote good scalability for application, at the
535 * expense of more complexity to manage the concurrent accesses.
536 *
537 * Please see the ioqueue documentation for more info.
538 */
539#ifndef PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY
540# define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY 1
541#endif
542
543
544/* Sanity check:
545 * if ioqueue concurrency is disallowed, PJ_IOQUEUE_HAS_SAFE_UNREG
546 * must be enabled.
547 */
548#if (PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY==0) && (PJ_IOQUEUE_HAS_SAFE_UNREG==0)
549# error PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if ioqueue concurrency \
550 is disabled
551#endif
552
553
554/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000555 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
556 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
557 * ioqueue key is kept in closing state before it can be reused.
558 *
559 * The value is in miliseconds.
560 *
561 * Default: 500 msec.
562 */
563#ifndef PJ_IOQUEUE_KEY_FREE_DELAY
564# define PJ_IOQUEUE_KEY_FREE_DELAY 500
565#endif
566
567
Benny Prijono9033e312005-11-21 02:08:39 +0000568/**
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000569 * Determine if FD_SETSIZE is changeable/set-able. If so, then we will
Benny Prijono40fe9082008-02-08 15:21:41 +0000570 * set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking
571 * for Winsock.
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000572 */
Benny Prijono40fe9082008-02-08 15:21:41 +0000573#ifndef PJ_FD_SETSIZE_SETABLE
Benny Prijono57affd02008-02-18 12:22:15 +0000574# if (defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H!=0) || \
575 (defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H!=0)
Benny Prijono40fe9082008-02-08 15:21:41 +0000576# define PJ_FD_SETSIZE_SETABLE 1
577# else
578# define PJ_FD_SETSIZE_SETABLE 0
579# endif
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000580#endif
581
582/**
Benny Prijono9033e312005-11-21 02:08:39 +0000583 * Overrides FD_SETSIZE so it is consistent throughout the library.
Benny Prijono40fe9082008-02-08 15:21:41 +0000584 * We only do this if we detected that FD_SETSIZE is changeable. If
585 * FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be
586 * set to value lower than FD_SETSIZE.
Benny Prijono9033e312005-11-21 02:08:39 +0000587 */
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000588#if PJ_FD_SETSIZE_SETABLE
589 /* Only override FD_SETSIZE if the value has not been set */
590# ifndef FD_SETSIZE
591# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
592# endif
593#else
594 /* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES
595 * is lower than FD_SETSIZE value.
596 */
597# ifdef FD_SETSIZE
598# if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
599# error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE"
600# endif
601# endif
Benny Prijono9033e312005-11-21 02:08:39 +0000602#endif
603
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000604
Benny Prijono9033e312005-11-21 02:08:39 +0000605/**
Benny Prijono1d6b8952008-07-07 21:31:02 +0000606 * Specify whether #pj_enum_ip_interface() function should exclude
607 * loopback interfaces.
608 *
609 * Default: 1
610 */
611#ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
612# define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
613#endif
614
615
616/**
Benny Prijono9033e312005-11-21 02:08:39 +0000617 * Has semaphore functionality?
618 *
619 * Default: 1
620 */
621#ifndef PJ_HAS_SEMAPHORE
622# define PJ_HAS_SEMAPHORE 1
623#endif
624
625
626/**
627 * Event object (for synchronization, e.g. in Win32)
628 *
629 * Default: 1
630 */
631#ifndef PJ_HAS_EVENT_OBJ
632# define PJ_HAS_EVENT_OBJ 1
633#endif
634
635
636/**
Benny Prijonoa66c3312007-01-21 23:12:40 +0000637 * Maximum file name length.
638 */
639#ifndef PJ_MAXPATH
640# define PJ_MAXPATH 260
641#endif
642
643
644/**
Benny Prijono9033e312005-11-21 02:08:39 +0000645 * Enable library's extra check.
646 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
647 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
648 * will simply evaluate to #pj_assert().
649 *
650 * You can disable this macro to reduce size, at the risk of crashes
651 * if invalid value (e.g. NULL) is passed to the library.
652 *
653 * Default: 1
654 */
655#ifndef PJ_ENABLE_EXTRA_CHECK
656# define PJ_ENABLE_EXTRA_CHECK 1
657#endif
658
659
660/**
661 * Enable name registration for exceptions with #pj_exception_id_alloc().
662 * If this feature is enabled, then the library will keep track of
663 * names associated with each exception ID requested by application via
664 * #pj_exception_id_alloc().
665 *
666 * Disabling this macro will reduce the code and .bss size by a tad bit.
667 * See also #PJ_MAX_EXCEPTION_ID.
668 *
669 * Default: 1
670 */
671#ifndef PJ_HAS_EXCEPTION_NAMES
672# define PJ_HAS_EXCEPTION_NAMES 1
673#endif
674
675/**
676 * Maximum number of unique exception IDs that can be requested
677 * with #pj_exception_id_alloc(). For each entry, a small record will
678 * be allocated in the .bss segment.
679 *
680 * Default: 16
681 */
682#ifndef PJ_MAX_EXCEPTION_ID
683# define PJ_MAX_EXCEPTION_ID 16
684#endif
685
Benny Prijono99683ae2005-11-21 16:59:47 +0000686/**
687 * Should we use Windows Structured Exception Handling (SEH) for the
688 * PJLIB exceptions.
689 *
690 * Default: 0
691 */
692#ifndef PJ_EXCEPTION_USE_WIN32_SEH
693# define PJ_EXCEPTION_USE_WIN32_SEH 0
694#endif
695
696/**
697 * Should we attempt to use Pentium's rdtsc for high resolution
698 * timestamp.
699 *
700 * Default: 0
701 */
702#ifndef PJ_TIMESTAMP_USE_RDTSC
703# define PJ_TIMESTAMP_USE_RDTSC 0
704#endif
705
Benny Prijono11852992006-03-18 12:28:03 +0000706/**
Benny Prijono5d542642007-05-02 18:54:19 +0000707 * Is native platform error positive number?
708 * Default: 1 (yes)
709 */
710#ifndef PJ_NATIVE_ERR_POSITIVE
711# define PJ_NATIVE_ERR_POSITIVE 1
712#endif
713
714/**
Benny Prijono11852992006-03-18 12:28:03 +0000715 * Include error message string in the library (pj_strerror()).
716 * This is very much desirable!
717 *
718 * Default: 1
719 */
720#ifndef PJ_HAS_ERROR_STRING
721# define PJ_HAS_ERROR_STRING 1
722#endif
723
Benny Prijono99683ae2005-11-21 16:59:47 +0000724
Benny Prijonodcf29962006-03-23 18:03:40 +0000725/**
726 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
727 * functions to compare alnum strings. On some systems, they're faster
728 * then stricmp/strcasecmp, but they can be slower on other systems.
729 * When disabled, pjlib will fallback to stricmp/strnicmp.
730 *
731 * Default: 0
732 */
733#ifndef PJ_HAS_STRICMP_ALNUM
734# define PJ_HAS_STRICMP_ALNUM 0
735#endif
736
Benny Prijono9033e312005-11-21 02:08:39 +0000737/** @} */
738
739/********************************************************************
740 * General macros.
741 */
742
743/**
Benny Prijono31ff4d32007-11-23 03:49:20 +0000744 * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO)
745 * @ingroup pj_config
746 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000747 *
748 * The libraries support generation of dynamic link libraries for
Benny Prijono31ff4d32007-11-23 03:49:20 +0000749 * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian
750 * terms). Similar procedures may be applied for Win32 DLL with some
751 * modification.
752 *
753 * Depending on the platforms, these steps may be necessary in order to
754 * produce the dynamic libraries:
755 * - Create the (Visual Studio) projects to produce DLL output. PJLIB
756 * does not provide ready to use project files to produce DLL, so
757 * you need to create these projects yourself. For Symbian, the MMP
758 * files have been setup to produce DSO files for targets that
759 * require them.
760 * - In the (Visual Studio) projects, some macros need to be declared
761 * so that appropriate modifiers are added to symbol declarations
762 * and definitions. Please see the macro section below for information
763 * regarding these macros. For Symbian, these have been taken care by the
764 * MMP files.
765 * - Some build systems require .DEF file to be specified when creating
766 * the DLL. For Symbian, .DEF files are included in pjlib distribution,
767 * in <tt>pjlib/build.symbian</tt> directory. These DEF files are
768 * created by running <tt>./makedef.sh all</tt> from this directory,
769 * inside Mingw.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000770 *
771 * Macros related for building DLL/DSO files:
772 * - For platforms that supports dynamic link libraries generation,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000773 * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000774 * the prefix to be added to symbol definition, to export this
775 * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000776 * value of this macro is \a __declspec(dllexport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000777 * ABIv2/Symbian, the value is \a EXPORT_C.
778 * - For platforms that supports linking with dynamic link libraries,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000779 * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000780 * the prefix to be added to symbol declaration, to import this
781 * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000782 * value of this macro is \a __declspec(dllimport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000783 * ABIv2/Symbian, the value is \a IMPORT_C.
Benny Prijono31ff4d32007-11-23 03:49:20 +0000784 * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt>
785 * macros above can be declared in your \a config_site.h if they are not
786 * declared by pjlib.
787 * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and
788 * <tt>PJ_EXPORTING</tt> macros must be declared, so that
789 * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function
790 * definition.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000791 * - When application wants to link dynamically with PJLIB, then it
Benny Prijono31ff4d32007-11-23 03:49:20 +0000792 * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header,
793 * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into
794 * symbol declarations.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000795 *
Benny Prijono31ff4d32007-11-23 03:49:20 +0000796 * When <b>PJ_DLL</b> macro is not declared, static linking is assumed.
797 *
798 * For example, here are some settings to produce DLLs with Visual Studio
799 * on Windows/Win32:
800 * - Create Visual Studio projects to produce DLL. Add the appropriate
801 * project dependencies to avoid link errors.
802 * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt>
803 * macros.
804 * - Declare these macros in your <tt>config_site.h</tt>:
805 \verbatim
806 #define PJ_EXPORT_SPECIFIER __declspec(dllexport)
807 #define PJ_IMPORT_SPECIFIER __declspec(dllimport)
808 \endverbatim
809 * - And in the application (that links with the DLL) project, add
810 * <tt>PJ_DLL</tt> in the macro declarations.
811 */
812
813/** @} */
814
815/**
816 * @defgroup pj_config Build Configuration
Benny Prijono31ff4d32007-11-23 03:49:20 +0000817 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000818 */
819
820/**
Benny Prijono9033e312005-11-21 02:08:39 +0000821 * @def PJ_INLINE(type)
822 * @param type The return type of the function.
823 * Expand the function as inline.
824 */
825#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
826
827/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000828 * This macro declares platform/compiler specific specifier prefix
829 * to be added to symbol declaration to export the symbol when PJLIB
830 * is built as dynamic library.
831 *
832 * This macro should have been added by platform specific headers,
833 * if the platform supports building dynamic library target.
834 */
835#ifndef PJ_EXPORT_DECL_SPECIFIER
836# define PJ_EXPORT_DECL_SPECIFIER
837#endif
838
839
840/**
841 * This macro declares platform/compiler specific specifier prefix
842 * to be added to symbol definition to export the symbol when PJLIB
843 * is built as dynamic library.
844 *
845 * This macro should have been added by platform specific headers,
846 * if the platform supports building dynamic library target.
847 */
848#ifndef PJ_EXPORT_DEF_SPECIFIER
849# define PJ_EXPORT_DEF_SPECIFIER
850#endif
851
852
853/**
854 * This macro declares platform/compiler specific specifier prefix
855 * to be added to symbol declaration to import the symbol.
856 *
857 * This macro should have been added by platform specific headers,
858 * if the platform supports building dynamic library target.
859 */
860#ifndef PJ_IMPORT_DECL_SPECIFIER
861# define PJ_IMPORT_DECL_SPECIFIER
862#endif
863
864
865/**
866 * This macro has been deprecated. It will evaluate to nothing.
867 */
868#ifndef PJ_EXPORT_SYMBOL
869# define PJ_EXPORT_SYMBOL(x)
870#endif
871
872
873/**
874 * @def PJ_DECL(type)
875 * @param type The return type of the function.
876 * Declare a function.
877 */
878#if defined(PJ_DLL)
879# if defined(PJ_EXPORTING)
880# define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
881# else
882# define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
883# endif
884#elif !defined(PJ_DECL)
885# if defined(__cplusplus)
886# define PJ_DECL(type) type
887# else
888# define PJ_DECL(type) extern type
889# endif
890#endif
891
892
Benny Prijono9033e312005-11-21 02:08:39 +0000893/**
894 * @def PJ_DEF(type)
895 * @param type The return type of the function.
896 * Define a function.
897 */
Benny Prijono8ab968f2007-07-20 08:08:30 +0000898#if defined(PJ_DLL) && defined(PJ_EXPORTING)
899# define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
900#elif !defined(PJ_DEF)
901# define PJ_DEF(type) type
902#endif
903
Benny Prijono9033e312005-11-21 02:08:39 +0000904
905/**
Benny Prijono225b2222007-11-16 03:49:01 +0000906 * @def PJ_DECL_NO_RETURN(type)
907 * @param type The return type of the function.
908 * Declare a function that will not return.
909 */
910/**
Benny Prijonoa7b376b2008-01-25 16:06:33 +0000911 * @def PJ_IDECL_NO_RETURN(type)
912 * @param type The return type of the function.
913 * Declare an inline function that will not return.
914 */
915/**
Benny Prijono225b2222007-11-16 03:49:01 +0000916 * @def PJ_BEGIN_DECL
917 * Mark beginning of declaration section in a header file.
918 */
919/**
920 * @def PJ_END_DECL
921 * Mark end of declaration section in a header file.
922 */
923#ifdef __cplusplus
924# define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
925# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
926# define PJ_BEGIN_DECL extern "C" {
927# define PJ_END_DECL }
928#else
929# define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
930# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
931# define PJ_BEGIN_DECL
932# define PJ_END_DECL
933#endif
934
935
936
937/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000938 * @def PJ_DECL_DATA(type)
939 * @param type The data type.
940 * Declare a global data.
941 */
942#if defined(PJ_DLL)
943# if defined(PJ_EXPORTING)
944# define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
945# else
946# define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
947# endif
948#elif !defined(PJ_DECL_DATA)
949# define PJ_DECL_DATA(type) extern type
Benny Prijono9033e312005-11-21 02:08:39 +0000950#endif
951
Benny Prijono8ab968f2007-07-20 08:08:30 +0000952
953/**
954 * @def PJ_DEF_DATA(type)
955 * @param type The data type.
956 * Define a global data.
957 */
958#if defined(PJ_DLL) && defined(PJ_EXPORTING)
959# define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
960#elif !defined(PJ_DEF_DATA)
961# define PJ_DEF_DATA(type) type
962#endif
963
964
Benny Prijono9033e312005-11-21 02:08:39 +0000965/**
966 * @def PJ_IDECL(type)
967 * @param type The function's return type.
968 * Declare a function that may be expanded as inline.
969 */
970/**
971 * @def PJ_IDEF(type)
972 * @param type The function's return type.
973 * Define a function that may be expanded as inline.
974 */
975
976#if PJ_FUNCTIONS_ARE_INLINED
977# define PJ_IDECL(type) PJ_INLINE(type)
978# define PJ_IDEF(type) PJ_INLINE(type)
979#else
980# define PJ_IDECL(type) PJ_DECL(type)
981# define PJ_IDEF(type) PJ_DEF(type)
982#endif
983
Benny Prijono8ab968f2007-07-20 08:08:30 +0000984
Benny Prijono9033e312005-11-21 02:08:39 +0000985/**
986 * @def PJ_UNUSED_ARG(arg)
987 * @param arg The argument name.
988 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
989 */
990#define PJ_UNUSED_ARG(arg) (void)arg
991
992/**
993 * @def PJ_TODO(id)
994 * @param id Any identifier that will be printed as TODO message.
995 * PJ_TODO macro will display TODO message as warning during compilation.
996 * Example: PJ_TODO(CLEAN_UP_ERROR);
997 */
998#ifndef PJ_TODO
999# define PJ_TODO(id) TODO___##id:
1000#endif
1001
1002/**
1003 * Function attributes to inform that the function may throw exception.
1004 *
1005 * @param x The exception list, enclosed in parenthesis.
1006 */
1007#define __pj_throw__(x)
1008
Benny Prijono31ff4d32007-11-23 03:49:20 +00001009/** @} */
Benny Prijono9033e312005-11-21 02:08:39 +00001010
1011/********************************************************************
1012 * Sanity Checks
1013 */
1014#ifndef PJ_HAS_HIGH_RES_TIMER
1015# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
1016#endif
1017
1018#if !defined(PJ_HAS_PENTIUM)
1019# error "PJ_HAS_PENTIUM is not defined!"
1020#endif
1021
1022#if !defined(PJ_IS_LITTLE_ENDIAN)
1023# error "PJ_IS_LITTLE_ENDIAN is not defined!"
1024#endif
1025
1026#if !defined(PJ_IS_BIG_ENDIAN)
1027# error "PJ_IS_BIG_ENDIAN is not defined!"
1028#endif
1029
Benny Prijono42c5b9e2006-05-10 19:24:40 +00001030#if !defined(PJ_EMULATE_RWMUTEX)
1031# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
1032#endif
Benny Prijono9033e312005-11-21 02:08:39 +00001033
Benny Prijono42c5b9e2006-05-10 19:24:40 +00001034#if !defined(PJ_THREAD_SET_STACK_SIZE)
1035# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
1036#endif
1037
1038#if !defined(PJ_THREAD_ALLOCATE_STACK)
1039# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
1040#endif
Benny Prijono9033e312005-11-21 02:08:39 +00001041
1042PJ_BEGIN_DECL
1043
1044/**
Benny Prijonod51a37a2007-07-28 02:44:55 +00001045 * PJLIB version string constant. @see pj_get_version()
Benny Prijono9033e312005-11-21 02:08:39 +00001046 */
Benny Prijonod51a37a2007-07-28 02:44:55 +00001047PJ_DECL_DATA(const char*) PJ_VERSION;
1048
1049/**
1050 * Get PJLIB version string.
1051 *
1052 * @return #PJ_VERSION constant.
1053 */
1054PJ_DECL(const char*) pj_get_version(void);
Benny Prijono9033e312005-11-21 02:08:39 +00001055
1056/**
1057 * Dump configuration to log with verbosity equal to info(3).
1058 */
1059PJ_DECL(void) pj_dump_config(void);
1060
1061PJ_END_DECL
1062
1063
1064#endif /* __PJ_CONFIG_H__ */
1065