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