blob: 0ceb863e30060319e21ae9f2ed3e8ad4570b42fa [file] [log] [blame]
Benny Prijono9033e312005-11-21 02:08:39 +00001/* $Id$ */
2/*
3 * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org>
4 *
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>
34#else
35# error "Unknown compiler."
36#endif
37
38
39/********************************************************************
40 * Include target OS specific configuration.
41 */
Benny Prijonoc4c8f242006-08-01 23:01:55 +000042#if defined(PJ_WIN32_WINCE) || defined(_WIN32_WCE) || defined(UNDER_CE)
43 /*
44 * Windows CE
45 */
46# undef PJ_WIN32_WINCE
47# define PJ_WIN32_WINCE 1
48# include <pj/compat/os_win32_wince.h>
49
50 /* Also define Win32 */
51# define PJ_WIN32 1
52
53#elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \
54 defined(_WIN64) || defined(WIN32) || defined(__TOS_WIN__)
55 /*
56 * Win32
57 */
58# undef PJ_WIN32
59# define PJ_WIN32 1
60# include <pj/compat/os_win32.h>
61
Benny Prijono9033e312005-11-21 02:08:39 +000062#elif defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +000063 /*
64 * Linux kernel
65 */
Benny Prijono9033e312005-11-21 02:08:39 +000066# include <pj/compat/os_linux_kernel.h>
Benny Prijonoc4c8f242006-08-01 23:01:55 +000067
68#elif defined(PJ_LINUX) || defined(linux) || defined(__linux)
69 /*
70 * Linux
71 */
72# undef PJ_LINUX
73# define PJ_LINUX 1
74# include <pj/compat/os_linux.h>
75
Benny Prijono9033e312005-11-21 02:08:39 +000076#elif defined(PJ_PALMOS) && PJ_PALMOS!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +000077 /*
78 * Palm
79 */
Benny Prijono9033e312005-11-21 02:08:39 +000080# include <pj/compat/os_palmos.h>
Benny Prijonoc4c8f242006-08-01 23:01:55 +000081
82#elif defined(PJ_SUNOS) || defined(sun) || defined(__sun)
83 /*
84 * SunOS
85 */
86# undef PJ_SUNOS
87# define PJ_SUNOS 1
88# include <pj/compat/os_sunos.h>
89
90#elif defined(PJ_DARWINOS) || defined(__MACOSX__)
91 /*
92 * MacOS X
93 */
94# undef PJ_DARWINOS
95# define PJ_DARWINOS 1
96# include <pj/compat/os_darwinos.h>
97
Benny Prijono42c5b9e2006-05-10 19:24:40 +000098#elif defined(PJ_RTEMS) && PJ_RTEMS!=0
Benny Prijonoc4c8f242006-08-01 23:01:55 +000099 /*
100 * RTEMS
101 */
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000102# include <pj/compat/os_rtems.h>
Benny Prijono9033e312005-11-21 02:08:39 +0000103#else
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000104# error "Please specify target os."
Benny Prijono9033e312005-11-21 02:08:39 +0000105#endif
106
107
108/********************************************************************
109 * Target machine specific configuration.
110 */
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000111#if defined (PJ_M_I386) || defined(_i386_) || defined(i_386_) || \
112 defined(_X86_) || defined(x86) || defined(__i386__) || \
113 defined(__i386) || defined(_M_IX86) || defined(__I86__)
114 /*
115 * Generic i386 processor family, little-endian
116 */
117# undef PJ_M_I386
118# define PJ_M_I386 1
119# define PJ_M_NAME "i386"
120# define PJ_HAS_PENTIUM 1
121# define PJ_IS_LITTLE_ENDIAN 1
122# define PJ_IS_BIG_ENDIAN 0
123
124
125#elif defined (PJ_M_X86_64) || defined(__amd64__) || defined(__amd64) || \
126 defined(__x86_64__) || defined(__x86_64)
127 /*
128 * AMD 64bit processor, little endian
129 */
130# undef PJ_M_X86_64
131# define PJ_M_X86_64 1
132# define PJ_M_NAME "x86_64"
133# define PJ_HAS_PENTIUM 1
134# define PJ_IS_LITTLE_ENDIAN 1
135# define PJ_IS_BIG_ENDIAN 0
136
137#elif defined(PJ_M_IA64) || defined(__ia64__) || defined(_IA64) || \
138 defined(__IA64__) || defined( _M_IA64)
139 /*
140 * Intel IA64 processor, little endian
141 */
142# undef PJ_M_IA64
143# define PJ_M_IA64 1
144# define PJ_M_NAME "ia64"
145# define PJ_HAS_PENTIUM 1
146# define PJ_IS_LITTLE_ENDIAN 1
147# define PJ_IS_BIG_ENDIAN 0
148
Benny Prijono9033e312005-11-21 02:08:39 +0000149#elif defined (PJ_M_M68K) && PJ_M_M68K != 0
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000150
151 /*
152 * Motorola m64k processor, little endian
153 */
154# undef PJ_M_M68K
155# define PJ_M_M68K 1
156# define PJ_M_NAME "m68k"
157# define PJ_HAS_PENTIUM 0
158# define PJ_IS_LITTLE_ENDIAN 1
159# define PJ_IS_BIG_ENDIAN 0
160
161
162#elif defined (PJ_M_ALPHA) || defined (__alpha__) || defined (__alpha) || \
163 defined (_M_ALPHA)
164 /*
165 * DEC Alpha processor, little endian
166 */
167# undef PJ_M_ALPHA
168# define PJ_M_ALPHA 1
169# define PJ_M_NAME "alpha"
170# define PJ_HAS_PENTIUM 0
171# define PJ_IS_LITTLE_ENDIAN 1
172# define PJ_IS_BIG_ENDIAN 0
173
174
Benny Prijonod79f25c2006-08-02 19:41:37 +0000175#elif defined(PJ_M_MIPS) || defined(__mips__) || defined(__mips) || \
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000176 defined(__MIPS__) || defined(MIPS) || defined(_MIPS_)
177 /*
Benny Prijonod79f25c2006-08-02 19:41:37 +0000178 * MIPS, default to little endian
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000179 */
180# undef PJ_M_MIPS
181# define PJ_M_MIPS 1
182# define PJ_M_NAME "mips"
183# define PJ_HAS_PENTIUM 0
Benny Prijonod79f25c2006-08-02 19:41:37 +0000184# if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN)
185# define PJ_IS_LITTLE_ENDIAN 1
186# define PJ_IS_BIG_ENDIAN 0
187# endif
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000188
189
190#elif defined (PJ_M_SPARC) || defined( __sparc__) || defined(__sparc)
191 /*
192 * Sun Sparc, big endian
193 */
194# undef PJ_M_SPARC
195# define PJ_M_SPARC 1
196# define PJ_M_NAME "sparc"
197# define PJ_HAS_PENTIUM 0
198# define PJ_IS_LITTLE_ENDIAN 0
199# define PJ_IS_BIG_ENDIAN 1
200
201#elif defined (PJ_M_ARMV4) || defined(ARM) || defined(_ARM_) || \
202 defined(ARMV4) || defined(__arm__)
203 /*
Benny Prijono8f9faae2006-08-04 17:18:37 +0000204 * ARM, default to little endian
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000205 */
206# undef PJ_M_ARMV4
207# define PJ_M_ARMV4 1
208# define PJ_M_NAME "armv4"
209# define PJ_HAS_PENTIUM 0
210# 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
214
215#elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \
216 defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \
217 defined(_ARCH_PPC)
218 /*
219 * PowerPC, big endian
220 */
221# undef PJ_M_POWERPC
222# define PJ_M_POWERPC 1
223# define PJ_M_NAME "powerpc"
224# define PJ_HAS_PENTIUM 0
Benny Prijonod79f25c2006-08-02 19:41:37 +0000225# define PJ_IS_LITTLE_ENDIAN 0
226# define PJ_IS_BIG_ENDIAN 1
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000227
Benny Prijono9033e312005-11-21 02:08:39 +0000228#else
Benny Prijonoc4c8f242006-08-01 23:01:55 +0000229# error "Please specify target machine."
Benny Prijono9033e312005-11-21 02:08:39 +0000230#endif
231
232/* Include size_t definition. */
233#include <pj/compat/size_t.h>
234
235/* Include site/user specific configuration to control PJLIB features.
236 * YOU MUST CREATE THIS FILE YOURSELF!!
237 */
238#include <pj/config_site.h>
239
240/********************************************************************
241 * PJLIB Features.
242 */
243
244/* Overrides for DOXYGEN */
245#ifdef DOXYGEN
246# undef PJ_FUNCTIONS_ARE_INLINED
247# undef PJ_HAS_FLOATING_POINT
248# undef PJ_LOG_MAX_LEVEL
249# undef PJ_LOG_MAX_SIZE
250# undef PJ_LOG_USE_STACK_BUFFER
251# undef PJ_TERM_HAS_COLOR
252# undef PJ_POOL_DEBUG
253# undef PJ_HAS_TCP
254# undef PJ_MAX_HOSTNAME
255# undef PJ_IOQUEUE_MAX_HANDLES
256# undef FD_SETSIZE
257# undef PJ_HAS_SEMAPHORE
258# undef PJ_HAS_EVENT_OBJ
259# undef PJ_ENABLE_EXTRA_CHECK
Benny Prijono99683ae2005-11-21 16:59:47 +0000260# undef PJ_EXCEPTION_USE_WIN32_SEH
Benny Prijono11852992006-03-18 12:28:03 +0000261# undef PJ_HAS_ERROR_STRING
Benny Prijono9033e312005-11-21 02:08:39 +0000262#endif
263
264/**
265 * @defgroup pj_config Build Configuration
266 * @ingroup PJ
267 * @{
268 *
269 * This section contains macros that can set during PJLIB build process
270 * to controll various aspects of the library.
271 *
272 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
273 * macro values during the build process.
274 */
275
276/**
277 * If this macro is set to 1, it will enable some debugging checking
278 * in the library.
279 *
280 * Default: equal to (NOT NDEBUG).
281 */
282#ifndef PJ_DEBUG
283# ifndef NDEBUG
284# define PJ_DEBUG 1
285# else
286# define PJ_DEBUG 0
287# endif
288#endif
289
290/**
291 * Expand functions in *_i.h header files as inline.
292 *
293 * Default: 0.
294 */
295#ifndef PJ_FUNCTIONS_ARE_INLINED
296# define PJ_FUNCTIONS_ARE_INLINED 0
297#endif
298
299/**
300 * Use floating point computations in the library.
301 *
302 * Default: 1.
303 */
304#ifndef PJ_HAS_FLOATING_POINT
305# define PJ_HAS_FLOATING_POINT 1
306#endif
307
308/**
309 * Declare maximum logging level/verbosity. Lower number indicates higher
310 * importance, with the highest importance has level zero. The least
311 * important level is five in this implementation, but this can be extended
312 * by supplying the appropriate implementation.
313 *
314 * The level conventions:
315 * - 0: fatal error
316 * - 1: error
317 * - 2: warning
318 * - 3: info
319 * - 4: debug
320 * - 5: trace
321 * - 6: more detailed trace
322 *
323 * Default: 4
324 */
325#ifndef PJ_LOG_MAX_LEVEL
326# define PJ_LOG_MAX_LEVEL 5
327#endif
328
329/**
330 * Maximum message size that can be sent to output device for each call
331 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
332 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
333 * flag is set.
334 *
Benny Prijonoccf95622006-02-07 18:48:01 +0000335 * Default: 1500
Benny Prijono9033e312005-11-21 02:08:39 +0000336 */
337#ifndef PJ_LOG_MAX_SIZE
Benny Prijonoccf95622006-02-07 18:48:01 +0000338# define PJ_LOG_MAX_SIZE 1500
Benny Prijono9033e312005-11-21 02:08:39 +0000339#endif
340
341/**
342 * Log buffer.
343 * Does the log get the buffer from the stack? (default is yes).
344 * If the value is set to NO, then the buffer will be taken from static
345 * buffer, which in this case will make the log function non-reentrant.
346 *
347 * Default: 1
348 */
349#ifndef PJ_LOG_USE_STACK_BUFFER
350# define PJ_LOG_USE_STACK_BUFFER 1
351#endif
352
353
354/**
355 * Colorfull terminal (for logging etc).
356 *
357 * Default: 1
358 */
359#ifndef PJ_TERM_HAS_COLOR
360# define PJ_TERM_HAS_COLOR 1
361#endif
362
Benny Prijono8508aa02006-03-30 15:56:01 +0000363
Benny Prijono9033e312005-11-21 02:08:39 +0000364/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000365 * If pool debugging is used, then each memory allocation from the pool
366 * will call malloc(), and pool will release all memory chunks when it
367 * is destroyed. This works better when memory verification programs
368 * such as Rational Purify is used.
Benny Prijono9033e312005-11-21 02:08:39 +0000369 *
370 * Default: 0
371 */
372#ifndef PJ_POOL_DEBUG
373# define PJ_POOL_DEBUG 0
374#endif
375
Benny Prijono8508aa02006-03-30 15:56:01 +0000376
377/**
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000378 * Specify this as \a stack_size argument in #pj_thread_create() to specify
379 * that thread should use default stack size for the current platform.
380 *
381 * Default: 8192
382 */
383#ifndef PJ_THREAD_DEFAULT_STACK_SIZE
384# define PJ_THREAD_DEFAULT_STACK_SIZE 8192
385#endif
386
387
388/**
Benny Prijono8508aa02006-03-30 15:56:01 +0000389 * Do we have alternate pool implementation?
390 *
391 * Default: 0
392 */
393#ifndef PJ_HAS_POOL_ALT_API
394# define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
395#endif
396
397
Benny Prijono9033e312005-11-21 02:08:39 +0000398/**
399 * \def PJ_HAS_TCP
400 * Support TCP in the library.
401 * Disabling TCP will reduce the footprint slightly (about 6KB).
402 *
403 * Default: 1
404 */
405#ifndef PJ_HAS_TCP
406# define PJ_HAS_TCP 1
407#endif
408
409/**
410 * Maximum hostname length.
411 * Libraries sometimes needs to make copy of an address to stack buffer;
412 * the value here affects the stack usage.
413 *
414 * Default: 128
415 */
416#ifndef PJ_MAX_HOSTNAME
417# define PJ_MAX_HOSTNAME (128)
418#endif
419
420/**
421 * Constants for declaring the maximum handles that can be supported by
422 * a single IOQ framework. This constant might not be relevant to the
423 * underlying I/O queue impelementation, but still, developers should be
424 * aware of this constant, to make sure that the program will not break when
425 * the underlying implementation changes.
426 *
427 * For implementation based on select(), the value here will be used as the
428 * maximum number of socket handles passed to select() (i.e. FD_SETSIZE will
429 * be set to this value).
430 *
Benny Prijonoe67d99a2006-03-20 12:39:24 +0000431 * Default: if FD_SETSIZE is defined and the value is greather than 256,
432 * then it will be used. Otherwise 256 (64 for WinCE).
Benny Prijono9033e312005-11-21 02:08:39 +0000433 */
434#ifndef PJ_IOQUEUE_MAX_HANDLES
Benny Prijono11852992006-03-18 12:28:03 +0000435# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
436# define PJ_IOQUEUE_MAX_HANDLES (64)
437# else
438# define PJ_IOQUEUE_MAX_HANDLES (256)
439# endif
Benny Prijono9033e312005-11-21 02:08:39 +0000440#endif
441
Benny Prijono8508aa02006-03-30 15:56:01 +0000442
443/**
444 * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
445 * things to ensure thread safety of handle unregistration operation by
446 * employing reference counter to each handle.
447 *
448 * In addition, the ioqueue will preallocate memory for the handles,
449 * according to the maximum number of handles that is specified during
450 * ioqueue creation.
451 *
452 * All applications would normally want this enabled, but you may disable
453 * this if:
454 * - there is no dynamic unregistration to all ioqueues.
455 * - there is no threading, or there is no preemptive multitasking.
456 *
457 * Default: 1
458 */
459#ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
460# define PJ_IOQUEUE_HAS_SAFE_UNREG 1
461#endif
462
463
464/**
465 * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
466 * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
467 * ioqueue key is kept in closing state before it can be reused.
468 *
469 * The value is in miliseconds.
470 *
471 * Default: 500 msec.
472 */
473#ifndef PJ_IOQUEUE_KEY_FREE_DELAY
474# define PJ_IOQUEUE_KEY_FREE_DELAY 500
475#endif
476
477
Benny Prijono9033e312005-11-21 02:08:39 +0000478/**
479 * Overrides FD_SETSIZE so it is consistent throughout the library.
480 * OS specific configuration header (compat/os_*) might have declared
481 * FD_SETSIZE, thus we only set if it hasn't been declared.
482 *
483 * Default: #PJ_IOQUEUE_MAX_HANDLES
484 */
485#ifndef FD_SETSIZE
486# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
487#endif
488
489/**
490 * Has semaphore functionality?
491 *
492 * Default: 1
493 */
494#ifndef PJ_HAS_SEMAPHORE
495# define PJ_HAS_SEMAPHORE 1
496#endif
497
498
499/**
500 * Event object (for synchronization, e.g. in Win32)
501 *
502 * Default: 1
503 */
504#ifndef PJ_HAS_EVENT_OBJ
505# define PJ_HAS_EVENT_OBJ 1
506#endif
507
508
509/**
510 * Enable library's extra check.
511 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
512 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
513 * will simply evaluate to #pj_assert().
514 *
515 * You can disable this macro to reduce size, at the risk of crashes
516 * if invalid value (e.g. NULL) is passed to the library.
517 *
518 * Default: 1
519 */
520#ifndef PJ_ENABLE_EXTRA_CHECK
521# define PJ_ENABLE_EXTRA_CHECK 1
522#endif
523
524
525/**
526 * Enable name registration for exceptions with #pj_exception_id_alloc().
527 * If this feature is enabled, then the library will keep track of
528 * names associated with each exception ID requested by application via
529 * #pj_exception_id_alloc().
530 *
531 * Disabling this macro will reduce the code and .bss size by a tad bit.
532 * See also #PJ_MAX_EXCEPTION_ID.
533 *
534 * Default: 1
535 */
536#ifndef PJ_HAS_EXCEPTION_NAMES
537# define PJ_HAS_EXCEPTION_NAMES 1
538#endif
539
540/**
541 * Maximum number of unique exception IDs that can be requested
542 * with #pj_exception_id_alloc(). For each entry, a small record will
543 * be allocated in the .bss segment.
544 *
545 * Default: 16
546 */
547#ifndef PJ_MAX_EXCEPTION_ID
548# define PJ_MAX_EXCEPTION_ID 16
549#endif
550
Benny Prijono99683ae2005-11-21 16:59:47 +0000551/**
552 * Should we use Windows Structured Exception Handling (SEH) for the
553 * PJLIB exceptions.
554 *
555 * Default: 0
556 */
557#ifndef PJ_EXCEPTION_USE_WIN32_SEH
558# define PJ_EXCEPTION_USE_WIN32_SEH 0
559#endif
560
561/**
562 * Should we attempt to use Pentium's rdtsc for high resolution
563 * timestamp.
564 *
565 * Default: 0
566 */
567#ifndef PJ_TIMESTAMP_USE_RDTSC
568# define PJ_TIMESTAMP_USE_RDTSC 0
569#endif
570
Benny Prijono11852992006-03-18 12:28:03 +0000571/**
572 * Include error message string in the library (pj_strerror()).
573 * This is very much desirable!
574 *
575 * Default: 1
576 */
577#ifndef PJ_HAS_ERROR_STRING
578# define PJ_HAS_ERROR_STRING 1
579#endif
580
Benny Prijono99683ae2005-11-21 16:59:47 +0000581
Benny Prijonodcf29962006-03-23 18:03:40 +0000582/**
583 * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
584 * functions to compare alnum strings. On some systems, they're faster
585 * then stricmp/strcasecmp, but they can be slower on other systems.
586 * When disabled, pjlib will fallback to stricmp/strnicmp.
587 *
588 * Default: 0
589 */
590#ifndef PJ_HAS_STRICMP_ALNUM
591# define PJ_HAS_STRICMP_ALNUM 0
592#endif
593
594
Benny Prijono9033e312005-11-21 02:08:39 +0000595/** @} */
596
597/********************************************************************
598 * General macros.
599 */
600
601/**
602 * @def PJ_INLINE(type)
603 * @param type The return type of the function.
604 * Expand the function as inline.
605 */
606#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
607
608/**
609 * @def PJ_DECL(type)
610 * @param type The return type of the function.
611 * Declare a function.
612 */
613/**
614 * @def PJ_DECL_NO_RETURN(type)
615 * @param type The return type of the function.
616 * Declare a function that will not return.
617 */
618/**
619 * @def PJ_BEGIN_DECL
620 * Mark beginning of declaration section in a header file.
621 */
622/**
623 * @def PJ_END_DECL
624 * Mark end of declaration section in a header file.
625 */
626#ifdef __cplusplus
627# define PJ_DECL(type) type
628# define PJ_DECL_NO_RETURN(type) type PJ_NORETURN
Benny Prijono99683ae2005-11-21 16:59:47 +0000629# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
Benny Prijono9033e312005-11-21 02:08:39 +0000630# define PJ_BEGIN_DECL extern "C" {
631# define PJ_END_DECL }
632#else
633# define PJ_DECL(type) extern type
634# define PJ_DECL_NO_RETURN(type) PJ_NORETURN type
Benny Prijono99683ae2005-11-21 16:59:47 +0000635# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
Benny Prijono9033e312005-11-21 02:08:39 +0000636# define PJ_BEGIN_DECL
637# define PJ_END_DECL
638#endif
639
640/**
641 * @def PJ_DEF(type)
642 * @param type The return type of the function.
643 * Define a function.
644 */
645#define PJ_DEF(type) type
646
647/**
648 * @def PJ_EXPORT_SYMBOL(sym)
649 * @param sym The symbol to export.
650 * Export the specified symbol in compilation type that requires export
651 * (e.g. Linux kernel).
652 */
653#ifdef __PJ_EXPORT_SYMBOL
654# define PJ_EXPORT_SYMBOL(sym) __PJ_EXPORT_SYMBOL(sym)
655#else
656# define PJ_EXPORT_SYMBOL(sym)
657#endif
658
659/**
660 * @def PJ_IDECL(type)
661 * @param type The function's return type.
662 * Declare a function that may be expanded as inline.
663 */
664/**
665 * @def PJ_IDEF(type)
666 * @param type The function's return type.
667 * Define a function that may be expanded as inline.
668 */
669
670#if PJ_FUNCTIONS_ARE_INLINED
671# define PJ_IDECL(type) PJ_INLINE(type)
672# define PJ_IDEF(type) PJ_INLINE(type)
673#else
674# define PJ_IDECL(type) PJ_DECL(type)
675# define PJ_IDEF(type) PJ_DEF(type)
676#endif
677
678/**
679 * @def PJ_UNUSED_ARG(arg)
680 * @param arg The argument name.
681 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
682 */
683#define PJ_UNUSED_ARG(arg) (void)arg
684
685/**
686 * @def PJ_TODO(id)
687 * @param id Any identifier that will be printed as TODO message.
688 * PJ_TODO macro will display TODO message as warning during compilation.
689 * Example: PJ_TODO(CLEAN_UP_ERROR);
690 */
691#ifndef PJ_TODO
692# define PJ_TODO(id) TODO___##id:
693#endif
694
695/**
696 * Function attributes to inform that the function may throw exception.
697 *
698 * @param x The exception list, enclosed in parenthesis.
699 */
700#define __pj_throw__(x)
701
702
703/********************************************************************
704 * Sanity Checks
705 */
706#ifndef PJ_HAS_HIGH_RES_TIMER
707# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
708#endif
709
710#if !defined(PJ_HAS_PENTIUM)
711# error "PJ_HAS_PENTIUM is not defined!"
712#endif
713
714#if !defined(PJ_IS_LITTLE_ENDIAN)
715# error "PJ_IS_LITTLE_ENDIAN is not defined!"
716#endif
717
718#if !defined(PJ_IS_BIG_ENDIAN)
719# error "PJ_IS_BIG_ENDIAN is not defined!"
720#endif
721
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000722#if !defined(PJ_EMULATE_RWMUTEX)
723# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
724#endif
Benny Prijono9033e312005-11-21 02:08:39 +0000725
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000726#if !defined(PJ_THREAD_SET_STACK_SIZE)
727# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
728#endif
729
730#if !defined(PJ_THREAD_ALLOCATE_STACK)
731# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
732#endif
Benny Prijono9033e312005-11-21 02:08:39 +0000733
734PJ_BEGIN_DECL
735
736/**
737 * PJLIB version string.
738 */
739extern const char *PJ_VERSION;
740
741/**
742 * Dump configuration to log with verbosity equal to info(3).
743 */
744PJ_DECL(void) pj_dump_config(void);
745
746PJ_END_DECL
747
748
749#endif /* __PJ_CONFIG_H__ */
750