blob: d620d4b797e2e00c8a7a1e6cb90e388c0fcc4200 [file] [log] [blame]
Benny Prijono9033e312005-11-21 02:08:39 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C)2003-2007 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 Prijono9033e312005-11-21 02:08:39 +0000254#else
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000255# error "Please specify target machine."
Benny Prijono9033e312005-11-21 02:08:39 +0000256#endif
257
258/* Include size_t definition. */
259#include <pj/compat/size_t.h>
260
261/* Include site/user specific configuration to control PJLIB features.
262 * YOU MUST CREATE THIS FILE YOURSELF!!
263 */
264#include <pj/config_site.h>
265
266/********************************************************************
267 * PJLIB Features.
268 */
269
270/* Overrides for DOXYGEN */
271#ifdef DOXYGEN
272# undef PJ_FUNCTIONS_ARE_INLINED
273# undef PJ_HAS_FLOATING_POINT
274# undef PJ_LOG_MAX_LEVEL
275# undef PJ_LOG_MAX_SIZE
276# undef PJ_LOG_USE_STACK_BUFFER
277# undef PJ_TERM_HAS_COLOR
278# undef PJ_POOL_DEBUG
279# undef PJ_HAS_TCP
280# undef PJ_MAX_HOSTNAME
281# undef PJ_IOQUEUE_MAX_HANDLES
282# undef FD_SETSIZE
283# undef PJ_HAS_SEMAPHORE
284# undef PJ_HAS_EVENT_OBJ
285# undef PJ_ENABLE_EXTRA_CHECK
Benny Prijono99683ae2005-11-21 16:59:47 +0000286# undef PJ_EXCEPTION_USE_WIN32_SEH
Benny Prijono11852992006-03-18 12:28:03 +0000287# undef PJ_HAS_ERROR_STRING
Benny Prijono9033e312005-11-21 02:08:39 +0000288#endif
289
290/**
291 * @defgroup pj_config Build Configuration
292 * @ingroup PJ
293 * @{
294 *
295 * This section contains macros that can set during PJLIB build process
296 * to controll various aspects of the library.
297 *
298 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
299 * macro values during the build process.
300 */
301
302/**
303 * If this macro is set to 1, it will enable some debugging checking
304 * in the library.
305 *
306 * Default: equal to (NOT NDEBUG).
307 */
308#ifndef PJ_DEBUG
309# ifndef NDEBUG
310# define PJ_DEBUG 1
311# else
312# define PJ_DEBUG 0
313# endif
314#endif
315
316/**
317 * Expand functions in *_i.h header files as inline.
318 *
319 * Default: 0.
320 */
321#ifndef PJ_FUNCTIONS_ARE_INLINED
322# define PJ_FUNCTIONS_ARE_INLINED 0
323#endif
324
325/**
326 * Use floating point computations in the library.
327 *
328 * Default: 1.
329 */
330#ifndef PJ_HAS_FLOATING_POINT
331# define PJ_HAS_FLOATING_POINT 1
332#endif
333
334/**
335 * Declare maximum logging level/verbosity. Lower number indicates higher
336 * importance, with the highest importance has level zero. The least
337 * important level is five in this implementation, but this can be extended
338 * by supplying the appropriate implementation.
339 *
340 * The level conventions:
341 * - 0: fatal error
342 * - 1: error
343 * - 2: warning
344 * - 3: info
345 * - 4: debug
346 * - 5: trace
347 * - 6: more detailed trace
348 *
349 * Default: 4
350 */
351#ifndef PJ_LOG_MAX_LEVEL
352# define PJ_LOG_MAX_LEVEL 5
353#endif
354
355/**
356 * Maximum message size that can be sent to output device for each call
357 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
358 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
359 * flag is set.
360 *
Benny Prijonodc752ca2006-09-22 16:55:42 +0000361 * Default: 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000362 */
363#ifndef PJ_LOG_MAX_SIZE
Benny Prijonodc752ca2006-09-22 16:55:42 +0000364# define PJ_LOG_MAX_SIZE 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000365#endif
366
367/**
368 * Log buffer.
369 * Does the log get the buffer from the stack? (default is yes).
370 * If the value is set to NO, then the buffer will be taken from static
371 * buffer, which in this case will make the log function non-reentrant.
372 *
373 * Default: 1
374 */
375#ifndef PJ_LOG_USE_STACK_BUFFER
376# define PJ_LOG_USE_STACK_BUFFER 1
377#endif
378
379
380/**
381 * Colorfull terminal (for logging etc).
382 *
383 * Default: 1
384 */
385#ifndef PJ_TERM_HAS_COLOR
386# define PJ_TERM_HAS_COLOR 1
387#endif
388
Benny Prijono8508aa02006-03-30 15:56:01 +0000389
Benny Prijono9033e312005-11-21 02:08:39 +0000390/**
Benny Prijonoba4abc92007-06-01 07:26:21 +0000391 * Set this flag to non-zero to enable various checking for pool
392 * operations. When this flag is set, assertion must be enabled
393 * in the application.
394 *
395 * This will slow down pool creation and destruction and will add
396 * few bytes of overhead, so application would normally want to
397 * disable this feature on release build.
398 *
399 * Default: 0
400 */
401#ifndef PJ_SAFE_POOL
402# define PJ_SAFE_POOL 0
403#endif
404
405
406/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000407 * If pool debugging is used, then each memory allocation from the pool
408 * will call malloc(), and pool will release all memory chunks when it
409 * is destroyed. This works better when memory verification programs
410 * such as Rational Purify is used.
Benny Prijono9033e312005-11-21 02:08:39 +0000411 *
412 * Default: 0
413 */
414#ifndef PJ_POOL_DEBUG
415# define PJ_POOL_DEBUG 0
416#endif
417
Benny Prijono8508aa02006-03-30 15:56:01 +0000418
419/**
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000420 * Specify this as \a stack_size argument in #pj_thread_create() to specify
421 * that thread should use default stack size for the current platform.
422 *
423 * Default: 8192
424 */
425#ifndef PJ_THREAD_DEFAULT_STACK_SIZE
426# define PJ_THREAD_DEFAULT_STACK_SIZE 8192
427#endif
428
429
430/**
Benny Prijono467edf02008-01-02 07:56:38 +0000431 * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of
432 * the stack. The OS implementation may check that no stack overflow
433 * occurs, and it also may collect statistic about stack usage. Note
434 * that this will increase the footprint of the libraries since it
435 * tracks the filename and line number of each functions.
436 */
437#ifndef PJ_OS_HAS_CHECK_STACK
438# define PJ_OS_HAS_CHECK_STACK 0
439#endif
440
441/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000442 * Do we have alternate pool implementation?
443 *
444 * Default: 0
445 */
446#ifndef PJ_HAS_POOL_ALT_API
447# define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
448#endif
449
450
Benny Prijono9033e312005-11-21 02:08:39 +0000451/**
Benny Prijono9033e312005-11-21 02:08:39 +0000452 * Support TCP in the library.
453 * Disabling TCP will reduce the footprint slightly (about 6KB).
454 *
455 * Default: 1
456 */
457#ifndef PJ_HAS_TCP
458# define PJ_HAS_TCP 1
459#endif
460
461/**
Benny Prijonoc16c6e32007-11-18 14:53:47 +0000462 * Support IPv6 in the library. If this support is disabled, some IPv6
463 * related functions will return PJ_EIPV6NOTSUP.
464 *
465 * Default: 0 (disabled, for now)
466 */
467#ifndef PJ_HAS_IPV6
468# define PJ_HAS_IPV6 0
469#endif
470
471 /**
Benny Prijono9033e312005-11-21 02:08:39 +0000472 * Maximum hostname length.
473 * Libraries sometimes needs to make copy of an address to stack buffer;
474 * the value here affects the stack usage.
475 *
476 * Default: 128
477 */
478#ifndef PJ_MAX_HOSTNAME
479# define PJ_MAX_HOSTNAME (128)
480#endif
481
482/**
483 * Constants for declaring the maximum handles that can be supported by
484 * a single IOQ framework. This constant might not be relevant to the
485 * underlying I/O queue impelementation, but still, developers should be
486 * aware of this constant, to make sure that the program will not break when
487 * the underlying implementation changes.
488 *
489 * For implementation based on select(), the value here will be used as the
490 * maximum number of socket handles passed to select() (i.e. FD_SETSIZE will
491 * be set to this value).
492 *
Benny Prijonoe67d99a2006-03-20 12:39:24 +0000493 * Default: if FD_SETSIZE is defined and the value is greather than 256,
494 * then it will be used. Otherwise 256 (64 for WinCE).
Benny Prijono9033e312005-11-21 02:08:39 +0000495 */
496#ifndef PJ_IOQUEUE_MAX_HANDLES
Benny Prijono11852992006-03-18 12:28:03 +0000497# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
498# define PJ_IOQUEUE_MAX_HANDLES (64)
499# else
500# define PJ_IOQUEUE_MAX_HANDLES (256)
501# endif
Benny Prijono9033e312005-11-21 02:08:39 +0000502#endif
503
Benny Prijono8508aa02006-03-30 15:56:01 +0000504
505/**
506 * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
507 * things to ensure thread safety of handle unregistration operation by
508 * employing reference counter to each handle.
509 *
510 * In addition, the ioqueue will preallocate memory for the handles,
511 * according to the maximum number of handles that is specified during
512 * ioqueue creation.
513 *
514 * All applications would normally want this enabled, but you may disable
515 * this if:
516 * - there is no dynamic unregistration to all ioqueues.
517 * - there is no threading, or there is no preemptive multitasking.
518 *
519 * Default: 1
520 */
521#ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
522# define PJ_IOQUEUE_HAS_SAFE_UNREG 1
523#endif
524
525
526/**
527 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
528 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
529 * ioqueue key is kept in closing state before it can be reused.
530 *
531 * The value is in miliseconds.
532 *
533 * Default: 500 msec.
534 */
535#ifndef PJ_IOQUEUE_KEY_FREE_DELAY
536# define PJ_IOQUEUE_KEY_FREE_DELAY 500
537#endif
538
539
Benny Prijono9033e312005-11-21 02:08:39 +0000540/**
541 * Overrides FD_SETSIZE so it is consistent throughout the library.
542 * OS specific configuration header (compat/os_*) might have declared
543 * FD_SETSIZE, thus we only set if it hasn't been declared.
544 *
545 * Default: #PJ_IOQUEUE_MAX_HANDLES
546 */
547#ifndef FD_SETSIZE
548# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
549#endif
550
551/**
552 * Has semaphore functionality?
553 *
554 * Default: 1
555 */
556#ifndef PJ_HAS_SEMAPHORE
557# define PJ_HAS_SEMAPHORE 1
558#endif
559
560
561/**
562 * Event object (for synchronization, e.g. in Win32)
563 *
564 * Default: 1
565 */
566#ifndef PJ_HAS_EVENT_OBJ
567# define PJ_HAS_EVENT_OBJ 1
568#endif
569
570
571/**
Benny Prijonoa66c3312007-01-21 23:12:40 +0000572 * Maximum file name length.
573 */
574#ifndef PJ_MAXPATH
575# define PJ_MAXPATH 260
576#endif
577
578
579/**
Benny Prijono9033e312005-11-21 02:08:39 +0000580 * Enable library's extra check.
581 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
582 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
583 * will simply evaluate to #pj_assert().
584 *
585 * You can disable this macro to reduce size, at the risk of crashes
586 * if invalid value (e.g. NULL) is passed to the library.
587 *
588 * Default: 1
589 */
590#ifndef PJ_ENABLE_EXTRA_CHECK
591# define PJ_ENABLE_EXTRA_CHECK 1
592#endif
593
594
595/**
596 * Enable name registration for exceptions with #pj_exception_id_alloc().
597 * If this feature is enabled, then the library will keep track of
598 * names associated with each exception ID requested by application via
599 * #pj_exception_id_alloc().
600 *
601 * Disabling this macro will reduce the code and .bss size by a tad bit.
602 * See also #PJ_MAX_EXCEPTION_ID.
603 *
604 * Default: 1
605 */
606#ifndef PJ_HAS_EXCEPTION_NAMES
607# define PJ_HAS_EXCEPTION_NAMES 1
608#endif
609
610/**
611 * Maximum number of unique exception IDs that can be requested
612 * with #pj_exception_id_alloc(). For each entry, a small record will
613 * be allocated in the .bss segment.
614 *
615 * Default: 16
616 */
617#ifndef PJ_MAX_EXCEPTION_ID
618# define PJ_MAX_EXCEPTION_ID 16
619#endif
620
Benny Prijono99683ae2005-11-21 16:59:47 +0000621/**
622 * Should we use Windows Structured Exception Handling (SEH) for the
623 * PJLIB exceptions.
624 *
625 * Default: 0
626 */
627#ifndef PJ_EXCEPTION_USE_WIN32_SEH
628# define PJ_EXCEPTION_USE_WIN32_SEH 0
629#endif
630
631/**
632 * Should we attempt to use Pentium's rdtsc for high resolution
633 * timestamp.
634 *
635 * Default: 0
636 */
637#ifndef PJ_TIMESTAMP_USE_RDTSC
638# define PJ_TIMESTAMP_USE_RDTSC 0
639#endif
640
Benny Prijono11852992006-03-18 12:28:03 +0000641/**
Benny Prijono5d542642007-05-02 18:54:19 +0000642 * Is native platform error positive number?
643 * Default: 1 (yes)
644 */
645#ifndef PJ_NATIVE_ERR_POSITIVE
646# define PJ_NATIVE_ERR_POSITIVE 1
647#endif
648
649/**
Benny Prijono11852992006-03-18 12:28:03 +0000650 * Include error message string in the library (pj_strerror()).
651 * This is very much desirable!
652 *
653 * Default: 1
654 */
655#ifndef PJ_HAS_ERROR_STRING
656# define PJ_HAS_ERROR_STRING 1
657#endif
658
Benny Prijono99683ae2005-11-21 16:59:47 +0000659
Benny Prijonodcf29962006-03-23 18:03:40 +0000660/**
661 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
662 * functions to compare alnum strings. On some systems, they're faster
663 * then stricmp/strcasecmp, but they can be slower on other systems.
664 * When disabled, pjlib will fallback to stricmp/strnicmp.
665 *
666 * Default: 0
667 */
668#ifndef PJ_HAS_STRICMP_ALNUM
669# define PJ_HAS_STRICMP_ALNUM 0
670#endif
671
Benny Prijono9033e312005-11-21 02:08:39 +0000672/** @} */
673
674/********************************************************************
675 * General macros.
676 */
677
678/**
Benny Prijono31ff4d32007-11-23 03:49:20 +0000679 * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO)
680 * @ingroup pj_config
681 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000682 *
683 * The libraries support generation of dynamic link libraries for
Benny Prijono31ff4d32007-11-23 03:49:20 +0000684 * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian
685 * terms). Similar procedures may be applied for Win32 DLL with some
686 * modification.
687 *
688 * Depending on the platforms, these steps may be necessary in order to
689 * produce the dynamic libraries:
690 * - Create the (Visual Studio) projects to produce DLL output. PJLIB
691 * does not provide ready to use project files to produce DLL, so
692 * you need to create these projects yourself. For Symbian, the MMP
693 * files have been setup to produce DSO files for targets that
694 * require them.
695 * - In the (Visual Studio) projects, some macros need to be declared
696 * so that appropriate modifiers are added to symbol declarations
697 * and definitions. Please see the macro section below for information
698 * regarding these macros. For Symbian, these have been taken care by the
699 * MMP files.
700 * - Some build systems require .DEF file to be specified when creating
701 * the DLL. For Symbian, .DEF files are included in pjlib distribution,
702 * in <tt>pjlib/build.symbian</tt> directory. These DEF files are
703 * created by running <tt>./makedef.sh all</tt> from this directory,
704 * inside Mingw.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000705 *
706 * Macros related for building DLL/DSO files:
707 * - For platforms that supports dynamic link libraries generation,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000708 * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000709 * the prefix to be added to symbol definition, to export this
710 * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000711 * value of this macro is \a __declspec(dllexport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000712 * ABIv2/Symbian, the value is \a EXPORT_C.
713 * - For platforms that supports linking with dynamic link libraries,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000714 * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000715 * the prefix to be added to symbol declaration, to import this
716 * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000717 * value of this macro is \a __declspec(dllimport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000718 * ABIv2/Symbian, the value is \a IMPORT_C.
Benny Prijono31ff4d32007-11-23 03:49:20 +0000719 * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt>
720 * macros above can be declared in your \a config_site.h if they are not
721 * declared by pjlib.
722 * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and
723 * <tt>PJ_EXPORTING</tt> macros must be declared, so that
724 * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function
725 * definition.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000726 * - When application wants to link dynamically with PJLIB, then it
Benny Prijono31ff4d32007-11-23 03:49:20 +0000727 * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header,
728 * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into
729 * symbol declarations.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000730 *
Benny Prijono31ff4d32007-11-23 03:49:20 +0000731 * When <b>PJ_DLL</b> macro is not declared, static linking is assumed.
732 *
733 * For example, here are some settings to produce DLLs with Visual Studio
734 * on Windows/Win32:
735 * - Create Visual Studio projects to produce DLL. Add the appropriate
736 * project dependencies to avoid link errors.
737 * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt>
738 * macros.
739 * - Declare these macros in your <tt>config_site.h</tt>:
740 \verbatim
741 #define PJ_EXPORT_SPECIFIER __declspec(dllexport)
742 #define PJ_IMPORT_SPECIFIER __declspec(dllimport)
743 \endverbatim
744 * - And in the application (that links with the DLL) project, add
745 * <tt>PJ_DLL</tt> in the macro declarations.
746 */
747
748/** @} */
749
750/**
751 * @defgroup pj_config Build Configuration
752 * @ingroup PJ
753 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000754 */
755
756/**
Benny Prijono9033e312005-11-21 02:08:39 +0000757 * @def PJ_INLINE(type)
758 * @param type The return type of the function.
759 * Expand the function as inline.
760 */
761#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
762
763/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000764 * This macro declares platform/compiler specific specifier prefix
765 * to be added to symbol declaration to export the symbol when PJLIB
766 * is built as dynamic library.
767 *
768 * This macro should have been added by platform specific headers,
769 * if the platform supports building dynamic library target.
770 */
771#ifndef PJ_EXPORT_DECL_SPECIFIER
772# define PJ_EXPORT_DECL_SPECIFIER
773#endif
774
775
776/**
777 * This macro declares platform/compiler specific specifier prefix
778 * to be added to symbol definition to export the symbol when PJLIB
779 * is built as dynamic library.
780 *
781 * This macro should have been added by platform specific headers,
782 * if the platform supports building dynamic library target.
783 */
784#ifndef PJ_EXPORT_DEF_SPECIFIER
785# define PJ_EXPORT_DEF_SPECIFIER
786#endif
787
788
789/**
790 * This macro declares platform/compiler specific specifier prefix
791 * to be added to symbol declaration to import the symbol.
792 *
793 * This macro should have been added by platform specific headers,
794 * if the platform supports building dynamic library target.
795 */
796#ifndef PJ_IMPORT_DECL_SPECIFIER
797# define PJ_IMPORT_DECL_SPECIFIER
798#endif
799
800
801/**
802 * This macro has been deprecated. It will evaluate to nothing.
803 */
804#ifndef PJ_EXPORT_SYMBOL
805# define PJ_EXPORT_SYMBOL(x)
806#endif
807
808
809/**
810 * @def PJ_DECL(type)
811 * @param type The return type of the function.
812 * Declare a function.
813 */
814#if defined(PJ_DLL)
815# if defined(PJ_EXPORTING)
816# define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
817# else
818# define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
819# endif
820#elif !defined(PJ_DECL)
821# if defined(__cplusplus)
822# define PJ_DECL(type) type
823# else
824# define PJ_DECL(type) extern type
825# endif
826#endif
827
828
Benny Prijono9033e312005-11-21 02:08:39 +0000829/**
830 * @def PJ_DEF(type)
831 * @param type The return type of the function.
832 * Define a function.
833 */
Benny Prijono8ab968f2007-07-20 08:08:30 +0000834#if defined(PJ_DLL) && defined(PJ_EXPORTING)
835# define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
836#elif !defined(PJ_DEF)
837# define PJ_DEF(type) type
838#endif
839
Benny Prijono9033e312005-11-21 02:08:39 +0000840
841/**
Benny Prijono225b2222007-11-16 03:49:01 +0000842 * @def PJ_DECL_NO_RETURN(type)
843 * @param type The return type of the function.
844 * Declare a function that will not return.
845 */
846/**
Benny Prijonoa7b376b2008-01-25 16:06:33 +0000847 * @def PJ_IDECL_NO_RETURN(type)
848 * @param type The return type of the function.
849 * Declare an inline function that will not return.
850 */
851/**
Benny Prijono225b2222007-11-16 03:49:01 +0000852 * @def PJ_BEGIN_DECL
853 * Mark beginning of declaration section in a header file.
854 */
855/**
856 * @def PJ_END_DECL
857 * Mark end of declaration section in a header file.
858 */
859#ifdef __cplusplus
860# define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
861# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
862# define PJ_BEGIN_DECL extern "C" {
863# define PJ_END_DECL }
864#else
865# define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
866# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
867# define PJ_BEGIN_DECL
868# define PJ_END_DECL
869#endif
870
871
872
873/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000874 * @def PJ_DECL_DATA(type)
875 * @param type The data type.
876 * Declare a global data.
877 */
878#if defined(PJ_DLL)
879# if defined(PJ_EXPORTING)
880# define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
881# else
882# define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
883# endif
884#elif !defined(PJ_DECL_DATA)
885# define PJ_DECL_DATA(type) extern type
Benny Prijono9033e312005-11-21 02:08:39 +0000886#endif
887
Benny Prijono8ab968f2007-07-20 08:08:30 +0000888
889/**
890 * @def PJ_DEF_DATA(type)
891 * @param type The data type.
892 * Define a global data.
893 */
894#if defined(PJ_DLL) && defined(PJ_EXPORTING)
895# define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
896#elif !defined(PJ_DEF_DATA)
897# define PJ_DEF_DATA(type) type
898#endif
899
900
Benny Prijono9033e312005-11-21 02:08:39 +0000901/**
902 * @def PJ_IDECL(type)
903 * @param type The function's return type.
904 * Declare a function that may be expanded as inline.
905 */
906/**
907 * @def PJ_IDEF(type)
908 * @param type The function's return type.
909 * Define a function that may be expanded as inline.
910 */
911
912#if PJ_FUNCTIONS_ARE_INLINED
913# define PJ_IDECL(type) PJ_INLINE(type)
914# define PJ_IDEF(type) PJ_INLINE(type)
915#else
916# define PJ_IDECL(type) PJ_DECL(type)
917# define PJ_IDEF(type) PJ_DEF(type)
918#endif
919
Benny Prijono8ab968f2007-07-20 08:08:30 +0000920
Benny Prijono9033e312005-11-21 02:08:39 +0000921/**
922 * @def PJ_UNUSED_ARG(arg)
923 * @param arg The argument name.
924 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
925 */
926#define PJ_UNUSED_ARG(arg) (void)arg
927
928/**
929 * @def PJ_TODO(id)
930 * @param id Any identifier that will be printed as TODO message.
931 * PJ_TODO macro will display TODO message as warning during compilation.
932 * Example: PJ_TODO(CLEAN_UP_ERROR);
933 */
934#ifndef PJ_TODO
935# define PJ_TODO(id) TODO___##id:
936#endif
937
938/**
939 * Function attributes to inform that the function may throw exception.
940 *
941 * @param x The exception list, enclosed in parenthesis.
942 */
943#define __pj_throw__(x)
944
Benny Prijono31ff4d32007-11-23 03:49:20 +0000945/** @} */
Benny Prijono9033e312005-11-21 02:08:39 +0000946
947/********************************************************************
948 * Sanity Checks
949 */
950#ifndef PJ_HAS_HIGH_RES_TIMER
951# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
952#endif
953
954#if !defined(PJ_HAS_PENTIUM)
955# error "PJ_HAS_PENTIUM is not defined!"
956#endif
957
958#if !defined(PJ_IS_LITTLE_ENDIAN)
959# error "PJ_IS_LITTLE_ENDIAN is not defined!"
960#endif
961
962#if !defined(PJ_IS_BIG_ENDIAN)
963# error "PJ_IS_BIG_ENDIAN is not defined!"
964#endif
965
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000966#if !defined(PJ_EMULATE_RWMUTEX)
967# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
968#endif
Benny Prijono9033e312005-11-21 02:08:39 +0000969
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000970#if !defined(PJ_THREAD_SET_STACK_SIZE)
971# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
972#endif
973
974#if !defined(PJ_THREAD_ALLOCATE_STACK)
975# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
976#endif
Benny Prijono9033e312005-11-21 02:08:39 +0000977
978PJ_BEGIN_DECL
979
980/**
Benny Prijonod51a37a2007-07-28 02:44:55 +0000981 * PJLIB version string constant. @see pj_get_version()
Benny Prijono9033e312005-11-21 02:08:39 +0000982 */
Benny Prijonod51a37a2007-07-28 02:44:55 +0000983PJ_DECL_DATA(const char*) PJ_VERSION;
984
985/**
986 * Get PJLIB version string.
987 *
988 * @return #PJ_VERSION constant.
989 */
990PJ_DECL(const char*) pj_get_version(void);
Benny Prijono9033e312005-11-21 02:08:39 +0000991
992/**
993 * Dump configuration to log with verbosity equal to info(3).
994 */
995PJ_DECL(void) pj_dump_config(void);
996
997PJ_END_DECL
998
999
1000#endif /* __PJ_CONFIG_H__ */
1001