blob: ec21a5299dd1b00c459bd56f5d47d01a4404e4a3 [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 */
42#if defined(PJ_WIN32) && PJ_WIN32!=0
43# include <pj/compat/os_win32.h>
44#elif defined(PJ_LINUX) && PJ_LINUX!=0
45# include <pj/compat/os_linux.h>
46#elif defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL!=0
47# include <pj/compat/os_linux_kernel.h>
48#elif defined(PJ_PALMOS) && PJ_PALMOS!=0
49# include <pj/compat/os_palmos.h>
50#elif defined(PJ_SUNOS) && PJ_SUNOS!=0
51# include <pj/compat/os_sunos.h>
52#else
53# error "Please specify target os."
54#endif
55
56
57/********************************************************************
58 * Target machine specific configuration.
59 */
60#if defined (PJ_M_I386) && PJ_M_I386 != 0
61# include <pj/compat/m_i386.h>
62#elif defined (PJ_M_M68K) && PJ_M_M68K != 0
63# include <pj/compat/m_m68k.h>
64#elif defined (PJ_M_ALPHA) && PJ_M_ALPHA != 0
65# include <pj/compat/m_alpha.h>
66#elif defined (PJ_M_SPARC) && PJ_M_SPARC != 0
67# include <pj/compat/m_sparc.h>
68#else
69# error "Please specify target machine."
70#endif
71
72/* Include size_t definition. */
73#include <pj/compat/size_t.h>
74
75/* Include site/user specific configuration to control PJLIB features.
76 * YOU MUST CREATE THIS FILE YOURSELF!!
77 */
78#include <pj/config_site.h>
79
80/********************************************************************
81 * PJLIB Features.
82 */
83
84/* Overrides for DOXYGEN */
85#ifdef DOXYGEN
86# undef PJ_FUNCTIONS_ARE_INLINED
87# undef PJ_HAS_FLOATING_POINT
88# undef PJ_LOG_MAX_LEVEL
89# undef PJ_LOG_MAX_SIZE
90# undef PJ_LOG_USE_STACK_BUFFER
91# undef PJ_TERM_HAS_COLOR
92# undef PJ_POOL_DEBUG
93# undef PJ_HAS_TCP
94# undef PJ_MAX_HOSTNAME
95# undef PJ_IOQUEUE_MAX_HANDLES
96# undef FD_SETSIZE
97# undef PJ_HAS_SEMAPHORE
98# undef PJ_HAS_EVENT_OBJ
99# undef PJ_ENABLE_EXTRA_CHECK
Benny Prijono99683ae2005-11-21 16:59:47 +0000100# undef PJ_EXCEPTION_USE_WIN32_SEH
Benny Prijono9033e312005-11-21 02:08:39 +0000101#endif
102
103/**
104 * @defgroup pj_config Build Configuration
105 * @ingroup PJ
106 * @{
107 *
108 * This section contains macros that can set during PJLIB build process
109 * to controll various aspects of the library.
110 *
111 * <b>Note</b>: the values in this page does NOT necessarily reflect to the
112 * macro values during the build process.
113 */
114
115/**
116 * If this macro is set to 1, it will enable some debugging checking
117 * in the library.
118 *
119 * Default: equal to (NOT NDEBUG).
120 */
121#ifndef PJ_DEBUG
122# ifndef NDEBUG
123# define PJ_DEBUG 1
124# else
125# define PJ_DEBUG 0
126# endif
127#endif
128
129/**
130 * Expand functions in *_i.h header files as inline.
131 *
132 * Default: 0.
133 */
134#ifndef PJ_FUNCTIONS_ARE_INLINED
135# define PJ_FUNCTIONS_ARE_INLINED 0
136#endif
137
138/**
139 * Use floating point computations in the library.
140 *
141 * Default: 1.
142 */
143#ifndef PJ_HAS_FLOATING_POINT
144# define PJ_HAS_FLOATING_POINT 1
145#endif
146
147/**
148 * Declare maximum logging level/verbosity. Lower number indicates higher
149 * importance, with the highest importance has level zero. The least
150 * important level is five in this implementation, but this can be extended
151 * by supplying the appropriate implementation.
152 *
153 * The level conventions:
154 * - 0: fatal error
155 * - 1: error
156 * - 2: warning
157 * - 3: info
158 * - 4: debug
159 * - 5: trace
160 * - 6: more detailed trace
161 *
162 * Default: 4
163 */
164#ifndef PJ_LOG_MAX_LEVEL
165# define PJ_LOG_MAX_LEVEL 5
166#endif
167
168/**
169 * Maximum message size that can be sent to output device for each call
170 * to PJ_LOG(). If the message size is longer than this value, it will be cut.
171 * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
172 * flag is set.
173 *
174 * Default: 800
175 */
176#ifndef PJ_LOG_MAX_SIZE
177# define PJ_LOG_MAX_SIZE 800
178#endif
179
180/**
181 * Log buffer.
182 * Does the log get the buffer from the stack? (default is yes).
183 * If the value is set to NO, then the buffer will be taken from static
184 * buffer, which in this case will make the log function non-reentrant.
185 *
186 * Default: 1
187 */
188#ifndef PJ_LOG_USE_STACK_BUFFER
189# define PJ_LOG_USE_STACK_BUFFER 1
190#endif
191
192
193/**
194 * Colorfull terminal (for logging etc).
195 *
196 * Default: 1
197 */
198#ifndef PJ_TERM_HAS_COLOR
199# define PJ_TERM_HAS_COLOR 1
200#endif
201
202/**
203 * Pool debugging.
204 *
205 * Default: 0
206 */
207#ifndef PJ_POOL_DEBUG
208# define PJ_POOL_DEBUG 0
209#endif
210
211/**
212 * \def PJ_HAS_TCP
213 * Support TCP in the library.
214 * Disabling TCP will reduce the footprint slightly (about 6KB).
215 *
216 * Default: 1
217 */
218#ifndef PJ_HAS_TCP
219# define PJ_HAS_TCP 1
220#endif
221
222/**
223 * Maximum hostname length.
224 * Libraries sometimes needs to make copy of an address to stack buffer;
225 * the value here affects the stack usage.
226 *
227 * Default: 128
228 */
229#ifndef PJ_MAX_HOSTNAME
230# define PJ_MAX_HOSTNAME (128)
231#endif
232
233/**
234 * Constants for declaring the maximum handles that can be supported by
235 * a single IOQ framework. This constant might not be relevant to the
236 * underlying I/O queue impelementation, but still, developers should be
237 * aware of this constant, to make sure that the program will not break when
238 * the underlying implementation changes.
239 *
240 * For implementation based on select(), the value here will be used as the
241 * maximum number of socket handles passed to select() (i.e. FD_SETSIZE will
242 * be set to this value).
243 *
244 * Default: 256
245 */
246#ifndef PJ_IOQUEUE_MAX_HANDLES
247# define PJ_IOQUEUE_MAX_HANDLES (256)
248#endif
249
250/**
251 * Overrides FD_SETSIZE so it is consistent throughout the library.
252 * OS specific configuration header (compat/os_*) might have declared
253 * FD_SETSIZE, thus we only set if it hasn't been declared.
254 *
255 * Default: #PJ_IOQUEUE_MAX_HANDLES
256 */
257#ifndef FD_SETSIZE
258# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
259#endif
260
261/**
262 * Has semaphore functionality?
263 *
264 * Default: 1
265 */
266#ifndef PJ_HAS_SEMAPHORE
267# define PJ_HAS_SEMAPHORE 1
268#endif
269
270
271/**
272 * Event object (for synchronization, e.g. in Win32)
273 *
274 * Default: 1
275 */
276#ifndef PJ_HAS_EVENT_OBJ
277# define PJ_HAS_EVENT_OBJ 1
278#endif
279
280
281/**
282 * Enable library's extra check.
283 * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to
284 * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN
285 * will simply evaluate to #pj_assert().
286 *
287 * You can disable this macro to reduce size, at the risk of crashes
288 * if invalid value (e.g. NULL) is passed to the library.
289 *
290 * Default: 1
291 */
292#ifndef PJ_ENABLE_EXTRA_CHECK
293# define PJ_ENABLE_EXTRA_CHECK 1
294#endif
295
296
297/**
298 * Enable name registration for exceptions with #pj_exception_id_alloc().
299 * If this feature is enabled, then the library will keep track of
300 * names associated with each exception ID requested by application via
301 * #pj_exception_id_alloc().
302 *
303 * Disabling this macro will reduce the code and .bss size by a tad bit.
304 * See also #PJ_MAX_EXCEPTION_ID.
305 *
306 * Default: 1
307 */
308#ifndef PJ_HAS_EXCEPTION_NAMES
309# define PJ_HAS_EXCEPTION_NAMES 1
310#endif
311
312/**
313 * Maximum number of unique exception IDs that can be requested
314 * with #pj_exception_id_alloc(). For each entry, a small record will
315 * be allocated in the .bss segment.
316 *
317 * Default: 16
318 */
319#ifndef PJ_MAX_EXCEPTION_ID
320# define PJ_MAX_EXCEPTION_ID 16
321#endif
322
Benny Prijono99683ae2005-11-21 16:59:47 +0000323/**
324 * Should we use Windows Structured Exception Handling (SEH) for the
325 * PJLIB exceptions.
326 *
327 * Default: 0
328 */
329#ifndef PJ_EXCEPTION_USE_WIN32_SEH
330# define PJ_EXCEPTION_USE_WIN32_SEH 0
331#endif
332
333/**
334 * Should we attempt to use Pentium's rdtsc for high resolution
335 * timestamp.
336 *
337 * Default: 0
338 */
339#ifndef PJ_TIMESTAMP_USE_RDTSC
340# define PJ_TIMESTAMP_USE_RDTSC 0
341#endif
342
343
Benny Prijono9033e312005-11-21 02:08:39 +0000344/** @} */
345
346/********************************************************************
347 * General macros.
348 */
349
350/**
351 * @def PJ_INLINE(type)
352 * @param type The return type of the function.
353 * Expand the function as inline.
354 */
355#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
356
357/**
358 * @def PJ_DECL(type)
359 * @param type The return type of the function.
360 * Declare a function.
361 */
362/**
363 * @def PJ_DECL_NO_RETURN(type)
364 * @param type The return type of the function.
365 * Declare a function that will not return.
366 */
367/**
368 * @def PJ_BEGIN_DECL
369 * Mark beginning of declaration section in a header file.
370 */
371/**
372 * @def PJ_END_DECL
373 * Mark end of declaration section in a header file.
374 */
375#ifdef __cplusplus
376# define PJ_DECL(type) type
377# define PJ_DECL_NO_RETURN(type) type PJ_NORETURN
Benny Prijono99683ae2005-11-21 16:59:47 +0000378# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
Benny Prijono9033e312005-11-21 02:08:39 +0000379# define PJ_BEGIN_DECL extern "C" {
380# define PJ_END_DECL }
381#else
382# define PJ_DECL(type) extern type
383# define PJ_DECL_NO_RETURN(type) PJ_NORETURN type
Benny Prijono99683ae2005-11-21 16:59:47 +0000384# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
Benny Prijono9033e312005-11-21 02:08:39 +0000385# define PJ_BEGIN_DECL
386# define PJ_END_DECL
387#endif
388
389/**
390 * @def PJ_DEF(type)
391 * @param type The return type of the function.
392 * Define a function.
393 */
394#define PJ_DEF(type) type
395
396/**
397 * @def PJ_EXPORT_SYMBOL(sym)
398 * @param sym The symbol to export.
399 * Export the specified symbol in compilation type that requires export
400 * (e.g. Linux kernel).
401 */
402#ifdef __PJ_EXPORT_SYMBOL
403# define PJ_EXPORT_SYMBOL(sym) __PJ_EXPORT_SYMBOL(sym)
404#else
405# define PJ_EXPORT_SYMBOL(sym)
406#endif
407
408/**
409 * @def PJ_IDECL(type)
410 * @param type The function's return type.
411 * Declare a function that may be expanded as inline.
412 */
413/**
414 * @def PJ_IDEF(type)
415 * @param type The function's return type.
416 * Define a function that may be expanded as inline.
417 */
418
419#if PJ_FUNCTIONS_ARE_INLINED
420# define PJ_IDECL(type) PJ_INLINE(type)
421# define PJ_IDEF(type) PJ_INLINE(type)
422#else
423# define PJ_IDECL(type) PJ_DECL(type)
424# define PJ_IDEF(type) PJ_DEF(type)
425#endif
426
427/**
428 * @def PJ_UNUSED_ARG(arg)
429 * @param arg The argument name.
430 * PJ_UNUSED_ARG prevents warning about unused argument in a function.
431 */
432#define PJ_UNUSED_ARG(arg) (void)arg
433
434/**
435 * @def PJ_TODO(id)
436 * @param id Any identifier that will be printed as TODO message.
437 * PJ_TODO macro will display TODO message as warning during compilation.
438 * Example: PJ_TODO(CLEAN_UP_ERROR);
439 */
440#ifndef PJ_TODO
441# define PJ_TODO(id) TODO___##id:
442#endif
443
444/**
445 * Function attributes to inform that the function may throw exception.
446 *
447 * @param x The exception list, enclosed in parenthesis.
448 */
449#define __pj_throw__(x)
450
451
452/********************************************************************
453 * Sanity Checks
454 */
455#ifndef PJ_HAS_HIGH_RES_TIMER
456# error "PJ_HAS_HIGH_RES_TIMER is not defined!"
457#endif
458
459#if !defined(PJ_HAS_PENTIUM)
460# error "PJ_HAS_PENTIUM is not defined!"
461#endif
462
463#if !defined(PJ_IS_LITTLE_ENDIAN)
464# error "PJ_IS_LITTLE_ENDIAN is not defined!"
465#endif
466
467#if !defined(PJ_IS_BIG_ENDIAN)
468# error "PJ_IS_BIG_ENDIAN is not defined!"
469#endif
470
471
472
473PJ_BEGIN_DECL
474
475/**
476 * PJLIB version string.
477 */
478extern const char *PJ_VERSION;
479
480/**
481 * Dump configuration to log with verbosity equal to info(3).
482 */
483PJ_DECL(void) pj_dump_config(void);
484
485PJ_END_DECL
486
487
488#endif /* __PJ_CONFIG_H__ */
489