blob: b12871010568deaf2b7fce75b8869a847baec93a [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 Prijono8508aa02006-03-30 15:56:01 +0000431 * Do we have alternate pool implementation?
432 *
433 * Default: 0
434 */
435#ifndef PJ_HAS_POOL_ALT_API
436# define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
437#endif
438
439
Benny Prijono9033e312005-11-21 02:08:39 +0000440/**
441 * \def PJ_HAS_TCP
442 * Support TCP in the library.
443 * Disabling TCP will reduce the footprint slightly (about 6KB).
444 *
445 * Default: 1
446 */
447#ifndef PJ_HAS_TCP
448# define PJ_HAS_TCP 1
449#endif
450
451/**
Benny Prijonoc16c6e32007-11-18 14:53:47 +0000452 * \def PJ_HAS_IPV6
453 * Support IPv6 in the library. If this support is disabled, some IPv6
454 * related functions will return PJ_EIPV6NOTSUP.
455 *
456 * Default: 0 (disabled, for now)
457 */
458#ifndef PJ_HAS_IPV6
459# define PJ_HAS_IPV6 0
460#endif
461
462 /**
Benny Prijono9033e312005-11-21 02:08:39 +0000463 * Maximum hostname length.
464 * Libraries sometimes needs to make copy of an address to stack buffer;
465 * the value here affects the stack usage.
466 *
467 * Default: 128
468 */
469#ifndef PJ_MAX_HOSTNAME
470# define PJ_MAX_HOSTNAME (128)
471#endif
472
473/**
474 * Constants for declaring the maximum handles that can be supported by
475 * a single IOQ framework. This constant might not be relevant to the
476 * underlying I/O queue impelementation, but still, developers should be
477 * aware of this constant, to make sure that the program will not break when
478 * the underlying implementation changes.
479 *
480 * For implementation based on select(), the value here will be used as the
481 * maximum number of socket handles passed to select() (i.e. FD_SETSIZE will
482 * be set to this value).
483 *
Benny Prijonoe67d99a2006-03-20 12:39:24 +0000484 * Default: if FD_SETSIZE is defined and the value is greather than 256,
485 * then it will be used. Otherwise 256 (64 for WinCE).
Benny Prijono9033e312005-11-21 02:08:39 +0000486 */
487#ifndef PJ_IOQUEUE_MAX_HANDLES
Benny Prijono11852992006-03-18 12:28:03 +0000488# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
489# define PJ_IOQUEUE_MAX_HANDLES (64)
490# else
491# define PJ_IOQUEUE_MAX_HANDLES (256)
492# endif
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/**
518 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
519 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
520 * ioqueue key is kept in closing state before it can be reused.
521 *
522 * The value is in miliseconds.
523 *
524 * Default: 500 msec.
525 */
526#ifndef PJ_IOQUEUE_KEY_FREE_DELAY
527# define PJ_IOQUEUE_KEY_FREE_DELAY 500
528#endif
529
530
Benny Prijono9033e312005-11-21 02:08:39 +0000531/**
532 * Overrides FD_SETSIZE so it is consistent throughout the library.
533 * OS specific configuration header (compat/os_*) might have declared
534 * FD_SETSIZE, thus we only set if it hasn't been declared.
535 *
536 * Default: #PJ_IOQUEUE_MAX_HANDLES
537 */
538#ifndef FD_SETSIZE
539# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
540#endif
541
542/**
543 * Has semaphore functionality?
544 *
545 * Default: 1
546 */
547#ifndef PJ_HAS_SEMAPHORE
548# define PJ_HAS_SEMAPHORE 1
549#endif
550
551
552/**
553 * Event object (for synchronization, e.g. in Win32)
554 *
555 * Default: 1
556 */
557#ifndef PJ_HAS_EVENT_OBJ
558# define PJ_HAS_EVENT_OBJ 1
559#endif
560
561
562/**
Benny Prijonoa66c3312007-01-21 23:12:40 +0000563 * Maximum file name length.
564 */
565#ifndef PJ_MAXPATH
566# define PJ_MAXPATH 260
567#endif
568
569
570/**
Benny Prijono9033e312005-11-21 02:08:39 +0000571 * Enable library's extra check.
572 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
573 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
574 * will simply evaluate to #pj_assert().
575 *
576 * You can disable this macro to reduce size, at the risk of crashes
577 * if invalid value (e.g. NULL) is passed to the library.
578 *
579 * Default: 1
580 */
581#ifndef PJ_ENABLE_EXTRA_CHECK
582# define PJ_ENABLE_EXTRA_CHECK 1
583#endif
584
585
586/**
587 * Enable name registration for exceptions with #pj_exception_id_alloc().
588 * If this feature is enabled, then the library will keep track of
589 * names associated with each exception ID requested by application via
590 * #pj_exception_id_alloc().
591 *
592 * Disabling this macro will reduce the code and .bss size by a tad bit.
593 * See also #PJ_MAX_EXCEPTION_ID.
594 *
595 * Default: 1
596 */
597#ifndef PJ_HAS_EXCEPTION_NAMES
598# define PJ_HAS_EXCEPTION_NAMES 1
599#endif
600
601/**
602 * Maximum number of unique exception IDs that can be requested
603 * with #pj_exception_id_alloc(). For each entry, a small record will
604 * be allocated in the .bss segment.
605 *
606 * Default: 16
607 */
608#ifndef PJ_MAX_EXCEPTION_ID
609# define PJ_MAX_EXCEPTION_ID 16
610#endif
611
Benny Prijono99683ae2005-11-21 16:59:47 +0000612/**
613 * Should we use Windows Structured Exception Handling (SEH) for the
614 * PJLIB exceptions.
615 *
616 * Default: 0
617 */
618#ifndef PJ_EXCEPTION_USE_WIN32_SEH
619# define PJ_EXCEPTION_USE_WIN32_SEH 0
620#endif
621
622/**
623 * Should we attempt to use Pentium's rdtsc for high resolution
624 * timestamp.
625 *
626 * Default: 0
627 */
628#ifndef PJ_TIMESTAMP_USE_RDTSC
629# define PJ_TIMESTAMP_USE_RDTSC 0
630#endif
631
Benny Prijono11852992006-03-18 12:28:03 +0000632/**
Benny Prijono5d542642007-05-02 18:54:19 +0000633 * Is native platform error positive number?
634 * Default: 1 (yes)
635 */
636#ifndef PJ_NATIVE_ERR_POSITIVE
637# define PJ_NATIVE_ERR_POSITIVE 1
638#endif
639
640/**
Benny Prijono11852992006-03-18 12:28:03 +0000641 * Include error message string in the library (pj_strerror()).
642 * This is very much desirable!
643 *
644 * Default: 1
645 */
646#ifndef PJ_HAS_ERROR_STRING
647# define PJ_HAS_ERROR_STRING 1
648#endif
649
Benny Prijono99683ae2005-11-21 16:59:47 +0000650
Benny Prijonodcf29962006-03-23 18:03:40 +0000651/**
652 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
653 * functions to compare alnum strings. On some systems, they're faster
654 * then stricmp/strcasecmp, but they can be slower on other systems.
655 * When disabled, pjlib will fallback to stricmp/strnicmp.
656 *
657 * Default: 0
658 */
659#ifndef PJ_HAS_STRICMP_ALNUM
660# define PJ_HAS_STRICMP_ALNUM 0
661#endif
662
663
Benny Prijono9033e312005-11-21 02:08:39 +0000664/** @} */
665
666/********************************************************************
667 * General macros.
668 */
669
670/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000671 * Guide for building dynamic link libraries (DLL).
672 *
673 * The libraries support generation of dynamic link libraries for
674 * Symbian ABIv2 target (.dso files, in S60 3rd Edition). Similar
675 * procedures may be applied for Win32 DLL too, with some modification.
676 *
677 * Macros related for building DLL/DSO files:
678 * - For platforms that supports dynamic link libraries generation,
679 * it must declare PJ_EXPORT_SPECIFIER macro which value contains
680 * the prefix to be added to symbol definition, to export this
681 * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
682 * value of this macro is "__declspec(dllexport)", and for ARM
683 * ABIv2/Symbian, the value is \a EXPORT_C.
684 * - For platforms that supports linking with dynamic link libraries,
685 * it must declare PJ_IMPORT_SPECIFIER macro which value contains
686 * the prefix to be added to symbol declaration, to import this
687 * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
688 * value of this macro is "__declspec(dllimport)", and for ARM
689 * ABIv2/Symbian, the value is \a IMPORT_C.
690 * - When PJLIB is built as DLL/DSO, both \a PJ_DLL and \a PJ_EXPORTING
691 * macros must be declared, so that PJ_EXPORT_SPECIFIER prefix will be
692 * added into function definition.
693 * - When application wants to link dynamically with PJLIB, then it
694 * must declare \a PJ_DLL macro when using/including PJLIB header,
695 * so that PJ_IMPORT_SPECIFIER is properly added into symbol
696 * declarations.
697 *
698 * When \a PJ_DLL macro is not declared, static linking is assumed.
699 */
700
701/**
Benny Prijono9033e312005-11-21 02:08:39 +0000702 * @def PJ_INLINE(type)
703 * @param type The return type of the function.
704 * Expand the function as inline.
705 */
706#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
707
708/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000709 * This macro declares platform/compiler specific specifier prefix
710 * to be added to symbol declaration to export the symbol when PJLIB
711 * is built as dynamic library.
712 *
713 * This macro should have been added by platform specific headers,
714 * if the platform supports building dynamic library target.
715 */
716#ifndef PJ_EXPORT_DECL_SPECIFIER
717# define PJ_EXPORT_DECL_SPECIFIER
718#endif
719
720
721/**
722 * This macro declares platform/compiler specific specifier prefix
723 * to be added to symbol definition to export the symbol when PJLIB
724 * is built as dynamic library.
725 *
726 * This macro should have been added by platform specific headers,
727 * if the platform supports building dynamic library target.
728 */
729#ifndef PJ_EXPORT_DEF_SPECIFIER
730# define PJ_EXPORT_DEF_SPECIFIER
731#endif
732
733
734/**
735 * This macro declares platform/compiler specific specifier prefix
736 * to be added to symbol declaration to import the symbol.
737 *
738 * This macro should have been added by platform specific headers,
739 * if the platform supports building dynamic library target.
740 */
741#ifndef PJ_IMPORT_DECL_SPECIFIER
742# define PJ_IMPORT_DECL_SPECIFIER
743#endif
744
745
746/**
747 * This macro has been deprecated. It will evaluate to nothing.
748 */
749#ifndef PJ_EXPORT_SYMBOL
750# define PJ_EXPORT_SYMBOL(x)
751#endif
752
753
754/**
755 * @def PJ_DECL(type)
756 * @param type The return type of the function.
757 * Declare a function.
758 */
759#if defined(PJ_DLL)
760# if defined(PJ_EXPORTING)
761# define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
762# else
763# define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
764# endif
765#elif !defined(PJ_DECL)
766# if defined(__cplusplus)
767# define PJ_DECL(type) type
768# else
769# define PJ_DECL(type) extern type
770# endif
771#endif
772
773
Benny Prijono9033e312005-11-21 02:08:39 +0000774/**
775 * @def PJ_DEF(type)
776 * @param type The return type of the function.
777 * Define a function.
778 */
Benny Prijono8ab968f2007-07-20 08:08:30 +0000779#if defined(PJ_DLL) && defined(PJ_EXPORTING)
780# define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
781#elif !defined(PJ_DEF)
782# define PJ_DEF(type) type
783#endif
784
Benny Prijono9033e312005-11-21 02:08:39 +0000785
786/**
Benny Prijono225b2222007-11-16 03:49:01 +0000787 * @def PJ_DECL_NO_RETURN(type)
788 * @param type The return type of the function.
789 * Declare a function that will not return.
790 */
791/**
792 * @def PJ_BEGIN_DECL
793 * Mark beginning of declaration section in a header file.
794 */
795/**
796 * @def PJ_END_DECL
797 * Mark end of declaration section in a header file.
798 */
799#ifdef __cplusplus
800# define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
801# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
802# define PJ_BEGIN_DECL extern "C" {
803# define PJ_END_DECL }
804#else
805# define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
806# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
807# define PJ_BEGIN_DECL
808# define PJ_END_DECL
809#endif
810
811
812
813/**
Benny Prijono8ab968f2007-07-20 08:08:30 +0000814 * @def PJ_DECL_DATA(type)
815 * @param type The data type.
816 * Declare a global data.
817 */
818#if defined(PJ_DLL)
819# if defined(PJ_EXPORTING)
820# define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
821# else
822# define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
823# endif
824#elif !defined(PJ_DECL_DATA)
825# define PJ_DECL_DATA(type) extern type
Benny Prijono9033e312005-11-21 02:08:39 +0000826#endif
827
Benny Prijono8ab968f2007-07-20 08:08:30 +0000828
829/**
830 * @def PJ_DEF_DATA(type)
831 * @param type The data type.
832 * Define a global data.
833 */
834#if defined(PJ_DLL) && defined(PJ_EXPORTING)
835# define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
836#elif !defined(PJ_DEF_DATA)
837# define PJ_DEF_DATA(type) type
838#endif
839
840
Benny Prijono9033e312005-11-21 02:08:39 +0000841/**
842 * @def PJ_IDECL(type)
843 * @param type The function's return type.
844 * Declare a function that may be expanded as inline.
845 */
846/**
847 * @def PJ_IDEF(type)
848 * @param type The function's return type.
849 * Define a function that may be expanded as inline.
850 */
851
852#if PJ_FUNCTIONS_ARE_INLINED
853# define PJ_IDECL(type) PJ_INLINE(type)
854# define PJ_IDEF(type) PJ_INLINE(type)
855#else
856# define PJ_IDECL(type) PJ_DECL(type)
857# define PJ_IDEF(type) PJ_DEF(type)
858#endif
859
Benny Prijono8ab968f2007-07-20 08:08:30 +0000860
Benny Prijono9033e312005-11-21 02:08:39 +0000861/**
862 * @def PJ_UNUSED_ARG(arg)
863 * @param arg The argument name.
864 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
865 */
866#define PJ_UNUSED_ARG(arg) (void)arg
867
868/**
869 * @def PJ_TODO(id)
870 * @param id Any identifier that will be printed as TODO message.
871 * PJ_TODO macro will display TODO message as warning during compilation.
872 * Example: PJ_TODO(CLEAN_UP_ERROR);
873 */
874#ifndef PJ_TODO
875# define PJ_TODO(id) TODO___##id:
876#endif
877
878/**
879 * Function attributes to inform that the function may throw exception.
880 *
881 * @param x The exception list, enclosed in parenthesis.
882 */
883#define __pj_throw__(x)
884
885
886/********************************************************************
887 * Sanity Checks
888 */
889#ifndef PJ_HAS_HIGH_RES_TIMER
890# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
891#endif
892
893#if !defined(PJ_HAS_PENTIUM)
894# error "PJ_HAS_PENTIUM is not defined!"
895#endif
896
897#if !defined(PJ_IS_LITTLE_ENDIAN)
898# error "PJ_IS_LITTLE_ENDIAN is not defined!"
899#endif
900
901#if !defined(PJ_IS_BIG_ENDIAN)
902# error "PJ_IS_BIG_ENDIAN is not defined!"
903#endif
904
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000905#if !defined(PJ_EMULATE_RWMUTEX)
906# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
907#endif
Benny Prijono9033e312005-11-21 02:08:39 +0000908
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000909#if !defined(PJ_THREAD_SET_STACK_SIZE)
910# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
911#endif
912
913#if !defined(PJ_THREAD_ALLOCATE_STACK)
914# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
915#endif
Benny Prijono9033e312005-11-21 02:08:39 +0000916
917PJ_BEGIN_DECL
918
919/**
Benny Prijonod51a37a2007-07-28 02:44:55 +0000920 * PJLIB version string constant. @see pj_get_version()
Benny Prijono9033e312005-11-21 02:08:39 +0000921 */
Benny Prijonod51a37a2007-07-28 02:44:55 +0000922PJ_DECL_DATA(const char*) PJ_VERSION;
923
924/**
925 * Get PJLIB version string.
926 *
927 * @return #PJ_VERSION constant.
928 */
929PJ_DECL(const char*) pj_get_version(void);
Benny Prijono9033e312005-11-21 02:08:39 +0000930
931/**
932 * Dump configuration to log with verbosity equal to info(3).
933 */
934PJ_DECL(void) pj_dump_config(void);
935
936PJ_END_DECL
937
938
939#endif /* __PJ_CONFIG_H__ */
940