Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 844653c | 2008-12-23 17:27:53 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PJ_CONFIG_H__ |
| 21 | #define __PJ_CONFIG_H__ |
| 22 | |
| 23 | /** |
| 24 | * @file config.h |
| 25 | * @brief PJLIB Main configuration settings. |
| 26 | */ |
| 27 | |
| 28 | /******************************************************************** |
| 29 | * Include compiler specific configuration. |
| 30 | */ |
| 31 | #if defined(_MSC_VER) |
| 32 | # include <pj/compat/cc_msvc.h> |
| 33 | #elif defined(__GNUC__) |
| 34 | # include <pj/compat/cc_gcc.h> |
Benny Prijono | f260e46 | 2007-04-30 21:03:32 +0000 | [diff] [blame] | 35 | #elif defined(__CW32__) |
| 36 | # include <pj/compat/cc_mwcc.h> |
| 37 | #elif defined(__MWERKS__) |
| 38 | # include <pj/compat/cc_codew.h> |
Benny Prijono | b2c9682 | 2007-05-03 13:31:21 +0000 | [diff] [blame] | 39 | #elif defined(__GCCE__) |
| 40 | # include <pj/compat/cc_gcce.h> |
| 41 | #elif defined(__ARMCC__) |
| 42 | # include <pj/compat/cc_armcc.h> |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 43 | #else |
| 44 | # error "Unknown compiler." |
| 45 | #endif |
| 46 | |
| 47 | |
| 48 | /******************************************************************** |
| 49 | * Include target OS specific configuration. |
| 50 | */ |
Benny Prijono | c4c61d0 | 2006-08-20 20:47:34 +0000 | [diff] [blame] | 51 | #if defined(PJ_AUTOCONF) |
| 52 | /* |
| 53 | * Autoconf |
| 54 | */ |
| 55 | # include <pj/compat/os_auto.h> |
| 56 | |
Benny Prijono | f260e46 | 2007-04-30 21:03:32 +0000 | [diff] [blame] | 57 | #elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 |
| 58 | /* |
| 59 | * SymbianOS |
| 60 | */ |
| 61 | # include <pj/compat/os_symbian.h> |
| 62 | |
Benny Prijono | c4c61d0 | 2006-08-20 20:47:34 +0000 | [diff] [blame] | 63 | #elif defined(PJ_WIN32_WINCE) || defined(_WIN32_WCE) || defined(UNDER_CE) |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 64 | /* |
| 65 | * Windows CE |
| 66 | */ |
| 67 | # undef PJ_WIN32_WINCE |
| 68 | # define PJ_WIN32_WINCE 1 |
| 69 | # include <pj/compat/os_win32_wince.h> |
| 70 | |
| 71 | /* Also define Win32 */ |
| 72 | # define PJ_WIN32 1 |
| 73 | |
| 74 | #elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \ |
| 75 | defined(_WIN64) || defined(WIN32) || defined(__TOS_WIN__) |
| 76 | /* |
| 77 | * Win32 |
| 78 | */ |
| 79 | # undef PJ_WIN32 |
| 80 | # define PJ_WIN32 1 |
| 81 | # include <pj/compat/os_win32.h> |
| 82 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 83 | #elif defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL!=0 |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 84 | /* |
| 85 | * Linux kernel |
| 86 | */ |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 87 | # include <pj/compat/os_linux_kernel.h> |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 88 | |
| 89 | #elif defined(PJ_LINUX) || defined(linux) || defined(__linux) |
| 90 | /* |
| 91 | * Linux |
| 92 | */ |
| 93 | # undef PJ_LINUX |
| 94 | # define PJ_LINUX 1 |
| 95 | # include <pj/compat/os_linux.h> |
| 96 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 97 | #elif defined(PJ_PALMOS) && PJ_PALMOS!=0 |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 98 | /* |
| 99 | * Palm |
| 100 | */ |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 101 | # include <pj/compat/os_palmos.h> |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 102 | |
| 103 | #elif defined(PJ_SUNOS) || defined(sun) || defined(__sun) |
| 104 | /* |
| 105 | * SunOS |
| 106 | */ |
| 107 | # undef PJ_SUNOS |
| 108 | # define PJ_SUNOS 1 |
| 109 | # include <pj/compat/os_sunos.h> |
| 110 | |
Benny Prijono | 5b2b445 | 2009-01-22 20:30:32 +0000 | [diff] [blame] | 111 | #elif defined(PJ_DARWINOS) || defined(__MACOSX__) || \ |
| 112 | defined (__APPLE__) || defined (__MACH__) |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 113 | /* |
| 114 | * MacOS X |
| 115 | */ |
| 116 | # undef PJ_DARWINOS |
| 117 | # define PJ_DARWINOS 1 |
| 118 | # include <pj/compat/os_darwinos.h> |
| 119 | |
Benny Prijono | 42c5b9e | 2006-05-10 19:24:40 +0000 | [diff] [blame] | 120 | #elif defined(PJ_RTEMS) && PJ_RTEMS!=0 |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 121 | /* |
| 122 | * RTEMS |
| 123 | */ |
Benny Prijono | 42c5b9e | 2006-05-10 19:24:40 +0000 | [diff] [blame] | 124 | # include <pj/compat/os_rtems.h> |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 125 | #else |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 126 | # error "Please specify target os." |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 127 | #endif |
| 128 | |
| 129 | |
| 130 | /******************************************************************** |
| 131 | * Target machine specific configuration. |
| 132 | */ |
Benny Prijono | c4c61d0 | 2006-08-20 20:47:34 +0000 | [diff] [blame] | 133 | #if defined(PJ_AUTOCONF) |
| 134 | /* |
| 135 | * Autoconf configured |
| 136 | */ |
| 137 | #include <pj/compat/m_auto.h> |
| 138 | |
| 139 | #elif defined (PJ_M_I386) || defined(_i386_) || defined(i_386_) || \ |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 140 | defined(_X86_) || defined(x86) || defined(__i386__) || \ |
| 141 | defined(__i386) || defined(_M_IX86) || defined(__I86__) |
| 142 | /* |
| 143 | * Generic i386 processor family, little-endian |
| 144 | */ |
| 145 | # undef PJ_M_I386 |
| 146 | # define PJ_M_I386 1 |
| 147 | # define PJ_M_NAME "i386" |
| 148 | # define PJ_HAS_PENTIUM 1 |
| 149 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 150 | # define PJ_IS_BIG_ENDIAN 0 |
| 151 | |
| 152 | |
| 153 | #elif defined (PJ_M_X86_64) || defined(__amd64__) || defined(__amd64) || \ |
| 154 | defined(__x86_64__) || defined(__x86_64) |
| 155 | /* |
| 156 | * AMD 64bit processor, little endian |
| 157 | */ |
| 158 | # undef PJ_M_X86_64 |
| 159 | # define PJ_M_X86_64 1 |
| 160 | # define PJ_M_NAME "x86_64" |
| 161 | # define PJ_HAS_PENTIUM 1 |
| 162 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 163 | # define PJ_IS_BIG_ENDIAN 0 |
| 164 | |
| 165 | #elif defined(PJ_M_IA64) || defined(__ia64__) || defined(_IA64) || \ |
| 166 | defined(__IA64__) || defined( _M_IA64) |
| 167 | /* |
| 168 | * Intel IA64 processor, little endian |
| 169 | */ |
| 170 | # undef PJ_M_IA64 |
| 171 | # define PJ_M_IA64 1 |
| 172 | # define PJ_M_NAME "ia64" |
| 173 | # define PJ_HAS_PENTIUM 1 |
| 174 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 175 | # define PJ_IS_BIG_ENDIAN 0 |
| 176 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 177 | #elif defined (PJ_M_M68K) && PJ_M_M68K != 0 |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 178 | |
| 179 | /* |
| 180 | * Motorola m64k processor, little endian |
| 181 | */ |
| 182 | # undef PJ_M_M68K |
| 183 | # define PJ_M_M68K 1 |
| 184 | # define PJ_M_NAME "m68k" |
| 185 | # define PJ_HAS_PENTIUM 0 |
| 186 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 187 | # define PJ_IS_BIG_ENDIAN 0 |
| 188 | |
| 189 | |
| 190 | #elif defined (PJ_M_ALPHA) || defined (__alpha__) || defined (__alpha) || \ |
| 191 | defined (_M_ALPHA) |
| 192 | /* |
| 193 | * DEC Alpha processor, little endian |
| 194 | */ |
| 195 | # undef PJ_M_ALPHA |
| 196 | # define PJ_M_ALPHA 1 |
| 197 | # define PJ_M_NAME "alpha" |
| 198 | # define PJ_HAS_PENTIUM 0 |
| 199 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 200 | # define PJ_IS_BIG_ENDIAN 0 |
| 201 | |
| 202 | |
Benny Prijono | d79f25c | 2006-08-02 19:41:37 +0000 | [diff] [blame] | 203 | #elif defined(PJ_M_MIPS) || defined(__mips__) || defined(__mips) || \ |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 204 | defined(__MIPS__) || defined(MIPS) || defined(_MIPS_) |
| 205 | /* |
Benny Prijono | d79f25c | 2006-08-02 19:41:37 +0000 | [diff] [blame] | 206 | * MIPS, default to little endian |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 207 | */ |
| 208 | # undef PJ_M_MIPS |
| 209 | # define PJ_M_MIPS 1 |
| 210 | # define PJ_M_NAME "mips" |
| 211 | # define PJ_HAS_PENTIUM 0 |
Benny Prijono | d79f25c | 2006-08-02 19:41:37 +0000 | [diff] [blame] | 212 | # if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN) |
| 213 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 214 | # define PJ_IS_BIG_ENDIAN 0 |
| 215 | # endif |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 216 | |
| 217 | |
| 218 | #elif defined (PJ_M_SPARC) || defined( __sparc__) || defined(__sparc) |
| 219 | /* |
| 220 | * Sun Sparc, big endian |
| 221 | */ |
| 222 | # undef PJ_M_SPARC |
| 223 | # define PJ_M_SPARC 1 |
| 224 | # define PJ_M_NAME "sparc" |
| 225 | # define PJ_HAS_PENTIUM 0 |
| 226 | # define PJ_IS_LITTLE_ENDIAN 0 |
| 227 | # define PJ_IS_BIG_ENDIAN 1 |
| 228 | |
| 229 | #elif defined (PJ_M_ARMV4) || defined(ARM) || defined(_ARM_) || \ |
| 230 | defined(ARMV4) || defined(__arm__) |
| 231 | /* |
Benny Prijono | 8f9faae | 2006-08-04 17:18:37 +0000 | [diff] [blame] | 232 | * ARM, default to little endian |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 233 | */ |
| 234 | # undef PJ_M_ARMV4 |
| 235 | # define PJ_M_ARMV4 1 |
| 236 | # define PJ_M_NAME "armv4" |
| 237 | # define PJ_HAS_PENTIUM 0 |
| 238 | # if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN) |
| 239 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 240 | # define PJ_IS_BIG_ENDIAN 0 |
| 241 | # endif |
| 242 | |
| 243 | #elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \ |
| 244 | defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \ |
| 245 | defined(_ARCH_PPC) |
| 246 | /* |
| 247 | * PowerPC, big endian |
| 248 | */ |
| 249 | # undef PJ_M_POWERPC |
| 250 | # define PJ_M_POWERPC 1 |
| 251 | # define PJ_M_NAME "powerpc" |
| 252 | # define PJ_HAS_PENTIUM 0 |
Benny Prijono | d79f25c | 2006-08-02 19:41:37 +0000 | [diff] [blame] | 253 | # define PJ_IS_LITTLE_ENDIAN 0 |
| 254 | # define PJ_IS_BIG_ENDIAN 1 |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 255 | |
Benny Prijono | 93713fb | 2008-05-07 13:28:06 +0000 | [diff] [blame] | 256 | #elif defined (PJ_M_NIOS2) || defined(__nios2) || defined(__nios2__) || \ |
| 257 | defined(__NIOS2__) || defined(__M_NIOS2) || defined(_ARCH_NIOS2) |
| 258 | /* |
| 259 | * Nios2, little endian |
| 260 | */ |
| 261 | # undef PJ_M_NIOS2 |
| 262 | # define PJ_M_NIOS2 1 |
| 263 | # define PJ_M_NAME "nios2" |
| 264 | # define PJ_HAS_PENTIUM 0 |
| 265 | # define PJ_IS_LITTLE_ENDIAN 1 |
| 266 | # define PJ_IS_BIG_ENDIAN 0 |
| 267 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 268 | #else |
Benny Prijono | c4c8f24 | 2006-08-01 23:01:55 +0000 | [diff] [blame] | 269 | # error "Please specify target machine." |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 270 | #endif |
| 271 | |
| 272 | /* Include size_t definition. */ |
| 273 | #include <pj/compat/size_t.h> |
| 274 | |
| 275 | /* Include site/user specific configuration to control PJLIB features. |
| 276 | * YOU MUST CREATE THIS FILE YOURSELF!! |
| 277 | */ |
| 278 | #include <pj/config_site.h> |
| 279 | |
| 280 | /******************************************************************** |
| 281 | * PJLIB Features. |
| 282 | */ |
| 283 | |
| 284 | /* Overrides for DOXYGEN */ |
| 285 | #ifdef DOXYGEN |
| 286 | # undef PJ_FUNCTIONS_ARE_INLINED |
| 287 | # undef PJ_HAS_FLOATING_POINT |
| 288 | # undef PJ_LOG_MAX_LEVEL |
| 289 | # undef PJ_LOG_MAX_SIZE |
| 290 | # undef PJ_LOG_USE_STACK_BUFFER |
| 291 | # undef PJ_TERM_HAS_COLOR |
| 292 | # undef PJ_POOL_DEBUG |
| 293 | # undef PJ_HAS_TCP |
| 294 | # undef PJ_MAX_HOSTNAME |
| 295 | # undef PJ_IOQUEUE_MAX_HANDLES |
| 296 | # undef FD_SETSIZE |
| 297 | # undef PJ_HAS_SEMAPHORE |
| 298 | # undef PJ_HAS_EVENT_OBJ |
| 299 | # undef PJ_ENABLE_EXTRA_CHECK |
Benny Prijono | 99683ae | 2005-11-21 16:59:47 +0000 | [diff] [blame] | 300 | # undef PJ_EXCEPTION_USE_WIN32_SEH |
Benny Prijono | 1185299 | 2006-03-18 12:28:03 +0000 | [diff] [blame] | 301 | # undef PJ_HAS_ERROR_STRING |
Benny Prijono | e3f79fd | 2008-02-13 15:17:28 +0000 | [diff] [blame] | 302 | |
| 303 | # define PJ_HAS_IPV6 1 |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 304 | #endif |
| 305 | |
| 306 | /** |
| 307 | * @defgroup pj_config Build Configuration |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 308 | * @{ |
| 309 | * |
| 310 | * This section contains macros that can set during PJLIB build process |
| 311 | * to controll various aspects of the library. |
| 312 | * |
| 313 | * <b>Note</b>: the values in this page does NOT necessarily reflect to the |
| 314 | * macro values during the build process. |
| 315 | */ |
| 316 | |
| 317 | /** |
| 318 | * If this macro is set to 1, it will enable some debugging checking |
| 319 | * in the library. |
| 320 | * |
| 321 | * Default: equal to (NOT NDEBUG). |
| 322 | */ |
| 323 | #ifndef PJ_DEBUG |
| 324 | # ifndef NDEBUG |
| 325 | # define PJ_DEBUG 1 |
| 326 | # else |
| 327 | # define PJ_DEBUG 0 |
| 328 | # endif |
| 329 | #endif |
| 330 | |
| 331 | /** |
| 332 | * Expand functions in *_i.h header files as inline. |
| 333 | * |
| 334 | * Default: 0. |
| 335 | */ |
| 336 | #ifndef PJ_FUNCTIONS_ARE_INLINED |
| 337 | # define PJ_FUNCTIONS_ARE_INLINED 0 |
| 338 | #endif |
| 339 | |
| 340 | /** |
| 341 | * Use floating point computations in the library. |
| 342 | * |
| 343 | * Default: 1. |
| 344 | */ |
| 345 | #ifndef PJ_HAS_FLOATING_POINT |
| 346 | # define PJ_HAS_FLOATING_POINT 1 |
| 347 | #endif |
| 348 | |
| 349 | /** |
| 350 | * Declare maximum logging level/verbosity. Lower number indicates higher |
| 351 | * importance, with the highest importance has level zero. The least |
| 352 | * important level is five in this implementation, but this can be extended |
| 353 | * by supplying the appropriate implementation. |
| 354 | * |
| 355 | * The level conventions: |
| 356 | * - 0: fatal error |
| 357 | * - 1: error |
| 358 | * - 2: warning |
| 359 | * - 3: info |
| 360 | * - 4: debug |
| 361 | * - 5: trace |
| 362 | * - 6: more detailed trace |
| 363 | * |
| 364 | * Default: 4 |
| 365 | */ |
| 366 | #ifndef PJ_LOG_MAX_LEVEL |
| 367 | # define PJ_LOG_MAX_LEVEL 5 |
| 368 | #endif |
| 369 | |
| 370 | /** |
| 371 | * Maximum message size that can be sent to output device for each call |
| 372 | * to PJ_LOG(). If the message size is longer than this value, it will be cut. |
| 373 | * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER |
| 374 | * flag is set. |
| 375 | * |
Benny Prijono | dc752ca | 2006-09-22 16:55:42 +0000 | [diff] [blame] | 376 | * Default: 2000 |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 377 | */ |
| 378 | #ifndef PJ_LOG_MAX_SIZE |
Benny Prijono | dc752ca | 2006-09-22 16:55:42 +0000 | [diff] [blame] | 379 | # define PJ_LOG_MAX_SIZE 2000 |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 380 | #endif |
| 381 | |
| 382 | /** |
| 383 | * Log buffer. |
| 384 | * Does the log get the buffer from the stack? (default is yes). |
| 385 | * If the value is set to NO, then the buffer will be taken from static |
| 386 | * buffer, which in this case will make the log function non-reentrant. |
| 387 | * |
| 388 | * Default: 1 |
| 389 | */ |
| 390 | #ifndef PJ_LOG_USE_STACK_BUFFER |
| 391 | # define PJ_LOG_USE_STACK_BUFFER 1 |
| 392 | #endif |
| 393 | |
| 394 | |
| 395 | /** |
| 396 | * Colorfull terminal (for logging etc). |
| 397 | * |
| 398 | * Default: 1 |
| 399 | */ |
| 400 | #ifndef PJ_TERM_HAS_COLOR |
| 401 | # define PJ_TERM_HAS_COLOR 1 |
| 402 | #endif |
| 403 | |
Benny Prijono | 8508aa0 | 2006-03-30 15:56:01 +0000 | [diff] [blame] | 404 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 405 | /** |
Benny Prijono | ba4abc9 | 2007-06-01 07:26:21 +0000 | [diff] [blame] | 406 | * Set this flag to non-zero to enable various checking for pool |
| 407 | * operations. When this flag is set, assertion must be enabled |
| 408 | * in the application. |
| 409 | * |
| 410 | * This will slow down pool creation and destruction and will add |
| 411 | * few bytes of overhead, so application would normally want to |
| 412 | * disable this feature on release build. |
| 413 | * |
| 414 | * Default: 0 |
| 415 | */ |
| 416 | #ifndef PJ_SAFE_POOL |
| 417 | # define PJ_SAFE_POOL 0 |
| 418 | #endif |
| 419 | |
| 420 | |
| 421 | /** |
Benny Prijono | 8508aa0 | 2006-03-30 15:56:01 +0000 | [diff] [blame] | 422 | * If pool debugging is used, then each memory allocation from the pool |
| 423 | * will call malloc(), and pool will release all memory chunks when it |
| 424 | * is destroyed. This works better when memory verification programs |
| 425 | * such as Rational Purify is used. |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 426 | * |
| 427 | * Default: 0 |
| 428 | */ |
| 429 | #ifndef PJ_POOL_DEBUG |
| 430 | # define PJ_POOL_DEBUG 0 |
| 431 | #endif |
| 432 | |
Benny Prijono | 8508aa0 | 2006-03-30 15:56:01 +0000 | [diff] [blame] | 433 | |
| 434 | /** |
Benny Prijono | 42c5b9e | 2006-05-10 19:24:40 +0000 | [diff] [blame] | 435 | * Specify this as \a stack_size argument in #pj_thread_create() to specify |
| 436 | * that thread should use default stack size for the current platform. |
| 437 | * |
| 438 | * Default: 8192 |
| 439 | */ |
| 440 | #ifndef PJ_THREAD_DEFAULT_STACK_SIZE |
| 441 | # define PJ_THREAD_DEFAULT_STACK_SIZE 8192 |
| 442 | #endif |
| 443 | |
| 444 | |
| 445 | /** |
Benny Prijono | 467edf0 | 2008-01-02 07:56:38 +0000 | [diff] [blame] | 446 | * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of |
| 447 | * the stack. The OS implementation may check that no stack overflow |
| 448 | * occurs, and it also may collect statistic about stack usage. Note |
| 449 | * that this will increase the footprint of the libraries since it |
| 450 | * tracks the filename and line number of each functions. |
| 451 | */ |
| 452 | #ifndef PJ_OS_HAS_CHECK_STACK |
| 453 | # define PJ_OS_HAS_CHECK_STACK 0 |
| 454 | #endif |
| 455 | |
| 456 | /** |
Benny Prijono | 8508aa0 | 2006-03-30 15:56:01 +0000 | [diff] [blame] | 457 | * Do we have alternate pool implementation? |
| 458 | * |
| 459 | * Default: 0 |
| 460 | */ |
| 461 | #ifndef PJ_HAS_POOL_ALT_API |
| 462 | # define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG |
| 463 | #endif |
| 464 | |
| 465 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 466 | /** |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 467 | * Support TCP in the library. |
| 468 | * Disabling TCP will reduce the footprint slightly (about 6KB). |
| 469 | * |
| 470 | * Default: 1 |
| 471 | */ |
| 472 | #ifndef PJ_HAS_TCP |
| 473 | # define PJ_HAS_TCP 1 |
| 474 | #endif |
| 475 | |
| 476 | /** |
Benny Prijono | c16c6e3 | 2007-11-18 14:53:47 +0000 | [diff] [blame] | 477 | * Support IPv6 in the library. If this support is disabled, some IPv6 |
| 478 | * related functions will return PJ_EIPV6NOTSUP. |
| 479 | * |
| 480 | * Default: 0 (disabled, for now) |
| 481 | */ |
| 482 | #ifndef PJ_HAS_IPV6 |
| 483 | # define PJ_HAS_IPV6 0 |
| 484 | #endif |
| 485 | |
| 486 | /** |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 487 | * Maximum hostname length. |
| 488 | * Libraries sometimes needs to make copy of an address to stack buffer; |
| 489 | * the value here affects the stack usage. |
| 490 | * |
| 491 | * Default: 128 |
| 492 | */ |
| 493 | #ifndef PJ_MAX_HOSTNAME |
| 494 | # define PJ_MAX_HOSTNAME (128) |
| 495 | #endif |
| 496 | |
| 497 | /** |
| 498 | * Constants for declaring the maximum handles that can be supported by |
| 499 | * a single IOQ framework. This constant might not be relevant to the |
| 500 | * underlying I/O queue impelementation, but still, developers should be |
| 501 | * aware of this constant, to make sure that the program will not break when |
| 502 | * the underlying implementation changes. |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 503 | */ |
| 504 | #ifndef PJ_IOQUEUE_MAX_HANDLES |
Benny Prijono | 40fe908 | 2008-02-08 15:21:41 +0000 | [diff] [blame] | 505 | # define PJ_IOQUEUE_MAX_HANDLES (64) |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 506 | #endif |
| 507 | |
Benny Prijono | 8508aa0 | 2006-03-30 15:56:01 +0000 | [diff] [blame] | 508 | |
| 509 | /** |
| 510 | * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more |
| 511 | * things to ensure thread safety of handle unregistration operation by |
| 512 | * employing reference counter to each handle. |
| 513 | * |
| 514 | * In addition, the ioqueue will preallocate memory for the handles, |
| 515 | * according to the maximum number of handles that is specified during |
| 516 | * ioqueue creation. |
| 517 | * |
| 518 | * All applications would normally want this enabled, but you may disable |
| 519 | * this if: |
| 520 | * - there is no dynamic unregistration to all ioqueues. |
| 521 | * - there is no threading, or there is no preemptive multitasking. |
| 522 | * |
| 523 | * Default: 1 |
| 524 | */ |
| 525 | #ifndef PJ_IOQUEUE_HAS_SAFE_UNREG |
| 526 | # define PJ_IOQUEUE_HAS_SAFE_UNREG 1 |
| 527 | #endif |
| 528 | |
| 529 | |
| 530 | /** |
Benny Prijono | e3f79fd | 2008-02-13 15:17:28 +0000 | [diff] [blame] | 531 | * Default concurrency setting for sockets/handles registered to ioqueue. |
| 532 | * This controls whether the ioqueue is allowed to call the key's callback |
| 533 | * concurrently/in parallel. The default is yes, which means that if there |
| 534 | * are more than one pending operations complete simultaneously, more |
| 535 | * than one threads may call the key's callback at the same time. This |
| 536 | * generally would promote good scalability for application, at the |
| 537 | * expense of more complexity to manage the concurrent accesses. |
| 538 | * |
| 539 | * Please see the ioqueue documentation for more info. |
| 540 | */ |
| 541 | #ifndef PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY |
| 542 | # define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY 1 |
| 543 | #endif |
| 544 | |
| 545 | |
| 546 | /* Sanity check: |
| 547 | * if ioqueue concurrency is disallowed, PJ_IOQUEUE_HAS_SAFE_UNREG |
| 548 | * must be enabled. |
| 549 | */ |
| 550 | #if (PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY==0) && (PJ_IOQUEUE_HAS_SAFE_UNREG==0) |
| 551 | # error PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if ioqueue concurrency \ |
| 552 | is disabled |
| 553 | #endif |
| 554 | |
| 555 | |
| 556 | /** |
Benny Prijono | 8508aa0 | 2006-03-30 15:56:01 +0000 | [diff] [blame] | 557 | * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in |
| 558 | * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the |
| 559 | * ioqueue key is kept in closing state before it can be reused. |
| 560 | * |
| 561 | * The value is in miliseconds. |
| 562 | * |
| 563 | * Default: 500 msec. |
| 564 | */ |
| 565 | #ifndef PJ_IOQUEUE_KEY_FREE_DELAY |
| 566 | # define PJ_IOQUEUE_KEY_FREE_DELAY 500 |
| 567 | #endif |
| 568 | |
| 569 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 570 | /** |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 571 | * Determine if FD_SETSIZE is changeable/set-able. If so, then we will |
Benny Prijono | 40fe908 | 2008-02-08 15:21:41 +0000 | [diff] [blame] | 572 | * set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking |
| 573 | * for Winsock. |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 574 | */ |
Benny Prijono | 40fe908 | 2008-02-08 15:21:41 +0000 | [diff] [blame] | 575 | #ifndef PJ_FD_SETSIZE_SETABLE |
Benny Prijono | 57affd0 | 2008-02-18 12:22:15 +0000 | [diff] [blame] | 576 | # if (defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H!=0) || \ |
| 577 | (defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H!=0) |
Benny Prijono | 40fe908 | 2008-02-08 15:21:41 +0000 | [diff] [blame] | 578 | # define PJ_FD_SETSIZE_SETABLE 1 |
| 579 | # else |
| 580 | # define PJ_FD_SETSIZE_SETABLE 0 |
| 581 | # endif |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 582 | #endif |
| 583 | |
| 584 | /** |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 585 | * Overrides FD_SETSIZE so it is consistent throughout the library. |
Benny Prijono | 40fe908 | 2008-02-08 15:21:41 +0000 | [diff] [blame] | 586 | * We only do this if we detected that FD_SETSIZE is changeable. If |
| 587 | * FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be |
| 588 | * set to value lower than FD_SETSIZE. |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 589 | */ |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 590 | #if PJ_FD_SETSIZE_SETABLE |
| 591 | /* Only override FD_SETSIZE if the value has not been set */ |
| 592 | # ifndef FD_SETSIZE |
| 593 | # define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES |
| 594 | # endif |
| 595 | #else |
| 596 | /* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES |
| 597 | * is lower than FD_SETSIZE value. |
| 598 | */ |
| 599 | # ifdef FD_SETSIZE |
| 600 | # if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE |
| 601 | # error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE" |
| 602 | # endif |
| 603 | # endif |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 604 | #endif |
| 605 | |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 606 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 607 | /** |
Benny Prijono | 1d6b895 | 2008-07-07 21:31:02 +0000 | [diff] [blame] | 608 | * Specify whether #pj_enum_ip_interface() function should exclude |
| 609 | * loopback interfaces. |
| 610 | * |
| 611 | * Default: 1 |
| 612 | */ |
| 613 | #ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF |
| 614 | # define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1 |
| 615 | #endif |
| 616 | |
| 617 | |
| 618 | /** |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 619 | * Has semaphore functionality? |
| 620 | * |
| 621 | * Default: 1 |
| 622 | */ |
| 623 | #ifndef PJ_HAS_SEMAPHORE |
| 624 | # define PJ_HAS_SEMAPHORE 1 |
| 625 | #endif |
| 626 | |
| 627 | |
| 628 | /** |
| 629 | * Event object (for synchronization, e.g. in Win32) |
| 630 | * |
| 631 | * Default: 1 |
| 632 | */ |
| 633 | #ifndef PJ_HAS_EVENT_OBJ |
| 634 | # define PJ_HAS_EVENT_OBJ 1 |
| 635 | #endif |
| 636 | |
| 637 | |
| 638 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 639 | * Maximum file name length. |
| 640 | */ |
| 641 | #ifndef PJ_MAXPATH |
| 642 | # define PJ_MAXPATH 260 |
| 643 | #endif |
| 644 | |
| 645 | |
| 646 | /** |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 647 | * Enable library's extra check. |
| 648 | * If this macro is enabled, #PJ_ASSERT_RETURN macro will expand to |
| 649 | * run-time checking. If this macro is disabled, #PJ_ASSERT_RETURN |
| 650 | * will simply evaluate to #pj_assert(). |
| 651 | * |
| 652 | * You can disable this macro to reduce size, at the risk of crashes |
| 653 | * if invalid value (e.g. NULL) is passed to the library. |
| 654 | * |
| 655 | * Default: 1 |
| 656 | */ |
| 657 | #ifndef PJ_ENABLE_EXTRA_CHECK |
| 658 | # define PJ_ENABLE_EXTRA_CHECK 1 |
| 659 | #endif |
| 660 | |
| 661 | |
| 662 | /** |
| 663 | * Enable name registration for exceptions with #pj_exception_id_alloc(). |
| 664 | * If this feature is enabled, then the library will keep track of |
| 665 | * names associated with each exception ID requested by application via |
| 666 | * #pj_exception_id_alloc(). |
| 667 | * |
| 668 | * Disabling this macro will reduce the code and .bss size by a tad bit. |
| 669 | * See also #PJ_MAX_EXCEPTION_ID. |
| 670 | * |
| 671 | * Default: 1 |
| 672 | */ |
| 673 | #ifndef PJ_HAS_EXCEPTION_NAMES |
| 674 | # define PJ_HAS_EXCEPTION_NAMES 1 |
| 675 | #endif |
| 676 | |
| 677 | /** |
| 678 | * Maximum number of unique exception IDs that can be requested |
| 679 | * with #pj_exception_id_alloc(). For each entry, a small record will |
| 680 | * be allocated in the .bss segment. |
| 681 | * |
| 682 | * Default: 16 |
| 683 | */ |
| 684 | #ifndef PJ_MAX_EXCEPTION_ID |
| 685 | # define PJ_MAX_EXCEPTION_ID 16 |
| 686 | #endif |
| 687 | |
Benny Prijono | 99683ae | 2005-11-21 16:59:47 +0000 | [diff] [blame] | 688 | /** |
| 689 | * Should we use Windows Structured Exception Handling (SEH) for the |
| 690 | * PJLIB exceptions. |
| 691 | * |
| 692 | * Default: 0 |
| 693 | */ |
| 694 | #ifndef PJ_EXCEPTION_USE_WIN32_SEH |
| 695 | # define PJ_EXCEPTION_USE_WIN32_SEH 0 |
| 696 | #endif |
| 697 | |
| 698 | /** |
| 699 | * Should we attempt to use Pentium's rdtsc for high resolution |
| 700 | * timestamp. |
| 701 | * |
| 702 | * Default: 0 |
| 703 | */ |
| 704 | #ifndef PJ_TIMESTAMP_USE_RDTSC |
| 705 | # define PJ_TIMESTAMP_USE_RDTSC 0 |
| 706 | #endif |
| 707 | |
Benny Prijono | 1185299 | 2006-03-18 12:28:03 +0000 | [diff] [blame] | 708 | /** |
Benny Prijono | 5d54264 | 2007-05-02 18:54:19 +0000 | [diff] [blame] | 709 | * Is native platform error positive number? |
| 710 | * Default: 1 (yes) |
| 711 | */ |
| 712 | #ifndef PJ_NATIVE_ERR_POSITIVE |
| 713 | # define PJ_NATIVE_ERR_POSITIVE 1 |
| 714 | #endif |
| 715 | |
| 716 | /** |
Benny Prijono | 1185299 | 2006-03-18 12:28:03 +0000 | [diff] [blame] | 717 | * Include error message string in the library (pj_strerror()). |
| 718 | * This is very much desirable! |
| 719 | * |
| 720 | * Default: 1 |
| 721 | */ |
| 722 | #ifndef PJ_HAS_ERROR_STRING |
| 723 | # define PJ_HAS_ERROR_STRING 1 |
| 724 | #endif |
| 725 | |
Benny Prijono | 99683ae | 2005-11-21 16:59:47 +0000 | [diff] [blame] | 726 | |
Benny Prijono | dcf2996 | 2006-03-23 18:03:40 +0000 | [diff] [blame] | 727 | /** |
| 728 | * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom |
| 729 | * functions to compare alnum strings. On some systems, they're faster |
| 730 | * then stricmp/strcasecmp, but they can be slower on other systems. |
| 731 | * When disabled, pjlib will fallback to stricmp/strnicmp. |
| 732 | * |
| 733 | * Default: 0 |
| 734 | */ |
| 735 | #ifndef PJ_HAS_STRICMP_ALNUM |
| 736 | # define PJ_HAS_STRICMP_ALNUM 0 |
| 737 | #endif |
| 738 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 739 | /** @} */ |
| 740 | |
| 741 | /******************************************************************** |
| 742 | * General macros. |
| 743 | */ |
| 744 | |
| 745 | /** |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 746 | * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO) |
| 747 | * @ingroup pj_config |
| 748 | * @{ |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 749 | * |
| 750 | * The libraries support generation of dynamic link libraries for |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 751 | * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian |
| 752 | * terms). Similar procedures may be applied for Win32 DLL with some |
| 753 | * modification. |
| 754 | * |
| 755 | * Depending on the platforms, these steps may be necessary in order to |
| 756 | * produce the dynamic libraries: |
| 757 | * - Create the (Visual Studio) projects to produce DLL output. PJLIB |
| 758 | * does not provide ready to use project files to produce DLL, so |
| 759 | * you need to create these projects yourself. For Symbian, the MMP |
| 760 | * files have been setup to produce DSO files for targets that |
| 761 | * require them. |
| 762 | * - In the (Visual Studio) projects, some macros need to be declared |
| 763 | * so that appropriate modifiers are added to symbol declarations |
| 764 | * and definitions. Please see the macro section below for information |
| 765 | * regarding these macros. For Symbian, these have been taken care by the |
| 766 | * MMP files. |
| 767 | * - Some build systems require .DEF file to be specified when creating |
| 768 | * the DLL. For Symbian, .DEF files are included in pjlib distribution, |
| 769 | * in <tt>pjlib/build.symbian</tt> directory. These DEF files are |
| 770 | * created by running <tt>./makedef.sh all</tt> from this directory, |
| 771 | * inside Mingw. |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 772 | * |
| 773 | * Macros related for building DLL/DSO files: |
| 774 | * - For platforms that supports dynamic link libraries generation, |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 775 | * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 776 | * the prefix to be added to symbol definition, to export this |
| 777 | * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 778 | * value of this macro is \a __declspec(dllexport), and for ARM |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 779 | * ABIv2/Symbian, the value is \a EXPORT_C. |
| 780 | * - For platforms that supports linking with dynamic link libraries, |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 781 | * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 782 | * the prefix to be added to symbol declaration, to import this |
| 783 | * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 784 | * value of this macro is \a __declspec(dllimport), and for ARM |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 785 | * ABIv2/Symbian, the value is \a IMPORT_C. |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 786 | * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt> |
| 787 | * macros above can be declared in your \a config_site.h if they are not |
| 788 | * declared by pjlib. |
| 789 | * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and |
| 790 | * <tt>PJ_EXPORTING</tt> macros must be declared, so that |
| 791 | * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function |
| 792 | * definition. |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 793 | * - When application wants to link dynamically with PJLIB, then it |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 794 | * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header, |
| 795 | * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into |
| 796 | * symbol declarations. |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 797 | * |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 798 | * When <b>PJ_DLL</b> macro is not declared, static linking is assumed. |
| 799 | * |
| 800 | * For example, here are some settings to produce DLLs with Visual Studio |
| 801 | * on Windows/Win32: |
| 802 | * - Create Visual Studio projects to produce DLL. Add the appropriate |
| 803 | * project dependencies to avoid link errors. |
| 804 | * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt> |
| 805 | * macros. |
| 806 | * - Declare these macros in your <tt>config_site.h</tt>: |
| 807 | \verbatim |
| 808 | #define PJ_EXPORT_SPECIFIER __declspec(dllexport) |
| 809 | #define PJ_IMPORT_SPECIFIER __declspec(dllimport) |
| 810 | \endverbatim |
| 811 | * - And in the application (that links with the DLL) project, add |
| 812 | * <tt>PJ_DLL</tt> in the macro declarations. |
| 813 | */ |
| 814 | |
| 815 | /** @} */ |
| 816 | |
| 817 | /** |
| 818 | * @defgroup pj_config Build Configuration |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 819 | * @{ |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 820 | */ |
| 821 | |
| 822 | /** |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 823 | * @def PJ_INLINE(type) |
| 824 | * @param type The return type of the function. |
| 825 | * Expand the function as inline. |
| 826 | */ |
| 827 | #define PJ_INLINE(type) PJ_INLINE_SPECIFIER type |
| 828 | |
| 829 | /** |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 830 | * This macro declares platform/compiler specific specifier prefix |
| 831 | * to be added to symbol declaration to export the symbol when PJLIB |
| 832 | * is built as dynamic library. |
| 833 | * |
| 834 | * This macro should have been added by platform specific headers, |
| 835 | * if the platform supports building dynamic library target. |
| 836 | */ |
| 837 | #ifndef PJ_EXPORT_DECL_SPECIFIER |
| 838 | # define PJ_EXPORT_DECL_SPECIFIER |
| 839 | #endif |
| 840 | |
| 841 | |
| 842 | /** |
| 843 | * This macro declares platform/compiler specific specifier prefix |
| 844 | * to be added to symbol definition to export the symbol when PJLIB |
| 845 | * is built as dynamic library. |
| 846 | * |
| 847 | * This macro should have been added by platform specific headers, |
| 848 | * if the platform supports building dynamic library target. |
| 849 | */ |
| 850 | #ifndef PJ_EXPORT_DEF_SPECIFIER |
| 851 | # define PJ_EXPORT_DEF_SPECIFIER |
| 852 | #endif |
| 853 | |
| 854 | |
| 855 | /** |
| 856 | * This macro declares platform/compiler specific specifier prefix |
| 857 | * to be added to symbol declaration to import the symbol. |
| 858 | * |
| 859 | * This macro should have been added by platform specific headers, |
| 860 | * if the platform supports building dynamic library target. |
| 861 | */ |
| 862 | #ifndef PJ_IMPORT_DECL_SPECIFIER |
| 863 | # define PJ_IMPORT_DECL_SPECIFIER |
| 864 | #endif |
| 865 | |
| 866 | |
| 867 | /** |
| 868 | * This macro has been deprecated. It will evaluate to nothing. |
| 869 | */ |
| 870 | #ifndef PJ_EXPORT_SYMBOL |
| 871 | # define PJ_EXPORT_SYMBOL(x) |
| 872 | #endif |
| 873 | |
| 874 | |
| 875 | /** |
| 876 | * @def PJ_DECL(type) |
| 877 | * @param type The return type of the function. |
| 878 | * Declare a function. |
| 879 | */ |
| 880 | #if defined(PJ_DLL) |
| 881 | # if defined(PJ_EXPORTING) |
| 882 | # define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type |
| 883 | # else |
| 884 | # define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type |
| 885 | # endif |
| 886 | #elif !defined(PJ_DECL) |
| 887 | # if defined(__cplusplus) |
| 888 | # define PJ_DECL(type) type |
| 889 | # else |
| 890 | # define PJ_DECL(type) extern type |
| 891 | # endif |
| 892 | #endif |
| 893 | |
| 894 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 895 | /** |
| 896 | * @def PJ_DEF(type) |
| 897 | * @param type The return type of the function. |
| 898 | * Define a function. |
| 899 | */ |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 900 | #if defined(PJ_DLL) && defined(PJ_EXPORTING) |
| 901 | # define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type |
| 902 | #elif !defined(PJ_DEF) |
| 903 | # define PJ_DEF(type) type |
| 904 | #endif |
| 905 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 906 | |
| 907 | /** |
Benny Prijono | 225b222 | 2007-11-16 03:49:01 +0000 | [diff] [blame] | 908 | * @def PJ_DECL_NO_RETURN(type) |
| 909 | * @param type The return type of the function. |
| 910 | * Declare a function that will not return. |
| 911 | */ |
| 912 | /** |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 913 | * @def PJ_IDECL_NO_RETURN(type) |
| 914 | * @param type The return type of the function. |
| 915 | * Declare an inline function that will not return. |
| 916 | */ |
| 917 | /** |
Benny Prijono | 225b222 | 2007-11-16 03:49:01 +0000 | [diff] [blame] | 918 | * @def PJ_BEGIN_DECL |
| 919 | * Mark beginning of declaration section in a header file. |
| 920 | */ |
| 921 | /** |
| 922 | * @def PJ_END_DECL |
| 923 | * Mark end of declaration section in a header file. |
| 924 | */ |
| 925 | #ifdef __cplusplus |
| 926 | # define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN |
| 927 | # define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN |
| 928 | # define PJ_BEGIN_DECL extern "C" { |
| 929 | # define PJ_END_DECL } |
| 930 | #else |
| 931 | # define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type) |
| 932 | # define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type) |
| 933 | # define PJ_BEGIN_DECL |
| 934 | # define PJ_END_DECL |
| 935 | #endif |
| 936 | |
| 937 | |
| 938 | |
| 939 | /** |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 940 | * @def PJ_DECL_DATA(type) |
| 941 | * @param type The data type. |
| 942 | * Declare a global data. |
| 943 | */ |
| 944 | #if defined(PJ_DLL) |
| 945 | # if defined(PJ_EXPORTING) |
| 946 | # define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type |
| 947 | # else |
| 948 | # define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type |
| 949 | # endif |
| 950 | #elif !defined(PJ_DECL_DATA) |
| 951 | # define PJ_DECL_DATA(type) extern type |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 952 | #endif |
| 953 | |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 954 | |
| 955 | /** |
| 956 | * @def PJ_DEF_DATA(type) |
| 957 | * @param type The data type. |
| 958 | * Define a global data. |
| 959 | */ |
| 960 | #if defined(PJ_DLL) && defined(PJ_EXPORTING) |
| 961 | # define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type |
| 962 | #elif !defined(PJ_DEF_DATA) |
| 963 | # define PJ_DEF_DATA(type) type |
| 964 | #endif |
| 965 | |
| 966 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 967 | /** |
| 968 | * @def PJ_IDECL(type) |
| 969 | * @param type The function's return type. |
| 970 | * Declare a function that may be expanded as inline. |
| 971 | */ |
| 972 | /** |
| 973 | * @def PJ_IDEF(type) |
| 974 | * @param type The function's return type. |
| 975 | * Define a function that may be expanded as inline. |
| 976 | */ |
| 977 | |
| 978 | #if PJ_FUNCTIONS_ARE_INLINED |
| 979 | # define PJ_IDECL(type) PJ_INLINE(type) |
| 980 | # define PJ_IDEF(type) PJ_INLINE(type) |
| 981 | #else |
| 982 | # define PJ_IDECL(type) PJ_DECL(type) |
| 983 | # define PJ_IDEF(type) PJ_DEF(type) |
| 984 | #endif |
| 985 | |
Benny Prijono | 8ab968f | 2007-07-20 08:08:30 +0000 | [diff] [blame] | 986 | |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 987 | /** |
| 988 | * @def PJ_UNUSED_ARG(arg) |
| 989 | * @param arg The argument name. |
| 990 | * PJ_UNUSED_ARG prevents warning about unused argument in a function. |
| 991 | */ |
| 992 | #define PJ_UNUSED_ARG(arg) (void)arg |
| 993 | |
| 994 | /** |
| 995 | * @def PJ_TODO(id) |
| 996 | * @param id Any identifier that will be printed as TODO message. |
| 997 | * PJ_TODO macro will display TODO message as warning during compilation. |
| 998 | * Example: PJ_TODO(CLEAN_UP_ERROR); |
| 999 | */ |
| 1000 | #ifndef PJ_TODO |
| 1001 | # define PJ_TODO(id) TODO___##id: |
| 1002 | #endif |
| 1003 | |
| 1004 | /** |
| 1005 | * Function attributes to inform that the function may throw exception. |
| 1006 | * |
| 1007 | * @param x The exception list, enclosed in parenthesis. |
| 1008 | */ |
| 1009 | #define __pj_throw__(x) |
| 1010 | |
Benny Prijono | 31ff4d3 | 2007-11-23 03:49:20 +0000 | [diff] [blame] | 1011 | /** @} */ |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1012 | |
| 1013 | /******************************************************************** |
| 1014 | * Sanity Checks |
| 1015 | */ |
| 1016 | #ifndef PJ_HAS_HIGH_RES_TIMER |
| 1017 | # error "PJ_HAS_HIGH_RES_TIMER is not defined!" |
| 1018 | #endif |
| 1019 | |
| 1020 | #if !defined(PJ_HAS_PENTIUM) |
| 1021 | # error "PJ_HAS_PENTIUM is not defined!" |
| 1022 | #endif |
| 1023 | |
| 1024 | #if !defined(PJ_IS_LITTLE_ENDIAN) |
| 1025 | # error "PJ_IS_LITTLE_ENDIAN is not defined!" |
| 1026 | #endif |
| 1027 | |
| 1028 | #if !defined(PJ_IS_BIG_ENDIAN) |
| 1029 | # error "PJ_IS_BIG_ENDIAN is not defined!" |
| 1030 | #endif |
| 1031 | |
Benny Prijono | 42c5b9e | 2006-05-10 19:24:40 +0000 | [diff] [blame] | 1032 | #if !defined(PJ_EMULATE_RWMUTEX) |
| 1033 | # error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h" |
| 1034 | #endif |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1035 | |
Benny Prijono | 42c5b9e | 2006-05-10 19:24:40 +0000 | [diff] [blame] | 1036 | #if !defined(PJ_THREAD_SET_STACK_SIZE) |
| 1037 | # error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h" |
| 1038 | #endif |
| 1039 | |
| 1040 | #if !defined(PJ_THREAD_ALLOCATE_STACK) |
| 1041 | # error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h" |
| 1042 | #endif |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1043 | |
| 1044 | PJ_BEGIN_DECL |
| 1045 | |
| 1046 | /** |
Benny Prijono | d51a37a | 2007-07-28 02:44:55 +0000 | [diff] [blame] | 1047 | * PJLIB version string constant. @see pj_get_version() |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1048 | */ |
Benny Prijono | d51a37a | 2007-07-28 02:44:55 +0000 | [diff] [blame] | 1049 | PJ_DECL_DATA(const char*) PJ_VERSION; |
| 1050 | |
| 1051 | /** |
| 1052 | * Get PJLIB version string. |
| 1053 | * |
| 1054 | * @return #PJ_VERSION constant. |
| 1055 | */ |
| 1056 | PJ_DECL(const char*) pj_get_version(void); |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1057 | |
| 1058 | /** |
| 1059 | * Dump configuration to log with verbosity equal to info(3). |
| 1060 | */ |
| 1061 | PJ_DECL(void) pj_dump_config(void); |
| 1062 | |
| 1063 | PJ_END_DECL |
| 1064 | |
| 1065 | |
| 1066 | #endif /* __PJ_CONFIG_H__ */ |
| 1067 | |