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