Group pj_config

group pj_config

This section contains macros that can set during PJLIB build process to controll various aspects of the library.

Note: the values in this page does NOT necessarily reflect to the macro values during the build process.



If this macro is set to 1, it will enable some debugging checking in the library.

Default: equal to (NOT NDEBUG).


Enable this macro to activate logging to mutex/semaphore related events. This is useful to troubleshoot concurrency problems such as deadlocks. In addition, you should also add PJ_LOG_HAS_THREAD_ID flag to the log decoration to assist the troubleshooting.

Default: 0


Expand functions in *_i.h header files as inline.

Default: 0.


Use floating point computations in the library.

Default: 1.


Declare maximum logging level/verbosity. Lower number indicates higher importance, with the highest importance has level zero. The least important level is five in this implementation, but this can be extended by supplying the appropriate implementation.

The level conventions:

  • 0: fatal error

  • 1: error

  • 2: warning

  • 3: info

  • 4: debug

  • 5: trace

  • 6: more detailed trace

Default: 4 Maximum message size that can be sent to output device for each call to PJ_LOG(). If the message size is longer than this value, it will be cut. This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER flag is set.

Default: 4000


Log buffer. Does the log get the buffer from the stack? (default is yes). If the value is set to NO, then the buffer will be taken from static buffer, which in this case will make the log function non-reentrant.

Default: 1


Enable log indentation feature.

Default: 1


Number of PJ_LOG_INDENT_CHAR to put every time pj_log_push_indent() is called.

Default: 1


Log indentation character.

Default: space


Log sender width.

Default: 22 (for 64-bit machines), 14 otherwise


Log thread name width.

Default: 12


Colorfull terminal (for logging etc).

Default: 1


Set this flag to non-zero to enable various checking for pool operations. When this flag is set, assertion must be enabled in the application.

This will slow down pool creation and destruction and will add few bytes of overhead, so application would normally want to disable this feature on release build.

Default: 0


If pool debugging is used, then each memory allocation from the pool will call malloc(), and pool will release all memory chunks when it is destroyed. This works better when memory verification programs such as Rational Purify is used.

Default: 0


If enabled, when calling pj_pool_release(), the memory pool content will be wiped out first before released.

Default: 0


If enabled, when allocating memory, pool will only search for a maximum number of blocks specified before deciding that the pool is full and a new memory block needs to be created.

Set it to 0 to disable the limitation (i.e. it will search all blocks).

Default: 5


Enable timer debugging facility. When this is enabled, application can call pj_timer_heap_dump() to show the contents of the timer along with the source location where the timer entries were scheduled. See for more info.

Default: 1


If enabled, the timer will keep internal copies of the timer entries. This will increase the robustness and stability of the timer (against accidental modification or premature deallocation of the timer entries) and makes it easier to troubleshoot any timer related issues, with the overhead of additional memory space required.

Note that the detection against premature deallocation only works if the freed memory content has changed (such as if it’s been reallocated and overwritten by another data. Alternatively, you can enable PJ_POOL_RELEASE_WIPE_DATA which will erase the data first before releasing the memory).

Default: 1 (enabled)


If enabled, the timer use sorted linked list instead of binary heap tree structure. Note that using sorted linked list is intended for debugging purposes and will hamper performance significantly when scheduling large number of entries.

Default: 0 (Use binary heap tree)


Set this to 1 to enable debugging on the group lock. Default: 0


Specify this as stack_size argument in pj_thread_create() to specify that thread should use default stack size for the current platform.

Default: 8192


Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of the stack. The OS implementation may check that no stack overflow occurs, and it also may collect statistic about stack usage. Note that this will increase the footprint of the libraries since it tracks the filename and line number of each functions.


Do we have alternate pool implementation?

Default: 0


Support TCP in the library. Disabling TCP will reduce the footprint slightly (about 6KB).

Default: 1 Support IPv6 in the library. If this support is disabled, some IPv6 related functions will return PJ_EIPV6NOTSUP.

Default: 0 (disabled, for now)


Maximum hostname length. Libraries sometimes needs to make copy of an address to stack buffer; the value here affects the stack usage.

Note that the length here should include the NULL termination. In other words, the maximum hostname length is PJ_MAX_HOSTNAME with the NULL termination and PJ_MAX_HOSTNAME-1 without the NULL termination.

Default: 254


Maximum consecutive identical error for accept() operation before activesock stops calling the next ioqueue accept.

Default: 50


Constants for declaring the maximum handles that can be supported by a single IOQ framework. This constant might not be relevant to the underlying I/O queue impelementation, but still, developers should be aware of this constant, to make sure that the program will not break when the underlying implementation changes.


If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more things to ensure thread safety of handle unregistration operation by employing reference counter to each handle.

In addition, the ioqueue will preallocate memory for the handles, according to the maximum number of handles that is specified during ioqueue creation.

All applications would normally want this enabled, but you may disable this if:

  • there is no dynamic unregistration to all ioqueues.

  • there is no threading, or there is no preemptive multitasking.

Default: 1


Default concurrency setting for sockets/handles registered to ioqueue. This controls whether the ioqueue is allowed to call the key’s callback concurrently/in parallel. The default is yes, which means that if there are more than one pending operations complete simultaneously, more than one threads may call the key’s callback at the same time. This generally would promote good scalability for application, at the expense of more complexity to manage the concurrent accesses.

Please see the ioqueue documentation for more info.


When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the ioqueue key is kept in closing state before it can be reused.

The value is in miliseconds.

Default: 500 msec.


