config.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 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. * @file config.h
  23. * @brief PJLIB Main configuration settings.
  24. */
  25. /********************************************************************
  26. * Include compiler specific configuration.
  27. */
  28. #if defined(_MSC_VER)
  29. # include <pj/compat/cc_msvc.h>
  30. #elif defined(__clang__)
  31. # include <pj/compat/cc_clang.h>
  32. #elif defined(__GNUC__)
  33. # include <pj/compat/cc_gcc.h>
  34. #elif defined(__CW32__)
  35. # include <pj/compat/cc_mwcc.h>
  36. #elif defined(__MWERKS__)
  37. # include <pj/compat/cc_codew.h>
  38. #elif defined(__GCCE__)
  39. # include <pj/compat/cc_gcce.h>
  40. #elif defined(__ARMCC__)
  41. # include <pj/compat/cc_armcc.h>
  42. #else
  43. # error "Unknown compiler."
  44. #endif
  45. /* PJ_ALIGN_DATA is compiler specific directive to align data address */
  46. #ifndef PJ_ALIGN_DATA
  47. # error "PJ_ALIGN_DATA is not defined!"
  48. #endif
  49. /********************************************************************
  50. * Include target OS specific configuration.
  51. */
  52. #if defined(PJ_AUTOCONF)
  53. /*
  54. * Autoconf
  55. */
  56. # include <pj/compat/os_auto.h>
  57. #elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
  58. /*
  59. * SymbianOS
  60. */
  61. # include <pj/compat/os_symbian.h>
  62. #elif defined(PJ_WIN32_WINCE) || defined(_WIN32_WCE) || defined(UNDER_CE)
  63. /*
  64. * Windows CE
  65. */
  66. # undef PJ_WIN32_WINCE
  67. # define PJ_WIN32_WINCE 1
  68. # include <pj/compat/os_win32_wince.h>
  69. /* Also define Win32 */
  70. # define PJ_WIN32 1
  71. #elif defined(PJ_WIN32_WINPHONE8) || defined(_WIN32_WINPHONE8)
  72. /*
  73. * Windows Phone 8
  74. */
  75. # undef PJ_WIN32_WINPHONE8
  76. # define PJ_WIN32_WINPHONE8 1
  77. # include <pj/compat/os_winphone8.h>
  78. /* Also define Win32 */
  79. # define PJ_WIN32 1
  80. #elif defined(PJ_WIN32_UWP) || defined(_WIN32_UWP)
  81. /*
  82. * Windows UWP
  83. */
  84. # undef PJ_WIN32_UWP
  85. # define PJ_WIN32_UWP 1
  86. # include <pj/compat/os_winuwp.h>
  87. /* Define Windows phone */
  88. # define PJ_WIN32_WINPHONE8 1
  89. /* Also define Win32 */
  90. # define PJ_WIN32 1
  91. #elif defined(PJ_WIN32) || defined(_WIN32) || defined(__WIN32__) || \
  92. defined(WIN32) || defined(PJ_WIN64) || defined(_WIN64) || \
  93. defined(WIN64) || defined(__TOS_WIN__)
  94. # if defined(PJ_WIN64) || defined(_WIN64) || defined(WIN64)
  95. /*
  96. * Win64
  97. */
  98. # undef PJ_WIN64
  99. # define PJ_WIN64 1
  100. # endif
  101. # undef PJ_WIN32
  102. # define PJ_WIN32 1
  103. # include <pj/compat/os_win32.h>
  104. #elif defined(PJ_LINUX) || defined(linux) || defined(__linux)
  105. /*
  106. * Linux
  107. */
  108. # undef PJ_LINUX
  109. # define PJ_LINUX 1
  110. # include <pj/compat/os_linux.h>
  111. #elif defined(PJ_PALMOS) && PJ_PALMOS!=0
  112. /*
  113. * Palm
  114. */
  115. # include <pj/compat/os_palmos.h>
  116. #elif defined(PJ_SUNOS) || defined(sun) || defined(__sun)
  117. /*
  118. * SunOS
  119. */
  120. # undef PJ_SUNOS
  121. # define PJ_SUNOS 1
  122. # include <pj/compat/os_sunos.h>
  123. #elif defined(PJ_DARWINOS) || defined(__MACOSX__) || \
  124. defined (__APPLE__) || defined (__MACH__)
  125. /*
  126. * MacOS X
  127. */
  128. # undef PJ_DARWINOS
  129. # define PJ_DARWINOS 1
  130. # include <pj/compat/os_darwinos.h>
  131. #elif defined(PJ_RTEMS) && PJ_RTEMS!=0
  132. /*
  133. * RTEMS
  134. */
  135. # include <pj/compat/os_rtems.h>
  136. #else
  137. # error "Please specify target os."
  138. #endif
  139. /********************************************************************
  140. * Target machine specific configuration.
  141. */
  142. #if defined(PJ_AUTOCONF)
  143. /*
  144. * Autoconf configured
  145. */
  146. #include <pj/compat/m_auto.h>
  147. #elif defined (PJ_M_I386) || defined(_i386_) || defined(i_386_) || \
  148. defined(_X86_) || defined(x86) || defined(__i386__) || \
  149. defined(__i386) || defined(_M_IX86) || defined(__I86__)
  150. /*
  151. * Generic i386 processor family, little-endian
  152. */
  153. # undef PJ_M_I386
  154. # define PJ_M_I386 1
  155. # define PJ_M_NAME "i386"
  156. # define PJ_HAS_PENTIUM 1
  157. # define PJ_IS_LITTLE_ENDIAN 1
  158. # define PJ_IS_BIG_ENDIAN 0
  159. #elif defined (PJ_M_X86_64) || defined(__amd64__) || defined(__amd64) || \
  160. defined(__x86_64__) || defined(__x86_64) || \
  161. defined(_M_X64) || defined(_M_AMD64)
  162. /*
  163. * AMD 64bit processor, little endian
  164. */
  165. # undef PJ_M_X86_64
  166. # define PJ_M_X86_64 1
  167. # define PJ_M_NAME "x86_64"
  168. # define PJ_HAS_PENTIUM 1
  169. # define PJ_IS_LITTLE_ENDIAN 1
  170. # define PJ_IS_BIG_ENDIAN 0
  171. #elif defined(PJ_M_IA64) || defined(__ia64__) || defined(_IA64) || \
  172. defined(__IA64__) || defined( _M_IA64)
  173. /*
  174. * Intel IA64 processor, default to little endian
  175. */
  176. # undef PJ_M_IA64
  177. # define PJ_M_IA64 1
  178. # define PJ_M_NAME "ia64"
  179. # define PJ_HAS_PENTIUM 1
  180. # define PJ_IS_LITTLE_ENDIAN 1
  181. # define PJ_IS_BIG_ENDIAN 0
  182. #elif defined (PJ_M_M68K) && PJ_M_M68K != 0
  183. /*
  184. * Motorola m68k processor, big endian
  185. */
  186. # undef PJ_M_M68K
  187. # define PJ_M_M68K 1
  188. # define PJ_M_NAME "m68k"
  189. # define PJ_HAS_PENTIUM 0
  190. # define PJ_IS_LITTLE_ENDIAN 0
  191. # define PJ_IS_BIG_ENDIAN 1
  192. #elif defined (PJ_M_ALPHA) || defined (__alpha__) || defined (__alpha) || \
  193. defined (_M_ALPHA)
  194. /*
  195. * DEC Alpha processor, little endian
  196. */
  197. # undef PJ_M_ALPHA
  198. # define PJ_M_ALPHA 1
  199. # define PJ_M_NAME "alpha"
  200. # define PJ_HAS_PENTIUM 0
  201. # define PJ_IS_LITTLE_ENDIAN 1
  202. # define PJ_IS_BIG_ENDIAN 0
  203. #elif defined(PJ_M_MIPS) || defined(__mips__) || defined(__mips) || \
  204. defined(__MIPS__) || defined(MIPS) || defined(_MIPS_)
  205. /*
  206. * MIPS, bi-endian, so raise error if endianness is not configured
  207. */
  208. # undef PJ_M_MIPS
  209. # define PJ_M_MIPS 1
  210. # define PJ_M_NAME "mips"
  211. # define PJ_HAS_PENTIUM 0
  212. # if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
  213. # error Endianness must be declared for this processor
  214. # endif
  215. #elif defined (PJ_M_SPARC) || defined( __sparc__) || defined(__sparc)
  216. /*
  217. * Sun Sparc, big endian
  218. */
  219. # undef PJ_M_SPARC
  220. # define PJ_M_SPARC 1
  221. # define PJ_M_NAME "sparc"
  222. # define PJ_HAS_PENTIUM 0
  223. # define PJ_IS_LITTLE_ENDIAN 0
  224. # define PJ_IS_BIG_ENDIAN 1
  225. #elif defined(ARM) || defined(_ARM_) || defined(__arm__) || \
  226. defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__)
  227. # define PJ_HAS_PENTIUM 0
  228. /*
  229. * ARM, bi-endian, so raise error if endianness is not configured
  230. */
  231. # if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
  232. # error Endianness must be declared for this processor
  233. # endif
  234. # if defined (PJ_M_ARMV7) || defined(ARMV7)
  235. # undef PJ_M_ARMV7
  236. # define PJ_M_ARM7 1
  237. # define PJ_M_NAME "armv7"
  238. # elif defined (PJ_M_ARMV4) || defined(ARMV4)
  239. # undef PJ_M_ARMV4
  240. # define PJ_M_ARMV4 1
  241. # define PJ_M_NAME "armv4"
  242. # elif defined (PJ_M_ARM64) || defined(ARM64) || defined(__aarch64__)
  243. # undef PJ_M_ARM64
  244. # define PJ_M_ARM64 1
  245. # define PJ_M_NAME "arm64"
  246. # endif
  247. #elif defined (PJ_M_POWERPC) || defined(__powerpc) || defined(__powerpc__) || \
  248. defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \
  249. defined(_ARCH_PPC)
  250. /*
  251. * PowerPC, bi-endian, so raise error if endianness is not configured
  252. */
  253. # undef PJ_M_POWERPC
  254. # define PJ_M_POWERPC 1
  255. # define PJ_M_NAME "powerpc"
  256. # define PJ_HAS_PENTIUM 0
  257. # if !PJ_IS_LITTLE_ENDIAN && !PJ_IS_BIG_ENDIAN
  258. # error Endianness must be declared for this processor
  259. # endif
  260. #elif defined (PJ_M_NIOS2) || defined(__nios2) || defined(__nios2__) || \
  261. defined(__NIOS2__) || defined(__M_NIOS2) || defined(_ARCH_NIOS2)
  262. /*
  263. * Nios2, little endian
  264. */
  265. # undef PJ_M_NIOS2
  266. # define PJ_M_NIOS2 1
  267. # define PJ_M_NAME "nios2"
  268. # define PJ_HAS_PENTIUM 0
  269. # define PJ_IS_LITTLE_ENDIAN 1
  270. # define PJ_IS_BIG_ENDIAN 0
  271. #else
  272. # error "Please specify target machine."
  273. #endif
  274. /* Include size_t definition. */
  275. #include <pj/compat/size_t.h>
  276. /* Include site/user specific configuration to control PJLIB features.
  277. * YOU MUST CREATE THIS FILE YOURSELF!!
  278. */
  279. #include <pj/config_site.h>
  280. /********************************************************************
  281. * PJLIB Features.
  282. */
  283. /* Overrides for DOXYGEN */
  284. #ifdef DOXYGEN
  285. # undef PJ_FUNCTIONS_ARE_INLINED
  286. # undef PJ_HAS_FLOATING_POINT
  287. # undef PJ_LOG_MAX_LEVEL
  288. # undef PJ_LOG_MAX_SIZE
  289. # undef PJ_LOG_USE_STACK_BUFFER
  290. # undef PJ_TERM_HAS_COLOR
  291. # undef PJ_POOL_DEBUG
  292. # undef PJ_HAS_TCP
  293. # undef PJ_MAX_HOSTNAME
  294. # undef PJ_IOQUEUE_MAX_HANDLES
  295. # undef FD_SETSIZE
  296. # undef PJ_HAS_SEMAPHORE
  297. # undef PJ_HAS_EVENT_OBJ
  298. # undef PJ_EXCEPTION_USE_WIN32_SEH
  299. # undef PJ_HAS_ERROR_STRING
  300. # define PJ_HAS_IPV6 1
  301. #endif
  302. /**
  303. * @defgroup pj_config Build Configuration
  304. * @{
  305. *
  306. * This section contains macros that can set during PJLIB build process
  307. * to controll various aspects of the library.
  308. *
  309. * <b>Note</b>: the values in this page does NOT necessarily reflect to the
  310. * macro values during the build process.
  311. */
  312. /**
  313. * If this macro is set to 1, it will enable some debugging checking
  314. * in the library.
  315. *
  316. * Default: equal to (NOT NDEBUG).
  317. */
  318. #ifndef PJ_DEBUG
  319. # ifndef NDEBUG
  320. # define PJ_DEBUG 1
  321. # else
  322. # define PJ_DEBUG 0
  323. # endif
  324. #endif
  325. /**
  326. * Enable this macro to activate logging to mutex/semaphore related events.
  327. * This is useful to troubleshoot concurrency problems such as deadlocks.
  328. * In addition, you should also add PJ_LOG_HAS_THREAD_ID flag to the
  329. * log decoration to assist the troubleshooting.
  330. *
  331. * Default: 0
  332. */
  333. #ifndef PJ_DEBUG_MUTEX
  334. # define PJ_DEBUG_MUTEX 0
  335. #endif
  336. /**
  337. * Expand functions in *_i.h header files as inline.
  338. *
  339. * Default: 0.
  340. */
  341. #ifndef PJ_FUNCTIONS_ARE_INLINED
  342. # define PJ_FUNCTIONS_ARE_INLINED 0
  343. #endif
  344. /**
  345. * Use floating point computations in the library.
  346. *
  347. * Default: 1.
  348. */
  349. #ifndef PJ_HAS_FLOATING_POINT
  350. # define PJ_HAS_FLOATING_POINT 1
  351. #endif
  352. /**
  353. * Declare maximum logging level/verbosity. Lower number indicates higher
  354. * importance, with the highest importance has level zero. The least
  355. * important level is five in this implementation, but this can be extended
  356. * by supplying the appropriate implementation.
  357. *
  358. * The level conventions:
  359. * - 0: fatal error
  360. * - 1: error
  361. * - 2: warning
  362. * - 3: info
  363. * - 4: debug
  364. * - 5: trace
  365. * - 6: more detailed trace
  366. *
  367. * Default: 4
  368. */
  369. #ifndef PJ_LOG_MAX_LEVEL
  370. # define PJ_LOG_MAX_LEVEL 5
  371. #endif
  372. /**
  373. * Maximum message size that can be sent to output device for each call
  374. * to PJ_LOG(). If the message size is longer than this value, it will be cut.
  375. * This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
  376. * flag is set.
  377. *
  378. * Default: 4000
  379. */
  380. #ifndef PJ_LOG_MAX_SIZE
  381. # define PJ_LOG_MAX_SIZE 4000
  382. #endif
  383. /**
  384. * Log buffer.
  385. * Does the log get the buffer from the stack? (default is yes).
  386. * If the value is set to NO, then the buffer will be taken from static
  387. * buffer, which in this case will make the log function non-reentrant.
  388. *
  389. * Default: 1
  390. */
  391. #ifndef PJ_LOG_USE_STACK_BUFFER
  392. # define PJ_LOG_USE_STACK_BUFFER 1
  393. #endif
  394. /**
  395. * Enable log indentation feature.
  396. *
  397. * Default: 1
  398. */
  399. #ifndef PJ_LOG_ENABLE_INDENT
  400. # define PJ_LOG_ENABLE_INDENT 1
  401. #endif
  402. /**
  403. * Number of PJ_LOG_INDENT_CHAR to put every time pj_log_push_indent()
  404. * is called.
  405. *
  406. * Default: 1
  407. */
  408. #ifndef PJ_LOG_INDENT_SIZE
  409. # define PJ_LOG_INDENT_SIZE 1
  410. #endif
  411. /**
  412. * Log indentation character.
  413. *
  414. * Default: space
  415. */
  416. #ifndef PJ_LOG_INDENT_CHAR
  417. # define PJ_LOG_INDENT_CHAR '.'
  418. #endif
  419. /**
  420. * Log sender width.
  421. *
  422. * Default: 22 (for 64-bit machines), 14 otherwise
  423. */
  424. #ifndef PJ_LOG_SENDER_WIDTH
  425. # if PJ_HAS_STDINT_H
  426. # include <stdint.h>
  427. # if (UINTPTR_MAX == 0xffffffffffffffff)
  428. # define PJ_LOG_SENDER_WIDTH 22
  429. # else
  430. # define PJ_LOG_SENDER_WIDTH 14
  431. # endif
  432. # else
  433. # define PJ_LOG_SENDER_WIDTH 14
  434. # endif
  435. #endif
  436. /**
  437. * Log thread name width.
  438. *
  439. * Default: 12
  440. */
  441. #ifndef PJ_LOG_THREAD_WIDTH
  442. # define PJ_LOG_THREAD_WIDTH 12
  443. #endif
  444. /**
  445. * Colorfull terminal (for logging etc).
  446. *
  447. * Default: 1
  448. */
  449. #ifndef PJ_TERM_HAS_COLOR
  450. # define PJ_TERM_HAS_COLOR 1
  451. #endif
  452. /**
  453. * Set this flag to non-zero to enable various checking for pool
  454. * operations. When this flag is set, assertion must be enabled
  455. * in the application.
  456. *
  457. * This will slow down pool creation and destruction and will add
  458. * few bytes of overhead, so application would normally want to
  459. * disable this feature on release build.
  460. *
  461. * Default: 0
  462. */
  463. #ifndef PJ_SAFE_POOL
  464. # define PJ_SAFE_POOL 0
  465. #endif
  466. /**
  467. * If pool debugging is used, then each memory allocation from the pool
  468. * will call malloc(), and pool will release all memory chunks when it
  469. * is destroyed. This works better when memory verification programs
  470. * such as Rational Purify is used.
  471. *
  472. * Default: 0
  473. */
  474. #ifndef PJ_POOL_DEBUG
  475. # define PJ_POOL_DEBUG 0
  476. #endif
  477. /**
  478. * If enabled, when calling pj_pool_release(), the memory pool content
  479. * will be wiped out first before released.
  480. *
  481. * Default: 0
  482. */
  483. #ifndef PJ_POOL_RELEASE_WIPE_DATA
  484. # define PJ_POOL_RELEASE_WIPE_DATA 0
  485. #endif
  486. /**
  487. * If enabled, when allocating memory, pool will only search for a maximum
  488. * number of blocks specified before deciding that the pool is full and
  489. * a new memory block needs to be created.
  490. *
  491. * Set it to 0 to disable the limitation (i.e. it will search all blocks).
  492. *
  493. * Default: 5
  494. */
  495. #ifndef PJ_POOL_MAX_SEARCH_BLOCK_COUNT
  496. # define PJ_POOL_MAX_SEARCH_BLOCK_COUNT 5
  497. #endif
  498. /**
  499. * Enable timer debugging facility. When this is enabled, application
  500. * can call pj_timer_heap_dump() to show the contents of the timer
  501. * along with the source location where the timer entries were scheduled.
  502. * See https://github.com/pjsip/pjproject/issues/1527 for more info.
  503. *
  504. * Default: 1
  505. */
  506. #ifndef PJ_TIMER_DEBUG
  507. # define PJ_TIMER_DEBUG 1
  508. #endif
  509. /**
  510. * If enabled, the timer will keep internal copies of the timer entries.
  511. * This will increase the robustness and stability of the timer (against
  512. * accidental modification or premature deallocation of the timer entries) and
  513. * makes it easier to troubleshoot any timer related issues, with the overhead
  514. * of additional memory space required.
  515. *
  516. * Note that the detection against premature deallocation only works if the
  517. * freed memory content has changed (such as if it's been reallocated and
  518. * overwritten by another data. Alternatively, you can enable
  519. * PJ_POOL_RELEASE_WIPE_DATA which will erase the data first before releasing
  520. * the memory).
  521. *
  522. * Default: 1 (enabled)
  523. */
  524. #ifndef PJ_TIMER_USE_COPY
  525. # define PJ_TIMER_USE_COPY 1
  526. #endif
  527. /**
  528. * If enabled, the timer use sorted linked list instead of binary heap tree
  529. * structure. Note that using sorted linked list is intended for debugging
  530. * purposes and will hamper performance significantly when scheduling large
  531. * number of entries.
  532. *
  533. * Default: 0 (Use binary heap tree)
  534. */
  535. #ifndef PJ_TIMER_USE_LINKED_LIST
  536. # define PJ_TIMER_USE_LINKED_LIST 0
  537. #endif
  538. /**
  539. * Set this to 1 to enable debugging on the group lock. Default: 0
  540. */
  541. #ifndef PJ_GRP_LOCK_DEBUG
  542. # define PJ_GRP_LOCK_DEBUG 0
  543. #endif
  544. /**
  545. * Specify this as \a stack_size argument in #pj_thread_create() to specify
  546. * that thread should use default stack size for the current platform.
  547. *
  548. * Default: 8192
  549. */
  550. #ifndef PJ_THREAD_DEFAULT_STACK_SIZE
  551. # define PJ_THREAD_DEFAULT_STACK_SIZE 8192
  552. #endif
  553. /**
  554. * Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of
  555. * the stack. The OS implementation may check that no stack overflow
  556. * occurs, and it also may collect statistic about stack usage. Note
  557. * that this will increase the footprint of the libraries since it
  558. * tracks the filename and line number of each functions.
  559. */
  560. #ifndef PJ_OS_HAS_CHECK_STACK
  561. # define PJ_OS_HAS_CHECK_STACK 0
  562. #endif
  563. /**
  564. * Do we have alternate pool implementation?
  565. *
  566. * Default: 0
  567. */
  568. #ifndef PJ_HAS_POOL_ALT_API
  569. # define PJ_HAS_POOL_ALT_API PJ_POOL_DEBUG
  570. #endif
  571. /**
  572. * Support TCP in the library.
  573. * Disabling TCP will reduce the footprint slightly (about 6KB).
  574. *
  575. * Default: 1
  576. */
  577. #ifndef PJ_HAS_TCP
  578. # define PJ_HAS_TCP 1
  579. #endif
  580. /**
  581. * Support IPv6 in the library. If this support is disabled, some IPv6
  582. * related functions will return PJ_EIPV6NOTSUP.
  583. *
  584. * Default: 0 (disabled, for now)
  585. */
  586. #ifndef PJ_HAS_IPV6
  587. # define PJ_HAS_IPV6 0
  588. #endif
  589. /**
  590. * Maximum hostname length.
  591. * Libraries sometimes needs to make copy of an address to stack buffer;
  592. * the value here affects the stack usage.
  593. *
  594. * Note that the length here should include the NULL termination. In other
  595. * words, the maximum hostname length is PJ_MAX_HOSTNAME with the NULL
  596. * termination and PJ_MAX_HOSTNAME-1 without the NULL termination.
  597. *
  598. * Default: 254
  599. */
  600. #ifndef PJ_MAX_HOSTNAME
  601. # define PJ_MAX_HOSTNAME (254)
  602. #endif
  603. /**
  604. * Maximum consecutive identical error for accept() operation before
  605. * activesock stops calling the next ioqueue accept.
  606. *
  607. * Default: 50
  608. */
  609. #ifndef PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR
  610. # define PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR 50
  611. #endif
  612. /**
  613. * Constants for declaring the maximum handles that can be supported by
  614. * a single IOQ framework. This constant might not be relevant to the
  615. * underlying I/O queue impelementation, but still, developers should be
  616. * aware of this constant, to make sure that the program will not break when
  617. * the underlying implementation changes.
  618. */
  619. #ifndef PJ_IOQUEUE_MAX_HANDLES
  620. # define PJ_IOQUEUE_MAX_HANDLES (64)
  621. #endif
  622. /**
  623. * If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more
  624. * things to ensure thread safety of handle unregistration operation by
  625. * employing reference counter to each handle.
  626. *
  627. * In addition, the ioqueue will preallocate memory for the handles,
  628. * according to the maximum number of handles that is specified during
  629. * ioqueue creation.
  630. *
  631. * All applications would normally want this enabled, but you may disable
  632. * this if:
  633. * - there is no dynamic unregistration to all ioqueues.
  634. * - there is no threading, or there is no preemptive multitasking.
  635. *
  636. * Default: 1
  637. */
  638. #ifndef PJ_IOQUEUE_HAS_SAFE_UNREG
  639. # define PJ_IOQUEUE_HAS_SAFE_UNREG 1
  640. #endif
  641. /**
  642. * Default concurrency setting for sockets/handles registered to ioqueue.
  643. * This controls whether the ioqueue is allowed to call the key's callback
  644. * concurrently/in parallel. The default is yes, which means that if there
  645. * are more than one pending operations complete simultaneously, more
  646. * than one threads may call the key's callback at the same time. This
  647. * generally would promote good scalability for application, at the
  648. * expense of more complexity to manage the concurrent accesses.
  649. *
  650. * Please see the ioqueue documentation for more info.
  651. */
  652. #ifndef PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY
  653. # define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY 1
  654. #endif
  655. /* Sanity check:
  656. * if ioqueue concurrency is disallowed, PJ_IOQUEUE_HAS_SAFE_UNREG
  657. * must be enabled.
  658. */
  659. #if (PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY==0) && (PJ_IOQUEUE_HAS_SAFE_UNREG==0)
  660. # error PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if ioqueue concurrency \
  661. is disabled
  662. #endif
  663. /**
  664. * When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in
  665. * ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the
  666. * ioqueue key is kept in closing state before it can be reused.
  667. *
  668. * The value is in miliseconds.
  669. *
  670. * Default: 500 msec.
  671. */
  672. #ifndef PJ_IOQUEUE_KEY_FREE_DELAY
  673. # define PJ_IOQUEUE_KEY_FREE_DELAY 500
  674. #endif
  675. /**
  676. * Default flags for epoll_flags member of pj_ioqueue_cfg structure.
  677. * The values are combination of pj_ioqueue_epoll_flag constants.
  678. *
  679. * Default: PJ_IOQUEUE_EPOLL_AUTO
  680. */
  681. #ifndef PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS
  682. # define PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS PJ_IOQUEUE_EPOLL_AUTO
  683. #endif
  684. /**
  685. * Determine if FD_SETSIZE is changeable/set-able. If so, then we will
  686. * set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking
  687. * for Winsock.
  688. */
  689. #ifndef PJ_FD_SETSIZE_SETABLE
  690. # if (defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H!=0) || \
  691. (defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H!=0)
  692. # define PJ_FD_SETSIZE_SETABLE 1
  693. # else
  694. # define PJ_FD_SETSIZE_SETABLE 0
  695. # endif
  696. #endif
  697. /**
  698. * Overrides FD_SETSIZE so it is consistent throughout the library.
  699. * We only do this if we detected that FD_SETSIZE is changeable. If
  700. * FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be
  701. * set to value lower than FD_SETSIZE.
  702. */
  703. #if PJ_FD_SETSIZE_SETABLE
  704. /* Only override FD_SETSIZE if the value has not been set */
  705. # ifndef FD_SETSIZE
  706. # define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
  707. # endif
  708. #else
  709. /* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES
  710. * is lower than FD_SETSIZE value.
  711. *
  712. * Update: Not all ioqueue backends require this (such as epoll), so
  713. * this check will be done on the ioqueue implementation itself, such as
  714. * ioqueue select.
  715. */
  716. /*
  717. # ifdef FD_SETSIZE
  718. # if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
  719. # error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE"
  720. # endif
  721. # endif
  722. */
  723. #endif
  724. /**
  725. * Specify whether #pj_enum_ip_interface() function should exclude
  726. * loopback interfaces.
  727. *
  728. * Default: 1
  729. */
  730. #ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
  731. # define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
  732. #endif
  733. /**
  734. * Has semaphore functionality?
  735. *
  736. * Default: 1
  737. */
  738. #ifndef PJ_HAS_SEMAPHORE
  739. # define PJ_HAS_SEMAPHORE 1
  740. #endif
  741. /**
  742. * Use dispatch semaphores on Darwin.
  743. *
  744. * Default: 1 on Darwin, 0 otherwise
  745. */
  746. #ifndef PJ_SEMAPHORE_USE_DISPATCH_SEM
  747. # if defined(PJ_DARWINOS) && PJ_DARWINOS != 0
  748. # define PJ_SEMAPHORE_USE_DISPATCH_SEM 1
  749. # else
  750. # define PJ_SEMAPHORE_USE_DISPATCH_SEM 0
  751. # endif
  752. #endif
  753. /**
  754. * Event object (for synchronization, e.g. in Win32)
  755. *
  756. * Default: 1
  757. */
  758. #ifndef PJ_HAS_EVENT_OBJ
  759. # define PJ_HAS_EVENT_OBJ 1
  760. #endif
  761. /**
  762. * Maximum file name length.
  763. */
  764. #ifndef PJ_MAXPATH
  765. # define PJ_MAXPATH 260
  766. #endif
  767. /**
  768. * Enable name registration for exceptions with #pj_exception_id_alloc().
  769. * If this feature is enabled, then the library will keep track of
  770. * names associated with each exception ID requested by application via
  771. * #pj_exception_id_alloc().
  772. *
  773. * Disabling this macro will reduce the code and .bss size by a tad bit.
  774. * See also #PJ_MAX_EXCEPTION_ID.
  775. *
  776. * Default: 1
  777. */
  778. #ifndef PJ_HAS_EXCEPTION_NAMES
  779. # define PJ_HAS_EXCEPTION_NAMES 1
  780. #endif
  781. /**
  782. * Maximum number of unique exception IDs that can be requested
  783. * with #pj_exception_id_alloc(). For each entry, a small record will
  784. * be allocated in the .bss segment.
  785. *
  786. * Default: 16
  787. */
  788. #ifndef PJ_MAX_EXCEPTION_ID
  789. # define PJ_MAX_EXCEPTION_ID 16
  790. #endif
  791. /**
  792. * Should we use Windows Structured Exception Handling (SEH) for the
  793. * PJLIB exceptions.
  794. *
  795. * Default: 0
  796. */
  797. #ifndef PJ_EXCEPTION_USE_WIN32_SEH
  798. # define PJ_EXCEPTION_USE_WIN32_SEH 0
  799. #endif
  800. /**
  801. * Should we attempt to use Pentium's rdtsc for high resolution
  802. * timestamp.
  803. *
  804. * Default: 0
  805. */
  806. #ifndef PJ_TIMESTAMP_USE_RDTSC
  807. # define PJ_TIMESTAMP_USE_RDTSC 0
  808. #endif
  809. /**
  810. * Is native platform error positive number?
  811. * Default: 1 (yes)
  812. */
  813. #ifndef PJ_NATIVE_ERR_POSITIVE
  814. # define PJ_NATIVE_ERR_POSITIVE 1
  815. #endif
  816. /**
  817. * Include error message string in the library (pj_strerror()).
  818. * This is very much desirable!
  819. *
  820. * Default: 1
  821. */
  822. #ifndef PJ_HAS_ERROR_STRING
  823. # define PJ_HAS_ERROR_STRING 1
  824. #endif
  825. /**
  826. * Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom
  827. * functions to compare alnum strings. On some systems, they're faster
  828. * then stricmp/strcasecmp, but they can be slower on other systems.
  829. * When disabled, pjlib will fallback to stricmp/strnicmp.
  830. *
  831. * Default: 0
  832. */
  833. #ifndef PJ_HAS_STRICMP_ALNUM
  834. # define PJ_HAS_STRICMP_ALNUM 0
  835. #endif
  836. /**
  837. * Prohibit the use of unsafe string functions such as strcpy(), strncpy(),
  838. * strcat(), and vsprintf().
  839. */
  840. #ifndef PJ_BAN_UNSAFE_STR_FUNCS
  841. # define PJ_BAN_UNSAFE_STR_FUNCS 0
  842. #endif
  843. /**
  844. * Prohibit the use of strcpy() and pj_ansi_strcpy(), use pj_ansi_strxcpy()
  845. * instead.
  846. */
  847. #ifndef PJ_BAN_STRCPY
  848. # define PJ_BAN_STRCPY PJ_BAN_UNSAFE_STR_FUNCS
  849. #endif
  850. /**
  851. * Prohibit the use of strncpy() and pj_ansi_strncpy(), use pj_ansi_strxcpy()
  852. * instead.
  853. */
  854. #ifndef PJ_BAN_STRNCPY
  855. # define PJ_BAN_STRNCPY PJ_BAN_UNSAFE_STR_FUNCS
  856. #endif
  857. /**
  858. * Prohibit the use of strcat() and pj_ansi_strcat(), use pj_ansi_strxcat()
  859. * instead.
  860. */
  861. #ifndef PJ_BAN_STRCAT
  862. # define PJ_BAN_STRCAT PJ_BAN_UNSAFE_STR_FUNCS
  863. #endif
  864. /**
  865. * Prohibit the use of sprintf() and pj_ansi_sprintf(),
  866. * use pj_ansi_snprintf() instead.
  867. */
  868. #ifndef PJ_BAN_SPRINTF
  869. # define PJ_BAN_SPRINTF PJ_BAN_UNSAFE_STR_FUNCS
  870. #endif
  871. /**
  872. * Prohibit the use of vsprintf() and pj_ansi_vsprintf(),
  873. * use pj_ansi_vsnprintf() instead.
  874. */
  875. #ifndef PJ_BAN_VSPRINTF
  876. # define PJ_BAN_VSPRINTF PJ_BAN_UNSAFE_STR_FUNCS
  877. #endif
  878. /*
  879. * Warn about obsolete macros.
  880. *
  881. * PJ_ENABLE_EXTRA_CHECK has been deprecated in 2.13.
  882. */
  883. #if defined(PJ_ENABLE_EXTRA_CHECK) && PJ_ENABLE_EXTRA_CHECK==0
  884. # ifdef _MSC_VER
  885. # pragma message("Warning: PJ_ENABLE_EXTRA_CHECK macro is deprecated"\
  886. " and has no effect")
  887. # else
  888. # warning "PJ_ENABLE_EXTRA_CHECK macro is deprecated and has no effect"
  889. # endif
  890. #endif
  891. /*
  892. * Types of QoS backend implementation.
  893. */
  894. /**
  895. * Dummy QoS backend implementation, will always return error on all
  896. * the APIs.
  897. */
  898. #define PJ_QOS_DUMMY 1
  899. /** QoS backend based on setsockopt(IP_TOS) */
  900. #define PJ_QOS_BSD 2
  901. /** QoS backend for Windows Mobile 6 */
  902. #define PJ_QOS_WM 3
  903. /** QoS backend for Symbian */
  904. #define PJ_QOS_SYMBIAN 4
  905. /** QoS backend for Darwin */
  906. #define PJ_QOS_DARWIN 5
  907. /**
  908. * Force the use of some QoS backend API for some platforms.
  909. */
  910. #ifndef PJ_QOS_IMPLEMENTATION
  911. # if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE && _WIN32_WCE >= 0x502
  912. /* Windows Mobile 6 or later */
  913. # define PJ_QOS_IMPLEMENTATION PJ_QOS_WM
  914. # elif defined(PJ_DARWINOS)
  915. /* Darwin OS (e.g: iOS, MacOS, tvOS) */
  916. # define PJ_QOS_IMPLEMENTATION PJ_QOS_DARWIN
  917. # endif
  918. #endif
  919. /**
  920. * Enable secure socket. For most platforms, this is implemented using
  921. * OpenSSL or GnuTLS, so this will require one of those libraries to
  922. * be installed. For Symbian platform, this is implemented natively
  923. * using CSecureSocket.
  924. *
  925. * Default: 0 (for now)
  926. */
  927. #ifndef PJ_HAS_SSL_SOCK
  928. # define PJ_HAS_SSL_SOCK 0
  929. #endif
  930. /*
  931. * Secure socket implementation.
  932. * Select one of these implementations in PJ_SSL_SOCK_IMP.
  933. */
  934. /** Disable SSL socket */
  935. #define PJ_SSL_SOCK_IMP_NONE 0
  936. /** Using OpenSSL */
  937. #define PJ_SSL_SOCK_IMP_OPENSSL 1
  938. /**< Using GnuTLS */
  939. #define PJ_SSL_SOCK_IMP_GNUTLS 2
  940. /** Using Apple's Secure Transport (deprecated in MacOS 10.15 & iOS 13.0) */
  941. #define PJ_SSL_SOCK_IMP_DARWIN 3
  942. /** Using Apple's Network framework */
  943. #define PJ_SSL_SOCK_IMP_APPLE 4
  944. /** Using Windows's Schannel */
  945. #define PJ_SSL_SOCK_IMP_SCHANNEL 5
  946. /**
  947. * Select which SSL socket implementation to use. Currently pjlib supports
  948. * PJ_SSL_SOCK_IMP_OPENSSL, which uses OpenSSL, and PJ_SSL_SOCK_IMP_GNUTLS,
  949. * which uses GnuTLS. Setting this to PJ_SSL_SOCK_IMP_NONE will disable
  950. * secure socket.
  951. *
  952. * Default is PJ_SSL_SOCK_IMP_NONE if PJ_HAS_SSL_SOCK is not set, otherwise
  953. * it is PJ_SSL_SOCK_IMP_OPENSSL.
  954. */
  955. #ifndef PJ_SSL_SOCK_IMP
  956. # if PJ_HAS_SSL_SOCK==0
  957. # define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_NONE
  958. # else
  959. # define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_OPENSSL
  960. # endif
  961. #endif
  962. /**
  963. * Define the maximum number of ciphers supported by the secure socket.
  964. *
  965. * Default: 256
  966. */
  967. #ifndef PJ_SSL_SOCK_MAX_CIPHERS
  968. # define PJ_SSL_SOCK_MAX_CIPHERS 256
  969. #endif
  970. /**
  971. * Specify what should be set as the available list of SSL_CIPHERs. For
  972. * example, set this as "DEFAULT" to use the default cipher list (Note:
  973. * PJSIP release 2.4 and before used this "DEFAULT" setting).
  974. *
  975. * Default: "HIGH:-COMPLEMENTOFDEFAULT"
  976. */
  977. #ifndef PJ_SSL_SOCK_OSSL_CIPHERS
  978. # define PJ_SSL_SOCK_OSSL_CIPHERS "HIGH:-COMPLEMENTOFDEFAULT"
  979. #endif
  980. /**
  981. * Define the maximum number of curves supported by the secure socket.
  982. *
  983. * Default: 32
  984. */
  985. #ifndef PJ_SSL_SOCK_MAX_CURVES
  986. # define PJ_SSL_SOCK_MAX_CURVES 32
  987. #endif
  988. /**
  989. * Use OpenSSL thread locking callback. This is only applicable for OpenSSL
  990. * version prior to 1.1.0
  991. *
  992. * Default: 1 (enabled)
  993. */
  994. #ifndef PJ_SSL_SOCK_OSSL_USE_THREAD_CB
  995. # define PJ_SSL_SOCK_OSSL_USE_THREAD_CB 1
  996. #else
  997. # define PJ_SSL_SOCK_OSSL_USE_THREAD_CB 0
  998. #endif
  999. /**
  1000. * Disable WSAECONNRESET error for UDP sockets on Win32 platforms. See
  1001. * https://github.com/pjsip/pjproject/issues/1197.
  1002. *
  1003. * Default: 1
  1004. */
  1005. #ifndef PJ_SOCK_DISABLE_WSAECONNRESET
  1006. # define PJ_SOCK_DISABLE_WSAECONNRESET 1
  1007. #endif
  1008. /**
  1009. * Maximum number of socket options in pj_sockopt_params.
  1010. *
  1011. * Default: 4
  1012. */
  1013. #ifndef PJ_MAX_SOCKOPT_PARAMS
  1014. # define PJ_MAX_SOCKOPT_PARAMS 4
  1015. #endif
  1016. /* Specify if JNI_OnLoad() will be defined in the library. If enabled,
  1017. * PJSIP will set the Java Virtual Machine (JVM) inside JNI_OnLoad().
  1018. *
  1019. * Since there can only be one JNI_OnLoad() in a library loaded from Java,
  1020. * you can disable this if the implementation is already defined somewhere
  1021. * else. Then you can set the JVM using the API pj_jni_set_jvm() instead.
  1022. *
  1023. * Default: enabled for Android
  1024. */
  1025. #ifndef PJ_JNI_HAS_JNI_ONLOAD
  1026. # define PJ_JNI_HAS_JNI_ONLOAD PJ_ANDROID
  1027. #endif
  1028. /** @} */
  1029. /********************************************************************
  1030. * General macros.
  1031. */
  1032. /**
  1033. * @defgroup pj_dll_target Building Dynamic Link Libraries (DLL/DSO)
  1034. * @ingroup pj_config
  1035. * @{
  1036. *
  1037. * The libraries support generation of dynamic link libraries for
  1038. * Symbian ABIv2 target (.dso/Dynamic Shared Object files, in Symbian
  1039. * terms). Similar procedures may be applied for Win32 DLL with some
  1040. * modification.
  1041. *
  1042. * Depending on the platforms, these steps may be necessary in order to
  1043. * produce the dynamic libraries:
  1044. * - Create the (Visual Studio) projects to produce DLL output. PJLIB
  1045. * does not provide ready to use project files to produce DLL, so
  1046. * you need to create these projects yourself. For Symbian, the MMP
  1047. * files have been setup to produce DSO files for targets that
  1048. * require them.
  1049. * - In the (Visual Studio) projects, some macros need to be declared
  1050. * so that appropriate modifiers are added to symbol declarations
  1051. * and definitions. Please see the macro section below for information
  1052. * regarding these macros. For Symbian, these have been taken care by the
  1053. * MMP files.
  1054. * - Some build systems require .DEF file to be specified when creating
  1055. * the DLL. For Symbian, .DEF files are included in pjlib distribution,
  1056. * in <tt>pjlib/build.symbian</tt> directory. These DEF files are
  1057. * created by running <tt>./makedef.sh all</tt> from this directory,
  1058. * inside Mingw.
  1059. *
  1060. * Macros related for building DLL/DSO files:
  1061. * - For platforms that supports dynamic link libraries generation,
  1062. * it must declare <tt>PJ_EXPORT_SPECIFIER</tt> macro which value contains
  1063. * the prefix to be added to symbol definition, to export this
  1064. * symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
  1065. * value of this macro is \a __declspec(dllexport), and for ARM
  1066. * ABIv2/Symbian, the value is \a EXPORT_C.
  1067. * - For platforms that supports linking with dynamic link libraries,
  1068. * it must declare <tt>PJ_IMPORT_SPECIFIER</tt> macro which value contains
  1069. * the prefix to be added to symbol declaration, to import this
  1070. * symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
  1071. * value of this macro is \a __declspec(dllimport), and for ARM
  1072. * ABIv2/Symbian, the value is \a IMPORT_C.
  1073. * - Both <tt>PJ_EXPORT_SPECIFIER</tt> and <tt>PJ_IMPORT_SPECIFIER</tt>
  1074. * macros above can be declared in your \a config_site.h if they are not
  1075. * declared by pjlib.
  1076. * - When PJLIB is built as DLL/DSO, both <tt>PJ_DLL</tt> and
  1077. * <tt>PJ_EXPORTING</tt> macros must be declared, so that
  1078. * <tt>PJ_EXPORT_SPECIFIER</tt> modifier will be added into function
  1079. * definition.
  1080. * - When application wants to link dynamically with PJLIB, then it
  1081. * must declare <tt>PJ_DLL</tt> macro when using/including PJLIB header,
  1082. * so that <tt>PJ_IMPORT_SPECIFIER</tt> modifier is properly added into
  1083. * symbol declarations.
  1084. *
  1085. * When <b>PJ_DLL</b> macro is not declared, static linking is assumed.
  1086. *
  1087. * For example, here are some settings to produce DLLs with Visual Studio
  1088. * on Windows/Win32:
  1089. * - Create Visual Studio projects to produce DLL. Add the appropriate
  1090. * project dependencies to avoid link errors.
  1091. * - In the projects, declare <tt>PJ_DLL</tt> and <tt>PJ_EXPORTING</tt>
  1092. * macros.
  1093. * - Declare these macros in your <tt>config_site.h</tt>:
  1094. \verbatim
  1095. #define PJ_EXPORT_SPECIFIER __declspec(dllexport)
  1096. #define PJ_IMPORT_SPECIFIER __declspec(dllimport)
  1097. \endverbatim
  1098. * - And in the application (that links with the DLL) project, add
  1099. * <tt>PJ_DLL</tt> in the macro declarations.
  1100. */
  1101. /** @} */
  1102. /**
  1103. * @defgroup pj_config Build Configuration
  1104. * @{
  1105. */
  1106. /**
  1107. * @def PJ_INLINE(type)
  1108. * @param type The return type of the function.
  1109. * Expand the function as inline.
  1110. */
  1111. #define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
  1112. /**
  1113. * This macro declares platform/compiler specific specifier prefix
  1114. * to be added to symbol declaration to export the symbol when PJLIB
  1115. * is built as dynamic library.
  1116. *
  1117. * This macro should have been added by platform specific headers,
  1118. * if the platform supports building dynamic library target.
  1119. */
  1120. #ifndef PJ_EXPORT_DECL_SPECIFIER
  1121. # define PJ_EXPORT_DECL_SPECIFIER
  1122. #endif
  1123. /**
  1124. * This macro declares platform/compiler specific specifier prefix
  1125. * to be added to symbol definition to export the symbol when PJLIB
  1126. * is built as dynamic library.
  1127. *
  1128. * This macro should have been added by platform specific headers,
  1129. * if the platform supports building dynamic library target.
  1130. */
  1131. #ifndef PJ_EXPORT_DEF_SPECIFIER
  1132. # define PJ_EXPORT_DEF_SPECIFIER
  1133. #endif
  1134. /**
  1135. * This macro declares platform/compiler specific specifier prefix
  1136. * to be added to symbol declaration to import the symbol.
  1137. *
  1138. * This macro should have been added by platform specific headers,
  1139. * if the platform supports building dynamic library target.
  1140. */
  1141. #ifndef PJ_IMPORT_DECL_SPECIFIER
  1142. # define PJ_IMPORT_DECL_SPECIFIER
  1143. #endif
  1144. /**
  1145. * This macro has been deprecated. It will evaluate to nothing.
  1146. */
  1147. #ifndef PJ_EXPORT_SYMBOL
  1148. # define PJ_EXPORT_SYMBOL(x)
  1149. #endif
  1150. /**
  1151. * @def PJ_DECL(type)
  1152. * @param type The return type of the function.
  1153. * Declare a function.
  1154. */
  1155. #if defined(PJ_DLL)
  1156. # if defined(PJ_EXPORTING)
  1157. # define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
  1158. # else
  1159. # define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
  1160. # endif
  1161. #elif !defined(PJ_DECL)
  1162. # if defined(__cplusplus)
  1163. # define PJ_DECL(type) type
  1164. # else
  1165. # define PJ_DECL(type) extern type
  1166. # endif
  1167. #endif
  1168. /**
  1169. * @def PJ_DEF(type)
  1170. * @param type The return type of the function.
  1171. * Define a function.
  1172. */
  1173. #if defined(PJ_DLL) && defined(PJ_EXPORTING)
  1174. # define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
  1175. #elif !defined(PJ_DEF)
  1176. # define PJ_DEF(type) type
  1177. #endif
  1178. /**
  1179. * @def PJ_DECL_NO_RETURN(type)
  1180. * @param type The return type of the function.
  1181. * Declare a function that will not return.
  1182. */
  1183. /**
  1184. * @def PJ_IDECL_NO_RETURN(type)
  1185. * @param type The return type of the function.
  1186. * Declare an inline function that will not return.
  1187. */
  1188. /**
  1189. * @def PJ_BEGIN_DECL
  1190. * Mark beginning of declaration section in a header file.
  1191. */
  1192. /**
  1193. * @def PJ_END_DECL
  1194. * Mark end of declaration section in a header file.
  1195. */
  1196. #ifdef __cplusplus
  1197. # define PJ_DECL_NO_RETURN(type) PJ_DECL(type) PJ_NORETURN
  1198. # define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
  1199. # define PJ_BEGIN_DECL extern "C" {
  1200. # define PJ_END_DECL }
  1201. #else
  1202. # define PJ_DECL_NO_RETURN(type) PJ_NORETURN PJ_DECL(type)
  1203. # define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
  1204. # define PJ_BEGIN_DECL
  1205. # define PJ_END_DECL
  1206. #endif
  1207. /**
  1208. * @def PJ_DECL_DATA(type)
  1209. * @param type The data type.
  1210. * Declare a global data.
  1211. */
  1212. #if defined(PJ_DLL)
  1213. # if defined(PJ_EXPORTING)
  1214. # define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
  1215. # else
  1216. # define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
  1217. # endif
  1218. #elif !defined(PJ_DECL_DATA)
  1219. # define PJ_DECL_DATA(type) extern type
  1220. #endif
  1221. /**
  1222. * @def PJ_DEF_DATA(type)
  1223. * @param type The data type.
  1224. * Define a global data.
  1225. */
  1226. #if defined(PJ_DLL) && defined(PJ_EXPORTING)
  1227. # define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
  1228. #elif !defined(PJ_DEF_DATA)
  1229. # define PJ_DEF_DATA(type) type
  1230. #endif
  1231. /**
  1232. * @def PJ_IDECL(type)
  1233. * @param type The function's return type.
  1234. * Declare a function that may be expanded as inline.
  1235. */
  1236. /**
  1237. * @def PJ_IDEF(type)
  1238. * @param type The function's return type.
  1239. * Define a function that may be expanded as inline.
  1240. */
  1241. #if PJ_FUNCTIONS_ARE_INLINED
  1242. # define PJ_IDECL(type) PJ_INLINE(type)
  1243. # define PJ_IDEF(type) PJ_INLINE(type)
  1244. #else
  1245. # define PJ_IDECL(type) PJ_DECL(type)
  1246. # define PJ_IDEF(type) PJ_DEF(type)
  1247. #endif
  1248. /**
  1249. * @def PJ_UNUSED_ARG(arg)
  1250. * @param arg The argument name.
  1251. * PJ_UNUSED_ARG prevents warning about unused argument in a function.
  1252. */
  1253. #define PJ_UNUSED_ARG(arg) (void)arg
  1254. /**
  1255. * @def PJ_TODO(id)
  1256. * @param id Any identifier that will be printed as TODO message.
  1257. * PJ_TODO macro will display TODO message as warning during compilation.
  1258. * Example: PJ_TODO(CLEAN_UP_ERROR);
  1259. */
  1260. #ifndef PJ_TODO
  1261. # define PJ_TODO(id) TODO___##id:
  1262. #endif
  1263. /**
  1264. * Simulate race condition by sleeping the thread in strategic locations.
  1265. * Default: no!
  1266. */
  1267. #ifndef PJ_RACE_ME
  1268. # define PJ_RACE_ME(x)
  1269. #endif
  1270. /**
  1271. * Function attributes to inform that the function may throw exception.
  1272. *
  1273. * @param x The exception list, enclosed in parenthesis.
  1274. */
  1275. #define __pj_throw__(x)
  1276. /** @} */
  1277. /********************************************************************
  1278. * Sanity Checks
  1279. */
  1280. #ifndef PJ_HAS_HIGH_RES_TIMER
  1281. # error "PJ_HAS_HIGH_RES_TIMER is not defined!"
  1282. #endif
  1283. #if !defined(PJ_HAS_PENTIUM)
  1284. # error "PJ_HAS_PENTIUM is not defined!"
  1285. #endif
  1286. #if !defined(PJ_IS_LITTLE_ENDIAN)
  1287. # error "PJ_IS_LITTLE_ENDIAN is not defined!"
  1288. #endif
  1289. #if !defined(PJ_IS_BIG_ENDIAN)
  1290. # error "PJ_IS_BIG_ENDIAN is not defined!"
  1291. #endif
  1292. #if !defined(PJ_EMULATE_RWMUTEX)
  1293. # error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h"
  1294. #endif
  1295. #if !defined(PJ_THREAD_SET_STACK_SIZE)
  1296. # error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h"
  1297. #endif
  1298. #if !defined(PJ_THREAD_ALLOCATE_STACK)
  1299. # error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h"
  1300. #endif
  1301. PJ_BEGIN_DECL
  1302. /** PJLIB version major number. */
  1303. #define PJ_VERSION_NUM_MAJOR 2
  1304. /** PJLIB version minor number. */
  1305. #define PJ_VERSION_NUM_MINOR 14
  1306. /** PJLIB version revision number. */
  1307. #define PJ_VERSION_NUM_REV 0
  1308. /**
  1309. * Extra suffix for the version (e.g. "-trunk"), or empty for
  1310. * web release version.
  1311. */
  1312. #define PJ_VERSION_NUM_EXTRA "-dev"
  1313. /**
  1314. * PJLIB version number consists of three bytes with the following format:
  1315. * 0xMMIIRR00, where MM: major number, II: minor number, RR: revision
  1316. * number, 00: always zero for now.
  1317. */
  1318. #define PJ_VERSION_NUM ((PJ_VERSION_NUM_MAJOR << 24) | \
  1319. (PJ_VERSION_NUM_MINOR << 16) | \
  1320. (PJ_VERSION_NUM_REV << 8))
  1321. /**
  1322. * PJLIB version string constant. @see pj_get_version()
  1323. */
  1324. PJ_DECL_DATA(const char*) PJ_VERSION;
  1325. /**
  1326. * Get PJLIB version string.
  1327. *
  1328. * @return #PJ_VERSION constant.
  1329. */
  1330. PJ_DECL(const char*) pj_get_version(void);
  1331. /**
  1332. * Dump configuration to log with verbosity equal to info(3).
  1333. */
  1334. PJ_DECL(void) pj_dump_config(void);
  1335. PJ_END_DECL
  1336. #endif /* __PJ_CONFIG_H__ */