blob: 22564420ec45d55da2189132d7fc2e5411a44dc3 [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 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
306 * @ingroup PJ
307 * @{
308 *
309 * This section contains macros that can set during PJLIB build process
310 * to controll various aspects of the library.
311 *
312 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
313 * macro values during the build process.
314 */
315
316/**
317 * If this macro is set to 1, it will enable some debugging checking
318 * in the library.
319 *
320 * Default: equal to (NOT NDEBUG).
321 */
322#ifndef PJ_DEBUG
323# ifndef NDEBUG
324# define PJ_DEBUG 1
325# else
326# define PJ_DEBUG 0
327# endif
328#endif
329
330/**
331 * Expand functions in *_i.h header files as inline.
332 *
333 * Default: 0.
334 */
335#ifndef PJ_FUNCTIONS_ARE_INLINED
336# define PJ_FUNCTIONS_ARE_INLINED 0
337#endif
338
339/**
340 * Use floating point computations in the library.
341 *
342 * Default: 1.
343 */
344#ifndef PJ_HAS_FLOATING_POINT
345# define PJ_HAS_FLOATING_POINT 1
346#endif
347
348/**
349 * Declare maximum logging level/verbosity. Lower number indicates higher
350 * importance, with the highest importance has level zero. The least
351 * important level is five in this implementation, but this can be extended
352 * by supplying the appropriate implementation.
353 *
354 * The level conventions:
355 * - 0: fatal error
356 * - 1: error
357 * - 2: warning
358 * - 3: info
359 * - 4: debug
360 * - 5: trace
361 * - 6: more detailed trace
362 *
363 * Default: 4
364 */
365#ifndef PJ_LOG_MAX_LEVEL
366# define PJ_LOG_MAX_LEVEL 5
367#endif
368
369/**
370 * Maximum message size that can be sent to output device for each call
371 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
372 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
373 * flag is set.
374 *
Benny Prijonodc752ca2006-09-22 16:55:42 +0000375 * Default: 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000376 */
377#ifndef PJ_LOG_MAX_SIZE
Benny Prijonodc752ca2006-09-22 16:55:42 +0000378# define PJ_LOG_MAX_SIZE 2000
Benny Prijono9033e312005-11-21 02:08:39 +0000379#endif
380
381/**
382 * Log buffer.
383 * Does the log get the buffer from the stack? (default is yes).
384 * If the value is set to NO, then the buffer will be taken from static
385 * buffer, which in this case will make the log function non-reentrant.
386 *
387 * Default: 1
388 */
389#ifndef PJ_LOG_USE_STACK_BUFFER
390# define PJ_LOG_USE_STACK_BUFFER 1
391#endif
392
393
394/**
395 * Colorfull terminal (for logging etc).
396 *
397 * Default: 1
398 */
399#ifndef PJ_TERM_HAS_COLOR
400# define PJ_TERM_HAS_COLOR 1
401#endif
402
Benny Prijono8508aa02006-03-30 15:56:01 +0000403
Benny Prijono9033e312005-11-21 02:08:39 +0000404/**
Benny Prijonoba4abc92007-06-01 07:26:21 +0000405 * Set this flag to non-zero to enable various checking for pool
406 * operations. When this flag is set, assertion must be enabled
407 * in the application.
408 *
409 * This will slow down pool creation and destruction and will add
410 * few bytes of overhead, so application would normally want to
411 * disable this feature on release build.
412 *
413 * Default: 0
414 */
415#ifndef PJ_SAFE_POOL
416# define PJ_SAFE_POOL 0
417#endif
418
419
420/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000421 * If pool debugging is used, then each memory allocation from the pool
422 * will call malloc(), and pool will release all memory chunks when it
423 * is destroyed. This works better when memory verification programs
424 * such as Rational Purify is used.
Benny Prijono9033e312005-11-21 02:08:39 +0000425 *
426 * Default: 0
427 */
428#ifndef PJ_POOL_DEBUG
429# define PJ_POOL_DEBUG 0
430#endif
431
Benny Prijono8508aa02006-03-30 15:56:01 +0000432
433/**
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000434 * Specify this as \a stack_size argument in #pj_thread_create() to specify
435 * that thread should use default stack size for the current platform.
436 *
437 * Default: 8192
438 */
439#ifndef PJ_THREAD_DEFAULT_STACK_SIZE
440# define PJ_THREAD_DEFAULT_STACK_SIZE 8192
441#endif
442
443
444/**
Benny Prijono467edf02008-01-02 07:56:38 +0000445 * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of
446 * the stack. The OS implementation may check that no stack overflow
447 * occurs, and it also may collect statistic about stack usage. Note
448 * that this will increase the footprint of the libraries since it
449 * tracks the filename and line number of each functions.
450 */
451#ifndef PJ_OS_HAS_CHECK_STACK
452# define PJ_OS_HAS_CHECK_STACK 0
453#endif
454
455/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000456 * Do we have alternate pool implementation?
457 *
458 * Default: 0
459 */
460#ifndef PJ_HAS_POOL_ALT_API
461# define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
462#endif
463
464
Benny Prijono9033e312005-11-21 02:08:39 +0000465/**
Benny Prijono9033e312005-11-21 02:08:39 +0000466 * Support TCP in the library.
467 * Disabling TCP will reduce the footprint slightly (about 6KB).
468 *
469 * Default: 1
470 */
471#ifndef PJ_HAS_TCP
472# define PJ_HAS_TCP 1
473#endif
474
475/**
Benny Prijonoc16c6e32007-11-18 14:53:47 +0000476 * Support IPv6 in the library. If this support is disabled, some IPv6
477 * related functions will return PJ_EIPV6NOTSUP.
478 *
479 * Default: 0 (disabled, for now)
480 */
481#ifndef PJ_HAS_IPV6
482# define PJ_HAS_IPV6 0
483#endif
484
485 /**
Benny Prijono9033e312005-11-21 02:08:39 +0000486 * Maximum hostname length.
487 * Libraries sometimes needs to make copy of an address to stack buffer;
488 * the value here affects the stack usage.
489 *
490 * Default: 128
491 */
492#ifndef PJ_MAX_HOSTNAME
493# define PJ_MAX_HOSTNAME (128)
494#endif
495
496/**
497 * Constants for declaring the maximum handles that can be supported by
498 * a single IOQ framework. This constant might not be relevant to the
499 * underlying I/O queue impelementation, but still, developers should be
500 * aware of this constant, to make sure that the program will not break when
501 * the underlying implementation changes.
Benny Prijono9033e312005-11-21 02:08:39 +0000502 */
503#ifndef PJ_IOQUEUE_MAX_HANDLES
Benny Prijono40fe9082008-02-08 15:21:41 +0000504# define PJ_IOQUEUE_MAX_HANDLES (64)
Benny Prijono9033e312005-11-21 02:08:39 +0000505#endif
506
Benny Prijono8508aa02006-03-30 15:56:01 +0000507
508/**
509 * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
510 * things to ensure thread safety of handle unregistration operation by
511 * employing reference counter to each handle.
512 *
513 * In addition, the ioqueue will preallocate memory for the handles,
514 * according to the maximum number of handles that is specified during
515 * ioqueue creation.
516 *
517 * All applications would normally want this enabled, but you may disable
518 * this if:
519 * - there is no dynamic unregistration to all ioqueues.
520 * - there is no threading, or there is no preemptive multitasking.
521 *
522 * Default: 1
523 */
524#ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
525# define PJ_IOQUEUE_HAS_SAFE_UNREG 1
526#endif
527
528
529/**
Benny Prijonoe3f79fd2008-02-13 15:17:28 +0000530 * Default concurrency setting for sockets/handles registered to ioqueue.
531 * This controls whether the ioqueue is allowed to call the key's callback
532 * concurrently/in parallel. The default is yes, which means that if there
533 * are more than one pending operations complete simultaneously, more
534 * than one threads may call the key's callback at the same time. This
535 * generally would promote good scalability for application, at the
536 * expense of more complexity to manage the concurrent accesses.
537 *
538 * Please see the ioqueue documentation for more info.
539 */
540#ifndef PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY
541# define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY 1
542#endif
543
544
545/* Sanity check:
546 * if ioqueue concurrency is disallowed, PJ_IOQUEUE_HAS_SAFE_UNREG
547 * must be enabled.
548 */
549#if (PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY==0) && (PJ_IOQUEUE_HAS_SAFE_UNREG==0)
550# error PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if ioqueue concurrency \
551 is disabled
552#endif
553
554
555/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000556 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
557 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
558 * ioqueue key is kept in closing state before it can be reused.
559 *
560 * The value is in miliseconds.
561 *
562 * Default: 500 msec.
563 */
564#ifndef PJ_IOQUEUE_KEY_FREE_DELAY
565# define PJ_IOQUEUE_KEY_FREE_DELAY 500
566#endif
567
568
Benny Prijono9033e312005-11-21 02:08:39 +0000569/**
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000570 * Determine if FD_SETSIZE is changeable/set-able. If so, then we will
Benny Prijono40fe9082008-02-08 15:21:41 +0000571 * set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking
572 * for Winsock.
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000573 */
Benny Prijono40fe9082008-02-08 15:21:41 +0000574#ifndef PJ_FD_SETSIZE_SETABLE
Benny Prijono57affd02008-02-18 12:22:15 +0000575# if (defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H!=0) || \
576 (defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H!=0)
Benny Prijono40fe9082008-02-08 15:21:41 +0000577# define PJ_FD_SETSIZE_SETABLE 1
578# else
579# define PJ_FD_SETSIZE_SETABLE 0
580# endif
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000581#endif
582
583/**
Benny Prijono9033e312005-11-21 02:08:39 +0000584 * Overrides FD_SETSIZE so it is consistent throughout the library.
Benny Prijono40fe9082008-02-08 15:21:41 +0000585 * We only do this if we detected that FD_SETSIZE is changeable. If
586 * FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be
587 * set to value lower than FD_SETSIZE.
Benny Prijono9033e312005-11-21 02:08:39 +0000588 */
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000589#if PJ_FD_SETSIZE_SETABLE
590 /* Only override FD_SETSIZE if the value has not been set */
591# ifndef FD_SETSIZE
592# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
593# endif
594#else
595 /* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES
596 * is lower than FD_SETSIZE value.
597 */
598# ifdef FD_SETSIZE
599# if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
600# error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE"
601# endif
602# endif
Benny Prijono9033e312005-11-21 02:08:39 +0000603#endif
604
Benny Prijono1c5f4e42008-02-07 13:11:39 +0000605
Benny Prijono9033e312005-11-21 02:08:39 +0000606/**
607 * Has semaphore functionality?
608 *
609 * Default: 1
610 */
611#ifndef PJ_HAS_SEMAPHORE
612# define PJ_HAS_SEMAPHORE 1
613#endif
614
615
616/**
617 * Event object (for synchronization, e.g. in Win32)
618 *
619 * Default: 1
620 */
621#ifndef PJ_HAS_EVENT_OBJ
622# define PJ_HAS_EVENT_OBJ 1
623#endif
624
625
626/**
Benny Prijonoa66c3312007-01-21 23:12:40 +0000627 * Maximum file name length.
628 */
629#ifndef PJ_MAXPATH
630# define PJ_MAXPATH 260
631#endif
632
633
634/**
Benny Prijono9033e312005-11-21 02:08:39 +0000635 * Enable library's extra check.
636 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
637 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
638 * will simply evaluate to #pj_assert().
639 *
640 * You can disable this macro to reduce size, at the risk of crashes
641 * if invalid value (e.g. NULL) is passed to the library.
642 *
643 * Default: 1
644 */
645#ifndef PJ_ENABLE_EXTRA_CHECK
646# define PJ_ENABLE_EXTRA_CHECK 1
647#endif
648
649
650/**
651 * Enable name registration for exceptions with #pj_exception_id_alloc().
652 * If this feature is enabled, then the library will keep track of
653 * names associated with each exception ID requested by application via
654 * #pj_exception_id_alloc().
655 *
656 * Disabling this macro will reduce the code and .bss size by a tad bit.
657 * See also #PJ_MAX_EXCEPTION_ID.
658 *
659 * Default: 1
660 */
661#ifndef PJ_HAS_EXCEPTION_NAMES
662# define PJ_HAS_EXCEPTION_NAMES 1
663#endif
664
665/**
666 * Maximum number of unique exception IDs that can be requested
667 * with #pj_exception_id_alloc(). For each entry, a small record will
668 * be allocated in the .bss segment.
669 *
670 * Default: 16
671 */
672#ifndef PJ_MAX_EXCEPTION_ID
673# define PJ_MAX_EXCEPTION_ID 16
674#endif
675
Benny Prijono99683ae2005-11-21 16:59:47 +0000676/**
677 * Should we use Windows Structured Exception Handling (SEH) for the
678 * PJLIB exceptions.
679 *
680 * Default: 0
681 */
682#ifndef PJ_EXCEPTION_USE_WIN32_SEH
683# define PJ_EXCEPTION_USE_WIN32_SEH 0
684#endif
685
686/**
687 * Should we attempt to use Pentium's rdtsc for high resolution
688 * timestamp.
689 *
690 * Default: 0
691 */
692#ifndef PJ_TIMESTAMP_USE_RDTSC
693# define PJ_TIMESTAMP_USE_RDTSC 0
694#endif
695
Benny Prijono11852992006-03-18 12:28:03 +0000696/**
Benny Prijono5d542642007-05-02 18:54:19 +0000697 * Is native platform error positive number?
698 * Default: 1 (yes)
699 */
700#ifndef PJ_NATIVE_ERR_POSITIVE
701# define PJ_NATIVE_ERR_POSITIVE 1
702#endif
703
704/**
Benny Prijono11852992006-03-18 12:28:03 +0000705 * Include error message string in the library (pj_strerror()).
706 * This is very much desirable!
707 *
708 * Default: 1
709 */
710#ifndef PJ_HAS_ERROR_STRING
711# define PJ_HAS_ERROR_STRING 1
712#endif
713
Benny Prijono99683ae2005-11-21 16:59:47 +0000714
Benny Prijonodcf29962006-03-23 18:03:40 +0000715/**
716 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
717 * functions to compare alnum strings. On some systems, they're faster
718 * then stricmp/strcasecmp, but they can be slower on other systems.
719 * When disabled, pjlib will fallback to stricmp/strnicmp.
720 *
721 * Default: 0
722 */
723#ifndef PJ_HAS_STRICMP_ALNUM
724# define PJ_HAS_STRICMP_ALNUM 0
725#endif
726
Benny Prijono9033e312005-11-21 02:08:39 +0000727/** @} */
728
729/********************************************************************
730 * General macros.
731 */
732
733/**
Benny Prijono31ff4d32007-11-23 03:49:20 +0000734 * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO)
735 * @ingroup pj_config
736 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000737 *
738 * The libraries support generation of dynamic link libraries for
Benny Prijono31ff4d32007-11-23 03:49:20 +0000739 * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian
740 * terms). Similar procedures may be applied for Win32 DLL with some
741 * modification.
742 *
743 * Depending on the platforms, these steps may be necessary in order to
744 * produce the dynamic libraries:
745 * - Create the (Visual Studio) projects to produce DLL output. PJLIB
746 * does not provide ready to use project files to produce DLL, so
747 * you need to create these projects yourself. For Symbian, the MMP
748 * files have been setup to produce DSO files for targets that
749 * require them.
750 * - In the (Visual Studio) projects, some macros need to be declared
751 * so that appropriate modifiers are added to symbol declarations
752 * and definitions. Please see the macro section below for information
753 * regarding these macros. For Symbian, these have been taken care by the
754 * MMP files.
755 * - Some build systems require .DEF file to be specified when creating
756 * the DLL. For Symbian, .DEF files are included in pjlib distribution,
757 * in <tt>pjlib/build.symbian</tt> directory. These DEF files are
758 * created by running <tt>./makedef.sh all</tt> from this directory,
759 * inside Mingw.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000760 *
761 * Macros related for building DLL/DSO files:
762 * - For platforms that supports dynamic link libraries generation,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000763 * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000764 * the prefix to be added to symbol definition, to export this
765 * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000766 * value of this macro is \a __declspec(dllexport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000767 * ABIv2/Symbian, the value is \a EXPORT_C.
768 * - For platforms that supports linking with dynamic link libraries,
Benny Prijono31ff4d32007-11-23 03:49:20 +0000769 * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains
Benny Prijono8ab968f2007-07-20 08:08:30 +0000770 * the prefix to be added to symbol declaration, to import this
771 * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
Benny Prijono31ff4d32007-11-23 03:49:20 +0000772 * value of this macro is \a __declspec(dllimport), and for ARM
Benny Prijono8ab968f2007-07-20 08:08:30 +0000773 * ABIv2/Symbian, the value is \a IMPORT_C.
Benny Prijono31ff4d32007-11-23 03:49:20 +0000774 * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt>
775 * macros above can be declared in your \a config_site.h if they are not
776 * declared by pjlib.
777 * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and
778 * <tt>PJ_EXPORTING</tt> macros must be declared, so that
779 * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function
780 * definition.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000781 * - When application wants to link dynamically with PJLIB, then it
Benny Prijono31ff4d32007-11-23 03:49:20 +0000782 * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header,
783 * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into
784 * symbol declarations.
Benny Prijono8ab968f2007-07-20 08:08:30 +0000785 *
Benny Prijono31ff4d32007-11-23 03:49:20 +0000786 * When <b>PJ_DLL</b> macro is not declared, static linking is assumed.
787 *
788 * For example, here are some settings to produce DLLs with Visual Studio
789 * on Windows/Win32:
790 * - Create Visual Studio projects to produce DLL. Add the appropriate
791 * project dependencies to avoid link errors.
792 * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt>
793 * macros.
794 * - Declare these macros in your <tt>config_site.h</tt>:
795 \verbatim
796 #define PJ_EXPORT_SPECIFIER __declspec(dllexport)
797 #define PJ_IMPORT_SPECIFIER __declspec(dllimport)
798 \endverbatim
799 * - And in the application (that links with the DLL) project, add
800 * <tt>PJ_DLL</tt> in the macro declarations.
801 */
802
803/** @} */
804
805/**
806 * @defgroup pj_config Build Configuration
807 * @ingroup PJ
808 * @{
Benny Prijono8ab968f2007-07-20 08:08:30 +0000809 */
810
811/**
Benny Prijono9033e312005-11-21 02:08:39 +0000812 * @def PJ_INLINE(type)
813 * @param type The return type of the function.
814 * Expand the function as inline.
815 */
816#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
817
818/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000819 * This macro declares platform/compiler specific specifier prefix
820 * to be added to symbol declaration to export the symbol when PJLIB
821 * is built as dynamic library.
822 *
823 * This macro should have been added by platform specific headers,
824 * if the platform supports building dynamic library target.
825 */
826#ifndef PJ_EXPORT_DECL_SPECIFIER
827# define PJ_EXPORT_DECL_SPECIFIER
828#endif
829
830
831/**
832 * This macro declares platform/compiler specific specifier prefix
833 * to be added to symbol definition to export the symbol when PJLIB
834 * is built as dynamic library.
835 *
836 * This macro should have been added by platform specific headers,
837 * if the platform supports building dynamic library target.
838 */
839#ifndef PJ_EXPORT_DEF_SPECIFIER
840# define PJ_EXPORT_DEF_SPECIFIER
841#endif
842
843
844/**
845 * This macro declares platform/compiler specific specifier prefix
846 * to be added to symbol declaration to import the symbol.
847 *
848 * This macro should have been added by platform specific headers,
849 * if the platform supports building dynamic library target.
850 */
851#ifndef PJ_IMPORT_DECL_SPECIFIER
852# define PJ_IMPORT_DECL_SPECIFIER
853#endif
854
855
856/**
857 * This macro has been deprecated. It will evaluate to nothing.
858 */
859#ifndef PJ_EXPORT_SYMBOL
860# define PJ_EXPORT_SYMBOL(x)
861#endif
862
863
864/**
865 * @def PJ_DECL(type)
866 * @param type The return type of the function.
867 * Declare a function.
868 */
869#if defined(PJ_DLL)
870# if defined(PJ_EXPORTING)
871# define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
872# else
873# define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
874# endif
875#elif !defined(PJ_DECL)
876# if defined(__cplusplus)
877# define PJ_DECL(type) type
878# else
879# define PJ_DECL(type) extern type
880# endif
881#endif
882
883
Benny Prijono9033e312005-11-21 02:08:39 +0000884/**
885 * @def PJ_DEF(type)
886 * @param type The return type of the function.
887 * Define a function.
888 */
Benny Prijono8ab968f2007-07-20 08:08:30 +0000889#if defined(PJ_DLL) && defined(PJ_EXPORTING)
890# define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
891#elif !defined(PJ_DEF)
892# define PJ_DEF(type) type
893#endif
894
Benny Prijono9033e312005-11-21 02:08:39 +0000895
896/**
Benny Prijono225b2222007-11-16 03:49:01 +0000897 * @def PJ_DECL_NO_RETURN(type)
898 * @param type The return type of the function.
899 * Declare a function that will not return.
900 */
901/**
Benny Prijonoa7b376b2008-01-25 16:06:33 +0000902 * @def PJ_IDECL_NO_RETURN(type)
903 * @param type The return type of the function.
904 * Declare an inline function that will not return.
905 */
906/**
Benny Prijono225b2222007-11-16 03:49:01 +0000907 * @def PJ_BEGIN_DECL
908 * Mark beginning of declaration section in a header file.
909 */
910/**
911 * @def PJ_END_DECL
912 * Mark end of declaration section in a header file.
913 */
914#ifdef __cplusplus
915# define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
916# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
917# define PJ_BEGIN_DECL extern "C" {
918# define PJ_END_DECL }
919#else
920# define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
921# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
922# define PJ_BEGIN_DECL
923# define PJ_END_DECL
924#endif
925
926
927
928/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000929 * @def PJ_DECL_DATA(type)
930 * @param type The data type.
931 * Declare a global data.
932 */
933#if defined(PJ_DLL)
934# if defined(PJ_EXPORTING)
935# define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
936# else
937# define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
938# endif
939#elif !defined(PJ_DECL_DATA)
940# define PJ_DECL_DATA(type) extern type
Benny Prijono9033e312005-11-21 02:08:39 +0000941#endif
942
Benny Prijono8ab968f2007-07-20 08:08:30 +0000943
944/**
945 * @def PJ_DEF_DATA(type)
946 * @param type The data type.
947 * Define a global data.
948 */
949#if defined(PJ_DLL) && defined(PJ_EXPORTING)
950# define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
951#elif !defined(PJ_DEF_DATA)
952# define PJ_DEF_DATA(type) type
953#endif
954
955
Benny Prijono9033e312005-11-21 02:08:39 +0000956/**
957 * @def PJ_IDECL(type)
958 * @param type The function's return type.
959 * Declare a function that may be expanded as inline.
960 */
961/**
962 * @def PJ_IDEF(type)
963 * @param type The function's return type.
964 * Define a function that may be expanded as inline.
965 */
966
967#if PJ_FUNCTIONS_ARE_INLINED
968# define PJ_IDECL(type) PJ_INLINE(type)
969# define PJ_IDEF(type) PJ_INLINE(type)
970#else
971# define PJ_IDECL(type) PJ_DECL(type)
972# define PJ_IDEF(type) PJ_DEF(type)
973#endif
974
Benny Prijono8ab968f2007-07-20 08:08:30 +0000975
Benny Prijono9033e312005-11-21 02:08:39 +0000976/**
977 * @def PJ_UNUSED_ARG(arg)
978 * @param arg The argument name.
979 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
980 */
981#define PJ_UNUSED_ARG(arg) (void)arg
982
983/**
984 * @def PJ_TODO(id)
985 * @param id Any identifier that will be printed as TODO message.
986 * PJ_TODO macro will display TODO message as warning during compilation.
987 * Example: PJ_TODO(CLEAN_UP_ERROR);
988 */
989#ifndef PJ_TODO
990# define PJ_TODO(id) TODO___##id:
991#endif
992
993/**
994 * Function attributes to inform that the function may throw exception.
995 *
996 * @param x The exception list, enclosed in parenthesis.
997 */
998#define __pj_throw__(x)
999
Benny Prijono31ff4d32007-11-23 03:49:20 +00001000/** @} */
Benny Prijono9033e312005-11-21 02:08:39 +00001001
1002/********************************************************************
1003 * Sanity Checks
1004 */
1005#ifndef PJ_HAS_HIGH_RES_TIMER
1006# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
1007#endif
1008
1009#if !defined(PJ_HAS_PENTIUM)
1010# error "PJ_HAS_PENTIUM is not defined!"
1011#endif
1012
1013#if !defined(PJ_IS_LITTLE_ENDIAN)
1014# error "PJ_IS_LITTLE_ENDIAN is not defined!"
1015#endif
1016
1017#if !defined(PJ_IS_BIG_ENDIAN)
1018# error "PJ_IS_BIG_ENDIAN is not defined!"
1019#endif
1020
Benny Prijono42c5b9e2006-05-10 19:24:40 +00001021#if !defined(PJ_EMULATE_RWMUTEX)
1022# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
1023#endif
Benny Prijono9033e312005-11-21 02:08:39 +00001024
Benny Prijono42c5b9e2006-05-10 19:24:40 +00001025#if !defined(PJ_THREAD_SET_STACK_SIZE)
1026# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
1027#endif
1028
1029#if !defined(PJ_THREAD_ALLOCATE_STACK)
1030# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
1031#endif
Benny Prijono9033e312005-11-21 02:08:39 +00001032
1033PJ_BEGIN_DECL
1034
1035/**
Benny Prijonod51a37a2007-07-28 02:44:55 +00001036 * PJLIB version string constant. @see pj_get_version()
Benny Prijono9033e312005-11-21 02:08:39 +00001037 */
Benny Prijonod51a37a2007-07-28 02:44:55 +00001038PJ_DECL_DATA(const char*) PJ_VERSION;
1039
1040/**
1041 * Get PJLIB version string.
1042 *
1043 * @return #PJ_VERSION constant.
1044 */
1045PJ_DECL(const char*) pj_get_version(void);
Benny Prijono9033e312005-11-21 02:08:39 +00001046
1047/**
1048 * Dump configuration to log with verbosity equal to info(3).
1049 */
1050PJ_DECL(void) pj_dump_config(void);
1051
1052PJ_END_DECL
1053
1054
1055#endif /* __PJ_CONFIG_H__ */
1056