Default flags for epoll_flags member of pj_ioqueue_cfg structure. The values are combination of pj_ioqueue_epoll_flag constants.



Determine if FD_SETSIZE is changeable/set-able. If so, then we will set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking for Winsock.


Overrides FD_SETSIZE so it is consistent throughout the library. We only do this if we detected that FD_SETSIZE is changeable. If FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be set to value lower than FD_SETSIZE. Specify whether pj_enum_ip_interface() function should exclude loopback interfaces.

Default: 1


Has semaphore functionality?

Default: 1 Use dispatch semaphores on Darwin.

Default: 1 on Darwin, 0 otherwise


Event object (for synchronization, e.g. in Win32)

Default: 1 Maximum file name length.


Enable name registration for exceptions with pj_exception_id_alloc(). If this feature is enabled, then the library will keep track of names associated with each exception ID requested by application via pj_exception_id_alloc().

Disabling this macro will reduce the code and .bss size by a tad bit. See also PJ_MAX_EXCEPTION_ID.

Default: 1


Maximum number of unique exception IDs that can be requested with pj_exception_id_alloc(). For each entry, a small record will be allocated in the .bss segment.

Default: 16


Should we use Windows Structured Exception Handling (SEH) for the PJLIB exceptions.

Default: 0


Should we attempt to use Pentium’s rdtsc for high resolution timestamp.

Default: 0


Is native platform error positive number? Default: 1 (yes)


Include error message string in the library (pj_strerror()). This is very much desirable!

Default: 1


Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom functions to compare alnum strings. On some systems, they’re faster then stricmp/strcasecmp, but they can be slower on other systems. When disabled, pjlib will fallback to stricmp/strnicmp.

Default: 0


Prohibit the use of unsafe string functions such as strcpy(), strncpy(), strcat(), and vsprintf().


Prohibit the use of strcpy() and pj_ansi_strcpy(), use pj_ansi_strxcpy() instead.


Prohibit the use of strncpy() and pj_ansi_strncpy(), use pj_ansi_strxcpy() instead.


Prohibit the use of strcat() and pj_ansi_strcat(), use pj_ansi_strxcat() instead.


Prohibit the use of sprintf() and pj_ansi_sprintf(), use pj_ansi_snprintf() instead.


Prohibit the use of vsprintf() and pj_ansi_vsprintf(), use pj_ansi_vsnprintf() instead.


Dummy QoS backend implementation, will always return error on all the APIs.


QoS backend based on setsockopt(IP_TOS)


QoS backend for Windows Mobile 6


QoS backend for Symbian


QoS backend for Darwin


Force the use of some QoS backend API for some platforms. Enable secure socket. For most platforms, this is implemented using OpenSSL or GnuTLS, so this will require one of those libraries to be installed. For Symbian platform, this is implemented natively using CSecureSocket.

Default: 0 (for now)


Disable SSL socket


Using OpenSSL Using GnuTLS


Using Apple’s Secure Transport (deprecated in MacOS 10.15 & iOS 13.0)


Using Apple’s Network framework


Select which SSL socket implementation to use. Currently pjlib supports PJ_SSL_SOCK_IMP_OPENSSL, which uses OpenSSL, and PJ_SSL_SOCK_IMP_GNUTLS, which uses GnuTLS. Setting this to PJ_SSL_SOCK_IMP_NONE will disable secure socket.

Default is PJ_SSL_SOCK_IMP_NONE if PJ_HAS_SSL_SOCK is not set, otherwise it is PJ_SSL_SOCK_IMP_OPENSSL.


Define the maximum number of ciphers supported by the secure socket.

Default: 256


Specify what should be set as the available list of SSL_CIPHERs. For example, set this as “DEFAULT” to use the default cipher list (Note: PJSIP release 2.4 and before used this “DEFAULT” setting).



Define the maximum number of curves supported by the secure socket.

Default: 32


Use OpenSSL thread locking callback. This is only applicable for OpenSSL version prior to 1.1.0

Default: 1 (enabled)


Disable WSAECONNRESET error for UDP sockets on Win32 platforms. See

Default: 1


Maximum number of socket options in pj_sockopt_params.

Default: 4

  • type – The return type of the function. Expand the function as inline.


This macro declares platform/compiler specific specifier prefix to be added to symbol declaration to export the symbol when PJLIB is built as dynamic library.

This macro should have been added by platform specific headers, if the platform supports building dynamic library target.


This macro declares platform/compiler specific specifier prefix to be added to symbol definition to export the symbol when PJLIB is built as dynamic library.

This macro should have been added by platform specific headers, if the platform supports building dynamic library target.


This macro declares platform/compiler specific specifier prefix to be added to symbol declaration to import the symbol.

This macro should have been added by platform specific headers, if the platform supports building dynamic library target.


This macro has been deprecated. It will evaluate to nothing.

  • type – The return type of the function. Declare a function that will not return.

  • type – The return type of the function. Declare an inline function that will not return.


Mark beginning of declaration section in a header file.


Mark end of declaration section in a header file.

  • type – The data type. Define a global data.

  • type – The function’s return type. Declare a function that may be expanded as inline.

  • type – The function’s return type. Define a function that may be expanded as inline.

  • arg – The argument name. PJ_UNUSED_ARG prevents warning about unused argument in a function.

  • id – Any identifier that will be printed as TODO message. PJ_TODO macro will display TODO message as warning during compilation. Example: PJ_TODO(CLEAN_UP_ERROR);


Simulate race condition by sleeping the thread in strategic locations. Default: no!


Function attributes to inform that the function may throw exception.

  • x – The exception list, enclosed in parenthesis.