/src/pjsip/pjlib/include/pj/os.h
Line | Count | Source |
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_OS_H__ |
20 | | #define __PJ_OS_H__ |
21 | | |
22 | | /** |
23 | | * @file os.h |
24 | | * @brief OS dependent functions |
25 | | */ |
26 | | #include <pj/types.h> |
27 | | |
28 | | PJ_BEGIN_DECL |
29 | | |
30 | | /** |
31 | | * @defgroup PJ_OS Operating System Dependent Functionality. |
32 | | */ |
33 | | |
34 | | |
35 | | /* **************************************************************************/ |
36 | | /** |
37 | | * @defgroup PJ_SYS_INFO System Information |
38 | | * @ingroup PJ_OS |
39 | | * @{ |
40 | | */ |
41 | | |
42 | | /** |
43 | | * These enumeration contains constants to indicate support of miscellaneous |
44 | | * system features. These will go in "flags" field of #pj_sys_info structure. |
45 | | */ |
46 | | typedef enum pj_sys_info_flag |
47 | | { |
48 | | /** |
49 | | * Support for Apple iOS background feature. |
50 | | */ |
51 | | PJ_SYS_HAS_IOS_BG = 1 |
52 | | |
53 | | } pj_sys_info_flag; |
54 | | |
55 | | |
56 | | /** |
57 | | * This structure contains information about the system. Use #pj_get_sys_info() |
58 | | * to obtain the system information. |
59 | | */ |
60 | | typedef struct pj_sys_info |
61 | | { |
62 | | /** |
63 | | * Null terminated string containing processor information (e.g. "i386", |
64 | | * "x86_64"). It may contain empty string if the value cannot be obtained. |
65 | | */ |
66 | | pj_str_t machine; |
67 | | |
68 | | /** |
69 | | * Null terminated string identifying the system operation (e.g. "Linux", |
70 | | * "win32", "wince"). It may contain empty string if the value cannot be |
71 | | * obtained. |
72 | | */ |
73 | | pj_str_t os_name; |
74 | | |
75 | | /** |
76 | | * A number containing the operating system version number. By convention, |
77 | | * this field is divided into four bytes, where the highest order byte |
78 | | * contains the most major version of the OS, the next less significant |
79 | | * byte contains the less major version, and so on. How the OS version |
80 | | * number is mapped into these four bytes would be specific for each OS. |
81 | | * For example, Linux-2.6.32-28 would yield "os_ver" value of 0x0206201c, |
82 | | * while for Windows 7 it will be 0x06010000 (because dwMajorVersion is |
83 | | * 6 and dwMinorVersion is 1 for Windows 7). |
84 | | * |
85 | | * This field may contain zero if the OS version cannot be obtained. |
86 | | */ |
87 | | pj_uint32_t os_ver; |
88 | | |
89 | | /** |
90 | | * Null terminated string identifying the SDK name that is used to build |
91 | | * the library (e.g. "glibc", "uclibc", "msvc", "wince"). It may contain |
92 | | * empty string if the value cannot eb obtained. |
93 | | */ |
94 | | pj_str_t sdk_name; |
95 | | |
96 | | /** |
97 | | * A number containing the SDK version, using the numbering convention as |
98 | | * the "os_ver" field. The value will be zero if the version cannot be |
99 | | * obtained. |
100 | | */ |
101 | | pj_uint32_t sdk_ver; |
102 | | |
103 | | /** |
104 | | * A longer null terminated string identifying the underlying system with |
105 | | * as much information as possible. |
106 | | */ |
107 | | pj_str_t info; |
108 | | |
109 | | /** |
110 | | * Other flags containing system specific information. The value is |
111 | | * bitmask of #pj_sys_info_flag constants. |
112 | | */ |
113 | | pj_uint32_t flags; |
114 | | |
115 | | } pj_sys_info; |
116 | | |
117 | | |
118 | | /** |
119 | | * Obtain the system information. |
120 | | * |
121 | | * @return System information structure. |
122 | | */ |
123 | | PJ_DECL(const pj_sys_info*) pj_get_sys_info(void); |
124 | | |
125 | | /** |
126 | | * @} |
127 | | */ |
128 | | |
129 | | /* **************************************************************************/ |
130 | | /** |
131 | | * @defgroup PJ_THREAD Threads |
132 | | * @ingroup PJ_OS |
133 | | * @{ |
134 | | * This module provides multithreading API. |
135 | | * |
136 | | * \section pj_thread_examples_sec Examples |
137 | | * |
138 | | * For examples, please see: |
139 | | * - Thread test: \src{pjlib/src/pjlib-test/thread.c} |
140 | | * - Sleep, Time, and Timestamp test: \src{pjlib/src/pjlib-test/sleep.c} |
141 | | * |
142 | | */ |
143 | | |
144 | | /** |
145 | | * Thread creation flags: |
146 | | * - PJ_THREAD_SUSPENDED: specify that the thread should be created suspended. |
147 | | */ |
148 | | typedef enum pj_thread_create_flags |
149 | | { |
150 | | PJ_THREAD_SUSPENDED = 1 |
151 | | } pj_thread_create_flags; |
152 | | |
153 | | |
154 | | /** |
155 | | * Type of thread entry function. |
156 | | */ |
157 | | typedef int (PJ_THREAD_FUNC pj_thread_proc)(void*); |
158 | | |
159 | | /** |
160 | | * Size of thread struct. |
161 | | */ |
162 | | #if !defined(PJ_THREAD_DESC_SIZE) |
163 | | # define PJ_THREAD_DESC_SIZE (64) |
164 | | #endif |
165 | | |
166 | | /** |
167 | | * Thread structure, to thread's state when the thread is created by external |
168 | | * or native API. |
169 | | */ |
170 | | typedef long pj_thread_desc[PJ_THREAD_DESC_SIZE]; |
171 | | |
172 | | /** |
173 | | * Get process ID. |
174 | | * @return process ID. |
175 | | */ |
176 | | PJ_DECL(pj_uint32_t) pj_getpid(void); |
177 | | |
178 | | /** |
179 | | * Create a new thread. |
180 | | * |
181 | | * @param pool The memory pool from which the thread record |
182 | | * will be allocated from. |
183 | | * @param thread_name The optional name to be assigned to the thread. |
184 | | * @param proc Thread entry function. |
185 | | * @param arg Argument to be passed to the thread entry function. |
186 | | * @param stack_size The size of the stack for the new thread, in bytes. |
187 | | * Pass 0 to let the OS pick its default size; this is |
188 | | * honored on every platform regardless of |
189 | | * PJ_THREAD_SET_STACK_SIZE. Pass a non-zero value to |
190 | | * request a specific size; that request is propagated |
191 | | * to the OS thread API only when PJ_THREAD_SET_STACK_SIZE |
192 | | * is non-zero (the default is 0 on Linux/Mac/Windows |
193 | | * and 1 on rtems; can be enabled per-build via |
194 | | * config_site.h on any platform). For some systems, |
195 | | * the stack will be allocated from the pool, so the |
196 | | * pool must have suitable capacity. |
197 | | * @param flags Flags for thread creation, which is bitmask combination |
198 | | * from enum pj_thread_create_flags. |
199 | | * @param thread Pointer to hold the newly created thread. |
200 | | * |
201 | | * @return PJ_SUCCESS on success, or the error code. |
202 | | */ |
203 | | PJ_DECL(pj_status_t) pj_thread_create( pj_pool_t *pool, |
204 | | const char *thread_name, |
205 | | pj_thread_proc *proc, |
206 | | void *arg, |
207 | | pj_size_t stack_size, |
208 | | unsigned flags, |
209 | | pj_thread_t **thread ); |
210 | | |
211 | | /** |
212 | | * Create a new thread, use preallocated space for thread descriptor |
213 | | * and thread stack. |
214 | | * To avoid pool allocation, function does not support suspended thread. |
215 | | * |
216 | | * |
217 | | * @param thread_name The optional name to be assigned to the thread. |
218 | | * @param proc Thread entry function. |
219 | | * @param arg Argument to be passed to the thread entry function. |
220 | | * @param stack_size The size of the stack for the new thread, in bytes. |
221 | | * Pass 0 to let the OS pick its default size; this is |
222 | | * honored on every platform regardless of |
223 | | * PJ_THREAD_SET_STACK_SIZE. Pass a non-zero value to |
224 | | * request a specific size; that request is propagated |
225 | | * to the OS thread API only when PJ_THREAD_SET_STACK_SIZE |
226 | | * is non-zero (the default is 0 on Linux/Mac/Windows |
227 | | * and 1 on rtems; can be enabled per-build via |
228 | | * config_site.h on any platform). |
229 | | * Note: on platforms where PJ_THREAD_ALLOCATE_STACK is |
230 | | * non-zero (e.g. rtems), the caller must provide a |
231 | | * non-zero stack_size matching the size of stack_addr; |
232 | | * passing 0 is not valid in that case. |
233 | | * @param stack_addr Preallocated space of size stack_size for the stack |
234 | | * for the new thread, used if PJ_THREAD_ALLOCATE_STACK |
235 | | * macro defined and is not 0. Otherwise ignored. |
236 | | * @param thread Pointer to preallocated thread descriptor to hold |
237 | | * the newly created thread. |
238 | | * |
239 | | * @return PJ_SUCCESS on success, or the error code. |
240 | | */ |
241 | | PJ_DECL(pj_status_t) pj_thread_create2( const char *thread_name, |
242 | | pj_thread_proc *proc, |
243 | | void *arg, |
244 | | pj_size_t stack_size, |
245 | | void *stack_addr, |
246 | | pj_thread_t *thread ); |
247 | | |
248 | | /** |
249 | | * Register a thread that was created by external or native API to PJLIB. |
250 | | * This function must be called in the context of the thread being registered. |
251 | | * When the thread is created by external function or API call, |
252 | | * it must be 'registered' to PJLIB using pj_thread_register(), so that it can |
253 | | * cooperate with PJLIB's framework. During registration, some data needs to |
254 | | * be maintained, and this data must remain available during the thread's |
255 | | * lifetime. |
256 | | * |
257 | | * @param thread_name The optional name to be assigned to the thread. |
258 | | * @param desc Thread descriptor, which must be available throughout |
259 | | * the lifetime of the thread. |
260 | | * @param thread Pointer to hold the created thread handle. |
261 | | * |
262 | | * @return PJ_SUCCESS on success, or the error code. |
263 | | */ |
264 | | PJ_DECL(pj_status_t) pj_thread_register ( const char *thread_name, |
265 | | pj_thread_desc desc, |
266 | | pj_thread_t **thread); |
267 | | |
268 | | |
269 | | /** |
270 | | * Detach pjsip library from the current thread without terminating |
271 | | * the OS thread, frees the resources allocated by pjlib for the calling thread, |
272 | | * including freeing the tls slot in which pj_thread_t is stored. |
273 | | * However, the memory allocated for the pj_thread_t itself will only be released |
274 | | * when the pool used to create the thread is destroyed. |
275 | | * |
276 | | * An application should call this function when leaving threads created by |
277 | | * an external module (e.g. audio thread, threads from an external thread pool, |
278 | | * etc). Such a thread is registered with pj_thread_register() and detached |
279 | | * with pj_thread_unregister() when finished using. |
280 | | * |
281 | | * @return PJ_SUCCESS on success. |
282 | | */ |
283 | | PJ_DECL(pj_status_t) pj_thread_unregister(void); |
284 | | |
285 | | /** |
286 | | * Register a thread that was created by external or native API to PJLIB. |
287 | | * |
288 | | * This function is a complete copy of pj_thread_register(), with the only |
289 | | * difference being that on Windows it returns a pj_thread_t suitable for |
290 | | * waiting for the thread to terminate. This function should only be used |
291 | | * if the application requires calling pj_thread_join() for the current thread; |
292 | | * otherwise, use pj_thread_register(). |
293 | | * |
294 | | * @param thread_name The optional name to be assigned to the thread. |
295 | | * @param desc Thread descriptor, which must be available throughout |
296 | | * the lifetime of the thread. |
297 | | * @param thread Pointer to hold the created thread handle. |
298 | | * |
299 | | * @return PJ_SUCCESS on success, or the error code. |
300 | | * |
301 | | * @see pj_thread_register() |
302 | | */ |
303 | | PJ_DECL(pj_status_t) pj_thread_attach ( const char *thread_name, |
304 | | pj_thread_desc desc, |
305 | | pj_thread_t **thread); |
306 | | |
307 | | |
308 | | /** |
309 | | * Check if this thread has been registered to PJLIB. |
310 | | * |
311 | | * @return Non-zero if it is registered. |
312 | | */ |
313 | | PJ_DECL(pj_bool_t) pj_thread_is_registered(void); |
314 | | |
315 | | |
316 | | /** |
317 | | * Get thread priority value for the thread. |
318 | | * |
319 | | * @param thread Thread handle. |
320 | | * |
321 | | * @return Thread priority value, or -1 on error. |
322 | | */ |
323 | | PJ_DECL(int) pj_thread_get_prio(pj_thread_t *thread); |
324 | | |
325 | | |
326 | | /** |
327 | | * Set the thread priority. The priority value must be in the priority |
328 | | * value range, which can be retrieved with #pj_thread_get_prio_min() and |
329 | | * #pj_thread_get_prio_max() functions. |
330 | | * |
331 | | * For Android, this function will only set the priority of the calling thread |
332 | | * (the thread param must be set to NULL or the calling thread handle). |
333 | | * |
334 | | * @param thread Thread handle. |
335 | | * @param prio New priority to be set to the thread. |
336 | | * |
337 | | * @return PJ_SUCCESS on success or the error code. |
338 | | */ |
339 | | PJ_DECL(pj_status_t) pj_thread_set_prio(pj_thread_t *thread, int prio); |
340 | | |
341 | | /** |
342 | | * Get the lowest priority value available for this thread. |
343 | | * |
344 | | * @param thread Thread handle. |
345 | | * @return Minimum thread priority value, or -1 on error. |
346 | | */ |
347 | | PJ_DECL(int) pj_thread_get_prio_min(pj_thread_t *thread); |
348 | | |
349 | | |
350 | | /** |
351 | | * Get the highest priority value available for this thread. |
352 | | * |
353 | | * @param thread Thread handle. |
354 | | * @return Minimum thread priority value, or -1 on error. |
355 | | */ |
356 | | PJ_DECL(int) pj_thread_get_prio_max(pj_thread_t *thread); |
357 | | |
358 | | |
359 | | /** |
360 | | * Return native handle from pj_thread_t for manipulation using native |
361 | | * OS APIs. |
362 | | * |
363 | | * @param thread PJLIB thread descriptor. |
364 | | * |
365 | | * @return Native thread handle. For example, when the |
366 | | * backend thread uses pthread, this function will |
367 | | * return pointer to pthread_t, and on Windows, |
368 | | * this function will return HANDLE. |
369 | | */ |
370 | | PJ_DECL(void*) pj_thread_get_os_handle(pj_thread_t *thread); |
371 | | |
372 | | /** |
373 | | * Get thread name. |
374 | | * |
375 | | * @param thread The thread handle. |
376 | | * |
377 | | * @return Thread name as null terminated string. |
378 | | */ |
379 | | PJ_DECL(const char*) pj_thread_get_name(pj_thread_t *thread); |
380 | | |
381 | | /** |
382 | | * Resume a suspended thread. |
383 | | * |
384 | | * @param thread The thread handle. |
385 | | * |
386 | | * @return zero on success. |
387 | | */ |
388 | | PJ_DECL(pj_status_t) pj_thread_resume(pj_thread_t *thread); |
389 | | |
390 | | /** |
391 | | * Get the current thread. |
392 | | * |
393 | | * @return Thread handle of current thread. |
394 | | */ |
395 | | PJ_DECL(pj_thread_t*) pj_thread_this(void); |
396 | | |
397 | | /** |
398 | | * Join thread, and block the caller thread until the specified thread exits. |
399 | | * If it is called from within the thread itself, it will return immediately |
400 | | * with failure status. |
401 | | * If the specified thread has already been dead, or it does not exist, |
402 | | * the function will return immediately with successful status. |
403 | | * |
404 | | * @param thread The thread handle. |
405 | | * |
406 | | * @return PJ_SUCCESS on success. |
407 | | */ |
408 | | PJ_DECL(pj_status_t) pj_thread_join(pj_thread_t *thread); |
409 | | |
410 | | |
411 | | /** |
412 | | * Destroy thread and release resources allocated for the thread. |
413 | | * However, the memory allocated for the pj_thread_t itself will only be released |
414 | | * when the pool used to create the thread is destroyed. |
415 | | * |
416 | | * @param thread The thread handle. |
417 | | * |
418 | | * @return zero on success. |
419 | | */ |
420 | | PJ_DECL(pj_status_t) pj_thread_destroy(pj_thread_t *thread); |
421 | | |
422 | | |
423 | | /** |
424 | | * Put the current thread to sleep for the specified miliseconds. |
425 | | * |
426 | | * @param msec Miliseconds delay. |
427 | | * |
428 | | * @return zero if successfull. |
429 | | */ |
430 | | PJ_DECL(pj_status_t) pj_thread_sleep(unsigned msec); |
431 | | |
432 | | /** |
433 | | * @def PJ_CHECK_STACK() |
434 | | * PJ_CHECK_STACK() macro is used to check the sanity of the stack. |
435 | | * The OS implementation may check that no stack overflow occurs, and |
436 | | * it also may collect statistic about stack usage. |
437 | | */ |
438 | | #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 |
439 | | |
440 | | # define PJ_CHECK_STACK() pj_thread_check_stack(__FILE__, __LINE__) |
441 | | |
442 | | /** @internal |
443 | | * The implementation of stack checking. |
444 | | */ |
445 | | PJ_DECL(void) pj_thread_check_stack(const char *file, int line); |
446 | | |
447 | | /** @internal |
448 | | * Get maximum stack usage statistic. |
449 | | */ |
450 | | PJ_DECL(pj_uint32_t) pj_thread_get_stack_max_usage(pj_thread_t *thread); |
451 | | |
452 | | /** @internal |
453 | | * Dump thread stack status. |
454 | | */ |
455 | | PJ_DECL(pj_status_t) pj_thread_get_stack_info(pj_thread_t *thread, |
456 | | const char **file, |
457 | | int *line); |
458 | | #else |
459 | | |
460 | | # define PJ_CHECK_STACK() |
461 | | /** pj_thread_get_stack_max_usage() for the thread */ |
462 | | # define pj_thread_get_stack_max_usage(thread) 0 |
463 | | /** pj_thread_get_stack_info() for the thread */ |
464 | | # define pj_thread_get_stack_info(thread,f,l) (*(f)="",*(l)=0) |
465 | | #endif /* PJ_OS_HAS_CHECK_STACK */ |
466 | | |
467 | | /** |
468 | | * @} |
469 | | */ |
470 | | |
471 | | /* **************************************************************************/ |
472 | | /** |
473 | | * @defgroup PJ_JNI Java Native Interface specific |
474 | | * @ingroup PJ_OS |
475 | | * @{ |
476 | | * Functionalities specific to JNI. |
477 | | * Currently only implemented on Android OS, but may be extended to other |
478 | | * platforms in the future. |
479 | | * |
480 | | */ |
481 | | |
482 | | /** |
483 | | * Set the Java Virtual Machine environment variable. |
484 | | * Note that applications typically do not need to call this function unless |
485 | | * PJ_JNI_HAS_JNI_ONLOAD is disabled. |
486 | | * |
487 | | * @param jvm The Java Virtual Machine environment. |
488 | | */ |
489 | | PJ_DECL(void) pj_jni_set_jvm(void *jvm); |
490 | | |
491 | | /** |
492 | | * Attach the current thread to a Java Virtual Machine. |
493 | | * |
494 | | * @param jni_env Output parameter to store the JNI interface pointer. |
495 | | * |
496 | | * @return PJ_TRUE if the attachment is successful, |
497 | | * PJ_FALSE if otherwise. |
498 | | */ |
499 | | PJ_DECL(pj_bool_t) pj_jni_attach_jvm(void **jni_env); |
500 | | |
501 | | /** |
502 | | * Detach the current thread from a Java Virtual Machine. |
503 | | * |
504 | | * @param attached Specify whether the current thread is attached |
505 | | * to a JVM. |
506 | | */ |
507 | | PJ_DECL(void) pj_jni_detach_jvm(pj_bool_t attached); |
508 | | |
509 | | |
510 | | /** |
511 | | * @} |
512 | | */ |
513 | | |
514 | | /* **************************************************************************/ |
515 | | /** |
516 | | * @defgroup PJ_SYMBIAN_OS Symbian OS Specific |
517 | | * @ingroup PJ_OS |
518 | | * @{ |
519 | | * Functionalities specific to Symbian OS. |
520 | | * |
521 | | * Symbian OS strongly discourages the use of polling since this wastes |
522 | | * CPU power, and instead provides Active Object and Active Scheduler |
523 | | * pattern to allow application (in this case, PJLIB) to register asynchronous |
524 | | * tasks. PJLIB port for Symbian complies to this recommended behavior. |
525 | | * As the result, few things have been changed in PJLIB for Symbian: |
526 | | * - the timer heap (see @ref PJ_TIMER) is implemented with active |
527 | | * object framework, and each timer entry registered to the timer |
528 | | * heap will register an Active Object to the Active Scheduler. |
529 | | * Because of this, polling the timer heap with pj_timer_heap_poll() |
530 | | * is no longer necessary, and this function will just evaluate |
531 | | * to nothing. |
532 | | * - the ioqueue (see @ref PJ_IOQUEUE) is also implemented with |
533 | | * active object framework, with each asynchronous operation will |
534 | | * register an Active Object to the Active Scheduler. Because of |
535 | | * this, polling the ioqueue with pj_ioqueue_poll() is no longer |
536 | | * necessary, and this function will just evaluate to nothing. |
537 | | * |
538 | | * Since timer heap and ioqueue polling are no longer necessary, Symbian |
539 | | * application can now poll for all events by calling |
540 | | * \a User::WaitForAnyRequest() and \a CActiveScheduler::RunIfReady(). |
541 | | * PJLIB provides a thin wrapper which calls these two functions, |
542 | | * called pj_symbianos_poll(). |
543 | | */ |
544 | | |
545 | | /** |
546 | | * Wait the completion of any Symbian active objects. When the timeout |
547 | | * value is not specified (the \a ms_timeout argument is -1), this |
548 | | * function is a thin wrapper which calls \a User::WaitForAnyRequest() |
549 | | * and \a CActiveScheduler::RunIfReady(). If the timeout value is |
550 | | * specified, this function will schedule a timer entry to the timer |
551 | | * heap (which is an Active Object), to limit the wait time for event |
552 | | * occurences. Scheduling a timer entry is an expensive operation, |
553 | | * therefore application should only specify a timeout value when it's |
554 | | * really necessary (for example, when it's not sure there are other |
555 | | * Active Objects currently running in the application). |
556 | | * |
557 | | * @param priority The minimum priority of the Active Objects to |
558 | | * poll, which values are from CActive::TPriority |
559 | | * constants. If -1 is given, CActive::EPriorityStandard. |
560 | | * priority will be used. |
561 | | * @param ms_timeout Optional timeout to wait. Application should |
562 | | * specify -1 to let the function wait indefinitely |
563 | | * for any events. |
564 | | * |
565 | | * @return PJ_TRUE if there have been any events executed |
566 | | * during the polling. This function will only return |
567 | | * PJ_FALSE if \a ms_timeout argument is specified |
568 | | * (i.e. the value is not -1) and there was no event |
569 | | * executed when the timeout timer elapsed. |
570 | | */ |
571 | | PJ_DECL(pj_bool_t) pj_symbianos_poll(int priority, int ms_timeout); |
572 | | |
573 | | |
574 | | /** |
575 | | * This structure declares Symbian OS specific parameters that can be |
576 | | * specified when calling #pj_symbianos_set_params(). |
577 | | */ |
578 | | typedef struct pj_symbianos_params |
579 | | { |
580 | | /** |
581 | | * Optional RSocketServ instance to be used by PJLIB. If this |
582 | | * value is NULL, PJLIB will create a new RSocketServ instance |
583 | | * when pj_init() is called. |
584 | | */ |
585 | | void *rsocketserv; |
586 | | |
587 | | /** |
588 | | * Optional RConnection instance to be used by PJLIB when creating |
589 | | * sockets. If this value is NULL, no RConnection will be |
590 | | * specified when creating sockets. |
591 | | */ |
592 | | void *rconnection; |
593 | | |
594 | | /** |
595 | | * Optional RHostResolver instance to be used by PJLIB. If this value |
596 | | * is NULL, a new RHostResolver instance will be created when |
597 | | * pj_init() is called. |
598 | | */ |
599 | | void *rhostresolver; |
600 | | |
601 | | /** |
602 | | * Optional RHostResolver for IPv6 instance to be used by PJLIB. |
603 | | * If this value is NULL, a new RHostResolver instance will be created |
604 | | * when pj_init() is called. |
605 | | */ |
606 | | void *rhostresolver6; |
607 | | |
608 | | } pj_symbianos_params; |
609 | | |
610 | | /** |
611 | | * Specify Symbian OS parameters to be used by PJLIB. This function MUST |
612 | | * be called before #pj_init() is called. |
613 | | * |
614 | | * @param prm Symbian specific parameters. |
615 | | * |
616 | | * @return PJ_SUCCESS if the parameters can be applied |
617 | | * successfully. |
618 | | */ |
619 | | PJ_DECL(pj_status_t) pj_symbianos_set_params(pj_symbianos_params *prm); |
620 | | |
621 | | /** |
622 | | * Notify PJLIB that the access point connection has been down or unusable |
623 | | * and PJLIB should not try to access the Symbian socket API (especially ones |
624 | | * that send packets). Sending packet when RConnection is reconnected to |
625 | | * different access point may cause the WaitForRequest() for the function to |
626 | | * block indefinitely. |
627 | | * |
628 | | * @param up If set to PJ_FALSE it will cause PJLIB to not try |
629 | | * to access socket API, and error will be returned |
630 | | * immediately instead. |
631 | | */ |
632 | | PJ_DECL(void) pj_symbianos_set_connection_status(pj_bool_t up); |
633 | | |
634 | | /** |
635 | | * @} |
636 | | */ |
637 | | |
638 | | /* **************************************************************************/ |
639 | | /** |
640 | | * @defgroup PJ_TLS Thread Local Storage. |
641 | | * @ingroup PJ_OS |
642 | | * @{ |
643 | | */ |
644 | | |
645 | | /** |
646 | | * Allocate thread local storage index. The initial value of the variable at |
647 | | * the index is zero. |
648 | | * |
649 | | * @param index Pointer to hold the return value. |
650 | | * @return PJ_SUCCESS on success, or the error code. |
651 | | */ |
652 | | PJ_DECL(pj_status_t) pj_thread_local_alloc(long *index); |
653 | | |
654 | | /** |
655 | | * Deallocate thread local variable. |
656 | | * |
657 | | * @param index The variable index. |
658 | | */ |
659 | | PJ_DECL(void) pj_thread_local_free(long index); |
660 | | |
661 | | /** |
662 | | * Set the value of thread local variable. |
663 | | * |
664 | | * @param index The index of the variable. |
665 | | * @param value The value. |
666 | | */ |
667 | | PJ_DECL(pj_status_t) pj_thread_local_set(long index, void *value); |
668 | | |
669 | | /** |
670 | | * Get the value of thread local variable. |
671 | | * |
672 | | * @param index The index of the variable. |
673 | | * @return The value. |
674 | | */ |
675 | | PJ_DECL(void*) pj_thread_local_get(long index); |
676 | | |
677 | | |
678 | | /** |
679 | | * @} |
680 | | */ |
681 | | |
682 | | |
683 | | /* **************************************************************************/ |
684 | | /** |
685 | | * @defgroup PJ_ATOMIC Atomic Variables |
686 | | * @ingroup PJ_OS |
687 | | * @{ |
688 | | * |
689 | | * This module provides API to manipulate atomic variables. |
690 | | * |
691 | | * \section pj_atomic_examples_sec Examples |
692 | | * |
693 | | * For some example codes, please see: |
694 | | * - Atomic Variable test: \src{pjlib/src/pjlib-test/atomic.c} |
695 | | */ |
696 | | |
697 | | |
698 | | /** |
699 | | * Create atomic variable. |
700 | | * |
701 | | * @param pool The pool. |
702 | | * @param initial The initial value of the atomic variable. |
703 | | * @param atomic Pointer to hold the atomic variable upon return. |
704 | | * |
705 | | * @return PJ_SUCCESS on success, or the error code. |
706 | | */ |
707 | | PJ_DECL(pj_status_t) pj_atomic_create( pj_pool_t *pool, |
708 | | pj_atomic_value_t initial, |
709 | | pj_atomic_t **atomic ); |
710 | | |
711 | | /** |
712 | | * Destroy atomic variable. |
713 | | * |
714 | | * @param atomic_var the atomic variable. |
715 | | * |
716 | | * @return PJ_SUCCESS if success. |
717 | | */ |
718 | | PJ_DECL(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var ); |
719 | | |
720 | | /** |
721 | | * Set the value of an atomic type, and return the previous value. |
722 | | * |
723 | | * @param atomic_var the atomic variable. |
724 | | * @param value value to be set to the variable. |
725 | | */ |
726 | | PJ_DECL(void) pj_atomic_set( pj_atomic_t *atomic_var, |
727 | | pj_atomic_value_t value); |
728 | | |
729 | | /** |
730 | | * Get the value of an atomic type. |
731 | | * |
732 | | * @param atomic_var the atomic variable. |
733 | | * |
734 | | * @return the value of the atomic variable. |
735 | | */ |
736 | | PJ_DECL(pj_atomic_value_t) pj_atomic_get(pj_atomic_t *atomic_var); |
737 | | |
738 | | /** |
739 | | * Increment the value of an atomic type. |
740 | | * |
741 | | * @param atomic_var the atomic variable. |
742 | | */ |
743 | | PJ_DECL(void) pj_atomic_inc(pj_atomic_t *atomic_var); |
744 | | |
745 | | /** |
746 | | * Increment the value of an atomic type and get the result. |
747 | | * |
748 | | * @param atomic_var the atomic variable. |
749 | | * |
750 | | * @return The incremented value. |
751 | | */ |
752 | | PJ_DECL(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var); |
753 | | |
754 | | /** |
755 | | * Decrement the value of an atomic type. |
756 | | * |
757 | | * @param atomic_var the atomic variable. |
758 | | */ |
759 | | PJ_DECL(void) pj_atomic_dec(pj_atomic_t *atomic_var); |
760 | | |
761 | | /** |
762 | | * Decrement the value of an atomic type and get the result. |
763 | | * |
764 | | * @param atomic_var the atomic variable. |
765 | | * |
766 | | * @return The decremented value. |
767 | | */ |
768 | | PJ_DECL(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var); |
769 | | |
770 | | /** |
771 | | * Add a value to an atomic type. |
772 | | * |
773 | | * @param atomic_var The atomic variable. |
774 | | * @param value Value to be added. |
775 | | */ |
776 | | PJ_DECL(void) pj_atomic_add( pj_atomic_t *atomic_var, |
777 | | pj_atomic_value_t value); |
778 | | |
779 | | /** |
780 | | * Add a value to an atomic type and get the result. |
781 | | * |
782 | | * @param atomic_var The atomic variable. |
783 | | * @param value Value to be added. |
784 | | * |
785 | | * @return The result after the addition. |
786 | | */ |
787 | | PJ_DECL(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var, |
788 | | pj_atomic_value_t value); |
789 | | |
790 | | /** |
791 | | * @} |
792 | | */ |
793 | | |
794 | | /* **************************************************************************/ |
795 | | /** |
796 | | * @defgroup PJ_MUTEX Mutexes. |
797 | | * @ingroup PJ_OS |
798 | | * @{ |
799 | | * |
800 | | * Mutex manipulation. Alternatively, application can use higher abstraction |
801 | | * for lock objects, which provides uniform API for all kinds of lock |
802 | | * mechanisms, including mutex. See @ref PJ_LOCK for more information. |
803 | | */ |
804 | | |
805 | | /** |
806 | | * Mutex types: |
807 | | * - PJ_MUTEX_DEFAULT: default mutex type, which is system dependent. |
808 | | * - PJ_MUTEX_SIMPLE: non-recursive mutex. |
809 | | * - PJ_MUTEX_RECURSE: recursive mutex. |
810 | | */ |
811 | | typedef enum pj_mutex_type_e |
812 | | { |
813 | | PJ_MUTEX_DEFAULT, |
814 | | PJ_MUTEX_SIMPLE, |
815 | | PJ_MUTEX_RECURSE |
816 | | } pj_mutex_type_e; |
817 | | |
818 | | |
819 | | /** |
820 | | * Create mutex of the specified type. |
821 | | * |
822 | | * @param pool The pool. |
823 | | * @param name Name to be associated with the mutex (for debugging). |
824 | | * @param type The type of the mutex, of type #pj_mutex_type_e. |
825 | | * @param mutex Pointer to hold the returned mutex instance. |
826 | | * |
827 | | * @return PJ_SUCCESS on success, or the error code. |
828 | | */ |
829 | | PJ_DECL(pj_status_t) pj_mutex_create(pj_pool_t *pool, |
830 | | const char *name, |
831 | | int type, |
832 | | pj_mutex_t **mutex); |
833 | | |
834 | | /** |
835 | | * Create simple, non-recursive mutex. |
836 | | * This function is a simple wrapper for #pj_mutex_create to create |
837 | | * non-recursive mutex. |
838 | | * |
839 | | * @param pool The pool. |
840 | | * @param name Mutex name. |
841 | | * @param mutex Pointer to hold the returned mutex instance. |
842 | | * |
843 | | * @return PJ_SUCCESS on success, or the error code. |
844 | | */ |
845 | | PJ_DECL(pj_status_t) pj_mutex_create_simple( pj_pool_t *pool, const char *name, |
846 | | pj_mutex_t **mutex ); |
847 | | |
848 | | /** |
849 | | * Create recursive mutex. |
850 | | * This function is a simple wrapper for #pj_mutex_create to create |
851 | | * recursive mutex. |
852 | | * |
853 | | * @param pool The pool. |
854 | | * @param name Mutex name. |
855 | | * @param mutex Pointer to hold the returned mutex instance. |
856 | | * |
857 | | * @return PJ_SUCCESS on success, or the error code. |
858 | | */ |
859 | | PJ_DECL(pj_status_t) pj_mutex_create_recursive( pj_pool_t *pool, |
860 | | const char *name, |
861 | | pj_mutex_t **mutex ); |
862 | | |
863 | | /** |
864 | | * Acquire mutex lock. |
865 | | * |
866 | | * @param mutex The mutex. |
867 | | * @return PJ_SUCCESS on success, or the error code. |
868 | | */ |
869 | | PJ_DECL(pj_status_t) pj_mutex_lock(pj_mutex_t *mutex); |
870 | | |
871 | | /** |
872 | | * Release mutex lock. |
873 | | * |
874 | | * @param mutex The mutex. |
875 | | * @return PJ_SUCCESS on success, or the error code. |
876 | | */ |
877 | | PJ_DECL(pj_status_t) pj_mutex_unlock(pj_mutex_t *mutex); |
878 | | |
879 | | /** |
880 | | * Try to acquire mutex lock. |
881 | | * |
882 | | * @param mutex The mutex. |
883 | | * @return PJ_SUCCESS on success, or the error code if the |
884 | | * lock couldn't be acquired. |
885 | | */ |
886 | | PJ_DECL(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex); |
887 | | |
888 | | /** |
889 | | * Destroy mutex. |
890 | | * |
891 | | * @param mutex Te mutex. |
892 | | * @return PJ_SUCCESS on success, or the error code. |
893 | | */ |
894 | | PJ_DECL(pj_status_t) pj_mutex_destroy(pj_mutex_t *mutex); |
895 | | |
896 | | /** |
897 | | * Determine whether calling thread is owning the mutex (only available when |
898 | | * PJ_DEBUG is set). |
899 | | * @param mutex The mutex. |
900 | | * @return Non-zero if yes. |
901 | | */ |
902 | | PJ_DECL(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex); |
903 | | |
904 | | /** |
905 | | * @} |
906 | | */ |
907 | | |
908 | | /* **************************************************************************/ |
909 | | /** |
910 | | * @defgroup PJ_RW_MUTEX Reader/Writer Mutex |
911 | | * @ingroup PJ_OS |
912 | | * @{ |
913 | | * Reader/writer mutex is a classic synchronization object where multiple |
914 | | * readers can acquire the mutex, but only a single writer can acquire the |
915 | | * mutex. |
916 | | */ |
917 | | |
918 | | /** |
919 | | * Opaque declaration for reader/writer mutex. |
920 | | * Reader/writer mutex is a classic synchronization object where multiple |
921 | | * readers can acquire the mutex, but only a single writer can acquire the |
922 | | * mutex. |
923 | | */ |
924 | | typedef struct pj_rwmutex_t pj_rwmutex_t; |
925 | | |
926 | | /** |
927 | | * Create reader/writer mutex. |
928 | | * |
929 | | * @param pool Pool to allocate memory for the mutex. |
930 | | * @param name Name to be assigned to the mutex. |
931 | | * @param mutex Pointer to receive the newly created mutex. |
932 | | * |
933 | | * @return PJ_SUCCESS on success, or the error code. |
934 | | */ |
935 | | PJ_DECL(pj_status_t) pj_rwmutex_create(pj_pool_t *pool, const char *name, |
936 | | pj_rwmutex_t **mutex); |
937 | | |
938 | | /** |
939 | | * Lock the mutex for reading. |
940 | | * |
941 | | * @param mutex The mutex. |
942 | | * @return PJ_SUCCESS on success, or the error code. |
943 | | */ |
944 | | PJ_DECL(pj_status_t) pj_rwmutex_lock_read(pj_rwmutex_t *mutex); |
945 | | |
946 | | /** |
947 | | * Lock the mutex for writing. |
948 | | * |
949 | | * @param mutex The mutex. |
950 | | * @return PJ_SUCCESS on success, or the error code. |
951 | | */ |
952 | | PJ_DECL(pj_status_t) pj_rwmutex_lock_write(pj_rwmutex_t *mutex); |
953 | | |
954 | | /** |
955 | | * Release read lock. |
956 | | * |
957 | | * @param mutex The mutex. |
958 | | * @return PJ_SUCCESS on success, or the error code. |
959 | | */ |
960 | | PJ_DECL(pj_status_t) pj_rwmutex_unlock_read(pj_rwmutex_t *mutex); |
961 | | |
962 | | /** |
963 | | * Release write lock. |
964 | | * |
965 | | * @param mutex The mutex. |
966 | | * @return PJ_SUCCESS on success, or the error code. |
967 | | */ |
968 | | PJ_DECL(pj_status_t) pj_rwmutex_unlock_write(pj_rwmutex_t *mutex); |
969 | | |
970 | | /** |
971 | | * Destroy reader/writer mutex. |
972 | | * |
973 | | * @param mutex The mutex. |
974 | | * @return PJ_SUCCESS on success, or the error code. |
975 | | */ |
976 | | PJ_DECL(pj_status_t) pj_rwmutex_destroy(pj_rwmutex_t *mutex); |
977 | | |
978 | | |
979 | | /** |
980 | | * @} |
981 | | */ |
982 | | |
983 | | |
984 | | /* **************************************************************************/ |
985 | | /** |
986 | | * @defgroup PJ_CRIT_SEC Critical sections. |
987 | | * @ingroup PJ_OS |
988 | | * @{ |
989 | | * Critical section protection can be used to protect regions where: |
990 | | * - mutual exclusion protection is needed. |
991 | | * - it's rather too expensive to create a mutex. |
992 | | * - the time spent in the region is very very brief. |
993 | | * |
994 | | * Critical section is a global object, and it prevents any threads from |
995 | | * entering any regions that are protected by critical section once a thread |
996 | | * is already in the section. |
997 | | * |
998 | | * Critial section is \a not recursive! |
999 | | * |
1000 | | * Application <b>MUST NOT</b> call any functions that may cause current |
1001 | | * thread to block (such as allocating memory, performing I/O, locking mutex, |
1002 | | * etc.) while holding the critical section. |
1003 | | */ |
1004 | | /** |
1005 | | * Enter critical section. |
1006 | | */ |
1007 | | PJ_DECL(void) pj_enter_critical_section(void); |
1008 | | |
1009 | | /** |
1010 | | * Leave critical section. |
1011 | | */ |
1012 | | PJ_DECL(void) pj_leave_critical_section(void); |
1013 | | |
1014 | | /** |
1015 | | * @} |
1016 | | */ |
1017 | | |
1018 | | /* **************************************************************************/ |
1019 | | #if defined(PJ_HAS_SEMAPHORE) && PJ_HAS_SEMAPHORE != 0 |
1020 | | /** |
1021 | | * @defgroup PJ_SEM Semaphores. |
1022 | | * @ingroup PJ_OS |
1023 | | * @{ |
1024 | | * |
1025 | | * This module provides abstraction for semaphores, where available. |
1026 | | */ |
1027 | | |
1028 | | /** |
1029 | | * Create semaphore. |
1030 | | * |
1031 | | * @param pool The pool. |
1032 | | * @param name Name to be assigned to the semaphore (for logging purpose) |
1033 | | * @param initial The initial count of the semaphore. |
1034 | | * @param max The maximum count of the semaphore. |
1035 | | * @param sem Pointer to hold the semaphore created. |
1036 | | * |
1037 | | * @return PJ_SUCCESS on success, or the error code. |
1038 | | */ |
1039 | | PJ_DECL(pj_status_t) pj_sem_create( pj_pool_t *pool, |
1040 | | const char *name, |
1041 | | unsigned initial, |
1042 | | unsigned max, |
1043 | | pj_sem_t **sem); |
1044 | | |
1045 | | /** |
1046 | | * Wait for semaphore. |
1047 | | * |
1048 | | * @param sem The semaphore. |
1049 | | * |
1050 | | * @return PJ_SUCCESS on success, or the error code. |
1051 | | */ |
1052 | | PJ_DECL(pj_status_t) pj_sem_wait(pj_sem_t *sem); |
1053 | | |
1054 | | /** |
1055 | | * Try wait for semaphore. |
1056 | | * |
1057 | | * @param sem The semaphore. |
1058 | | * |
1059 | | * @return PJ_SUCCESS on success, or the error code. |
1060 | | */ |
1061 | | PJ_DECL(pj_status_t) pj_sem_trywait(pj_sem_t *sem); |
1062 | | |
1063 | | /** |
1064 | | * Release semaphore. |
1065 | | * |
1066 | | * @param sem The semaphore. |
1067 | | * |
1068 | | * @return PJ_SUCCESS on success, or the error code. |
1069 | | */ |
1070 | | PJ_DECL(pj_status_t) pj_sem_post(pj_sem_t *sem); |
1071 | | |
1072 | | /** |
1073 | | * Destroy semaphore. |
1074 | | * |
1075 | | * @param sem The semaphore. |
1076 | | * |
1077 | | * @return PJ_SUCCESS on success, or the error code. |
1078 | | */ |
1079 | | PJ_DECL(pj_status_t) pj_sem_destroy(pj_sem_t *sem); |
1080 | | |
1081 | | /** |
1082 | | * @} |
1083 | | */ |
1084 | | #endif /* PJ_HAS_SEMAPHORE */ |
1085 | | |
1086 | | |
1087 | | /* **************************************************************************/ |
1088 | | #if defined(PJ_HAS_EVENT_OBJ) && PJ_HAS_EVENT_OBJ != 0 |
1089 | | /** |
1090 | | * @defgroup PJ_EVENT Event Object. |
1091 | | * @ingroup PJ_OS |
1092 | | * @{ |
1093 | | * |
1094 | | * This module provides abstraction to event object (e.g. Win32 Event) where |
1095 | | * available. Event objects can be used for synchronization among threads. |
1096 | | */ |
1097 | | |
1098 | | /** |
1099 | | * Create event object. |
1100 | | * |
1101 | | * @param pool The pool. |
1102 | | * @param name The name of the event object (for logging purpose). |
1103 | | * @param manual_reset Specify whether the event is manual-reset |
1104 | | * @param initial Specify the initial state of the event object. |
1105 | | * @param event Pointer to hold the returned event object. |
1106 | | * |
1107 | | * @return event handle, or NULL if failed. |
1108 | | */ |
1109 | | PJ_DECL(pj_status_t) pj_event_create(pj_pool_t *pool, const char *name, |
1110 | | pj_bool_t manual_reset, pj_bool_t initial, |
1111 | | pj_event_t **event); |
1112 | | |
1113 | | /** |
1114 | | * Wait for event to be signaled. |
1115 | | * |
1116 | | * @param event The event object. |
1117 | | * |
1118 | | * @return zero if successfull. |
1119 | | */ |
1120 | | PJ_DECL(pj_status_t) pj_event_wait(pj_event_t *event); |
1121 | | |
1122 | | /** |
1123 | | * Try wait for event object to be signalled. |
1124 | | * |
1125 | | * @param event The event object. |
1126 | | * |
1127 | | * @return zero if successfull. |
1128 | | */ |
1129 | | PJ_DECL(pj_status_t) pj_event_trywait(pj_event_t *event); |
1130 | | |
1131 | | /** |
1132 | | * Set the event object state to signaled. For auto-reset event, this |
1133 | | * will only release the first thread that are waiting on the event. For |
1134 | | * manual reset event, the state remains signaled until the event is reset. |
1135 | | * If there is no thread waiting on the event, the event object state |
1136 | | * remains signaled. |
1137 | | * |
1138 | | * @param event The event object. |
1139 | | * |
1140 | | * @return zero if successfull. |
1141 | | */ |
1142 | | PJ_DECL(pj_status_t) pj_event_set(pj_event_t *event); |
1143 | | |
1144 | | /** |
1145 | | * Set the event object to signaled state to release appropriate number of |
1146 | | * waiting threads and then reset the event object to non-signaled. For |
1147 | | * manual-reset event, this function will release all waiting threads. For |
1148 | | * auto-reset event, this function will only release one waiting thread. |
1149 | | * |
1150 | | * @param event The event object. |
1151 | | * |
1152 | | * @return zero if successfull. |
1153 | | */ |
1154 | | PJ_DECL(pj_status_t) pj_event_pulse(pj_event_t *event); |
1155 | | |
1156 | | /** |
1157 | | * Set the event object state to non-signaled. |
1158 | | * |
1159 | | * @param event The event object. |
1160 | | * |
1161 | | * @return zero if successfull. |
1162 | | */ |
1163 | | PJ_DECL(pj_status_t) pj_event_reset(pj_event_t *event); |
1164 | | |
1165 | | /** |
1166 | | * Destroy the event object. |
1167 | | * |
1168 | | * @param event The event object. |
1169 | | * |
1170 | | * @return zero if successfull. |
1171 | | */ |
1172 | | PJ_DECL(pj_status_t) pj_event_destroy(pj_event_t *event); |
1173 | | |
1174 | | /** |
1175 | | * @} |
1176 | | */ |
1177 | | #endif /* PJ_HAS_EVENT_OBJ */ |
1178 | | |
1179 | | |
1180 | | /* **************************************************************************/ |
1181 | | /** |
1182 | | * @defgroup PJ_BARRIER_SEC Barrier sections. |
1183 | | * @ingroup PJ_OS |
1184 | | * @{ |
1185 | | * This module provides abstraction to pj_barrier_t - synchronization barrier. |
1186 | | * It allows threads to block until all participating threads have reached |
1187 | | * the barrier, ensuring synchronization at specific points in execution. |
1188 | | * pj_barrier_t provides a barrier mechanism for synchronizing threads in |
1189 | | * a multithreaded application, similar to |
1190 | | * the POSIX pthread_barrier_wait or Windows EnterSynchronizationBarrier. |
1191 | | */ |
1192 | | |
1193 | | /** |
1194 | | * Flags that control the behavior of the barrier. |
1195 | | * Only supported on Windows platform starting from Windows 8. |
1196 | | * Otherwise, the flags are ignored. |
1197 | | */ |
1198 | | enum pj_barrier_flags { |
1199 | | /** |
1200 | | * Specifies that the thread entering the barrier should block |
1201 | | * immediately until the last thread enters the barrier. |
1202 | | */ |
1203 | | PJ_BARRIER_FLAGS_BLOCK_ONLY = 1, |
1204 | | |
1205 | | /** |
1206 | | * Specifies that the thread entering the barrier should spin until |
1207 | | * the last thread enters the barrier, |
1208 | | * even if the spinning thread exceeds the barrier's maximum spin count. |
1209 | | */ |
1210 | | PJ_BARRIER_FLAGS_SPIN_ONLY = 2, |
1211 | | |
1212 | | /** |
1213 | | * Specifies that the function can skip the work required to ensure |
1214 | | * that it is safe to delete the barrier, which can improve performance. |
1215 | | * All threads that enter this barrier must specify the flag; |
1216 | | * otherwise, the flag is ignored. |
1217 | | * This flag should be used only if the barrier will never be deleted. |
1218 | | * "Never" means "when some thread is waiting on this barrier". |
1219 | | */ |
1220 | | PJ_BARRIER_FLAGS_NO_DELETE = 4 |
1221 | | }; |
1222 | | |
1223 | | /** |
1224 | | * Create a barrier object. |
1225 | | * pj_barrier_create() creates a barrier object that can be used to synchronize |
1226 | | * threads. The barrier object is initialized with a thread count that |
1227 | | * specifies the number of threads that must call pj_barrier_wait() |
1228 | | * before any are allowed to proceed. |
1229 | | * |
1230 | | * @param pool The pool to allocate the barrier object. |
1231 | | * @param thread_count The number of threads that must call pj_barrier_wait() |
1232 | | * before any are allowed to proceed. |
1233 | | * @param p_barrier Pointer to hold the barrier object upon return. |
1234 | | * |
1235 | | * @return PJ_SUCCESS on success, or the error code. |
1236 | | * |
1237 | | * @warning The behavior of the barrier is undefined if more |
1238 | | * threads than thread_count arrive at the barrier. |
1239 | | */ |
1240 | | PJ_DECL(pj_status_t) pj_barrier_create(pj_pool_t *pool, unsigned thread_count, |
1241 | | pj_barrier_t **p_barrier); |
1242 | | |
1243 | | /** |
1244 | | * Destroy a barrier object. |
1245 | | * pj_barrier_destroy() destroys a barrier object and releases any resources |
1246 | | * associated with the barrier. |
1247 | | * |
1248 | | * @param barrier The barrier to destroy. |
1249 | | * |
1250 | | * @return PJ_SUCCESS on success, or the error code. |
1251 | | */ |
1252 | | PJ_DECL(pj_status_t) pj_barrier_destroy(pj_barrier_t *barrier); |
1253 | | |
1254 | | /** |
1255 | | * Wait for all threads to reach the barrier. |
1256 | | * pj_barrier_wait() allows threads to block until all participating threads |
1257 | | * have reached the barrier, ensuring synchronization at specific points in |
1258 | | * execution. It provides a barrier mechanism for synchronizing threads in |
1259 | | * a multithreaded application, similar to the POSIX pthread_barrier_wait |
1260 | | * or Windows EnterSynchronizationBarrier. |
1261 | | * |
1262 | | * @param barrier The barrier to wait on. |
1263 | | * @param flags Flags that control the behavior of the barrier |
1264 | | * (combination of pj_barrier_flags), default 0. |
1265 | | * |
1266 | | * @return Returns PJ_TRUE for a single (arbitrary) thread |
1267 | | * synchronized at the barrier and PJ_FALSE for each |
1268 | | * of the other threads. Otherwise, an error number |
1269 | | * shall be returned to indicate the error. |
1270 | | * |
1271 | | * @warning The behavior of the barrier is undefined if more |
1272 | | * threads arrive at the barrier than the thread_count |
1273 | | * specified when the barrier was created. |
1274 | | */ |
1275 | | PJ_DECL(pj_int32_t) pj_barrier_wait(pj_barrier_t *barrier, pj_uint32_t flags); |
1276 | | |
1277 | | /** |
1278 | | * @} |
1279 | | */ |
1280 | | |
1281 | | /* **************************************************************************/ |
1282 | | /** |
1283 | | * @addtogroup PJ_TIME Time Data Type and Manipulation. |
1284 | | * @ingroup PJ_OS |
1285 | | * @{ |
1286 | | * This module provides API for manipulating time. |
1287 | | * |
1288 | | * \section pj_time_examples_sec Examples |
1289 | | * |
1290 | | * For examples, please see: |
1291 | | * - Sleep, Time, and Timestamp test: \src{pjlib/src/pjlib-test/sleep.c} |
1292 | | */ |
1293 | | |
1294 | | /** |
1295 | | * Get current time of day in local representation. |
1296 | | * |
1297 | | * @param tv Variable to store the result. |
1298 | | * |
1299 | | * @return zero if successfull. |
1300 | | */ |
1301 | | PJ_DECL(pj_status_t) pj_gettimeofday(pj_time_val *tv); |
1302 | | |
1303 | | |
1304 | | /** |
1305 | | * Parse time value into date/time representation. |
1306 | | * |
1307 | | * @param tv The time. |
1308 | | * @param pt Variable to store the date time result. |
1309 | | * |
1310 | | * @return zero if successfull. |
1311 | | */ |
1312 | | PJ_DECL(pj_status_t) pj_time_decode(const pj_time_val *tv, pj_parsed_time *pt); |
1313 | | |
1314 | | /** |
1315 | | * Encode date/time to time value. |
1316 | | * |
1317 | | * @param pt The date/time. |
1318 | | * @param tv Variable to store time value result. |
1319 | | * |
1320 | | * @return zero if successfull. |
1321 | | */ |
1322 | | PJ_DECL(pj_status_t) pj_time_encode(const pj_parsed_time *pt, pj_time_val *tv); |
1323 | | |
1324 | | /** |
1325 | | * Convert local time to GMT. |
1326 | | * |
1327 | | * @param tv Time to convert. |
1328 | | * |
1329 | | * @return zero if successfull. |
1330 | | */ |
1331 | | PJ_DECL(pj_status_t) pj_time_local_to_gmt(pj_time_val *tv); |
1332 | | |
1333 | | /** |
1334 | | * Convert GMT to local time. |
1335 | | * |
1336 | | * @param tv Time to convert. |
1337 | | * |
1338 | | * @return zero if successfull. |
1339 | | */ |
1340 | | PJ_DECL(pj_status_t) pj_time_gmt_to_local(pj_time_val *tv); |
1341 | | |
1342 | | /** |
1343 | | * @} |
1344 | | */ |
1345 | | |
1346 | | /* **************************************************************************/ |
1347 | | #if defined(PJ_TERM_HAS_COLOR) && PJ_TERM_HAS_COLOR != 0 |
1348 | | |
1349 | | /** |
1350 | | * @defgroup PJ_TERM Terminal |
1351 | | * @ingroup PJ_OS |
1352 | | * @{ |
1353 | | */ |
1354 | | |
1355 | | /** |
1356 | | * Set current terminal color. |
1357 | | * |
1358 | | * @param color The RGB color. |
1359 | | * |
1360 | | * @return zero on success. |
1361 | | */ |
1362 | | PJ_DECL(pj_status_t) pj_term_set_color(pj_color_t color); |
1363 | | |
1364 | | /** |
1365 | | * Get current terminal foreground color. |
1366 | | * |
1367 | | * @return RGB color. |
1368 | | */ |
1369 | | PJ_DECL(pj_color_t) pj_term_get_color(void); |
1370 | | |
1371 | | /** |
1372 | | * @} |
1373 | | */ |
1374 | | |
1375 | | #endif /* PJ_TERM_HAS_COLOR */ |
1376 | | |
1377 | | /* **************************************************************************/ |
1378 | | /** |
1379 | | * @defgroup PJ_TIMESTAMP High Resolution Timestamp |
1380 | | * @ingroup PJ_OS |
1381 | | * @{ |
1382 | | * |
1383 | | * PJLIB provides <b>High Resolution Timestamp</b> API to access highest |
1384 | | * resolution timestamp value provided by the platform. The API is usefull |
1385 | | * to measure precise elapsed time, and can be used in applications such |
1386 | | * as profiling. |
1387 | | * |
1388 | | * The timestamp value is represented in cycles, and can be related to |
1389 | | * normal time (in seconds or sub-seconds) using various functions provided. |
1390 | | * |
1391 | | * \section pj_timestamp_examples_sec Examples |
1392 | | * |
1393 | | * For examples, please see: |
1394 | | * - Sleep, Time, and Timestamp test: \src{pjlib/src/pjlib-test/sleep.c} |
1395 | | * - Timestamp test: \src{pjlib/src/pjlib-test/timestamp.c} |
1396 | | */ |
1397 | | |
1398 | | /* |
1399 | | * High resolution timer. |
1400 | | */ |
1401 | | #if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0 |
1402 | | |
1403 | | /** |
1404 | | * Get monotonic time since some unspecified starting point. |
1405 | | * |
1406 | | * @param tv Variable to store the result. |
1407 | | * |
1408 | | * @return PJ_SUCCESS if successful. |
1409 | | */ |
1410 | | PJ_DECL(pj_status_t) pj_gettickcount(pj_time_val *tv); |
1411 | | |
1412 | | /** |
1413 | | * Acquire high resolution timer value. The time value are stored |
1414 | | * in cycles. |
1415 | | * |
1416 | | * @param ts High resolution timer value. |
1417 | | * @return PJ_SUCCESS or the appropriate error code. |
1418 | | * |
1419 | | * @see pj_get_timestamp_freq(). |
1420 | | */ |
1421 | | PJ_DECL(pj_status_t) pj_get_timestamp(pj_timestamp *ts); |
1422 | | |
1423 | | /** |
1424 | | * Get high resolution timer frequency, in cycles per second. |
1425 | | * |
1426 | | * @param freq Timer frequency, in cycles per second. |
1427 | | * @return PJ_SUCCESS or the appropriate error code. |
1428 | | */ |
1429 | | PJ_DECL(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq); |
1430 | | |
1431 | | /** |
1432 | | * Set timestamp from 32bit values. |
1433 | | * @param t The timestamp to be set. |
1434 | | * @param hi The high 32bit part. |
1435 | | * @param lo The low 32bit part. |
1436 | | */ |
1437 | | PJ_INLINE(void) pj_set_timestamp32(pj_timestamp *t, pj_uint32_t hi, |
1438 | | pj_uint32_t lo) |
1439 | 112k | { |
1440 | 112k | t->u32.hi = hi; |
1441 | 112k | t->u32.lo = lo; |
1442 | 112k | } Unexecuted instantiation: fuzz-ice.c:pj_set_timestamp32 Unexecuted instantiation: ice_strans.c:pj_set_timestamp32 Unexecuted instantiation: stun_msg.c:pj_set_timestamp32 Unexecuted instantiation: stun_sock.c:pj_set_timestamp32 Unexecuted instantiation: turn_session.c:pj_set_timestamp32 Unexecuted instantiation: ice_session.c:pj_set_timestamp32 Unexecuted instantiation: stun_session.c:pj_set_timestamp32 Unexecuted instantiation: stun_msg_dump.c:pj_set_timestamp32 Unexecuted instantiation: srv_resolver.c:pj_set_timestamp32 Unexecuted instantiation: resolver.c:pj_set_timestamp32 Unexecuted instantiation: os_core_unix.c:pj_set_timestamp32 Unexecuted instantiation: os_time_unix.c:pj_set_timestamp32 Unexecuted instantiation: os_timestamp_posix.c:pj_set_timestamp32 Unexecuted instantiation: guid_simple.c:pj_set_timestamp32 Unexecuted instantiation: ioqueue_select.c:pj_set_timestamp32 os_timestamp_common.c:pj_set_timestamp32 Line | Count | Source | 1439 | 111k | { | 1440 | 111k | t->u32.hi = hi; | 1441 | 111k | t->u32.lo = lo; | 1442 | 111k | } |
Unexecuted instantiation: pool_policy_malloc.c:pj_set_timestamp32 Unexecuted instantiation: sock_bsd.c:pj_set_timestamp32 Unexecuted instantiation: sock_select.c:pj_set_timestamp32 Unexecuted instantiation: except.c:pj_set_timestamp32 Unexecuted instantiation: hash.c:pj_set_timestamp32 Unexecuted instantiation: lock.c:pj_set_timestamp32 Unexecuted instantiation: log.c:pj_set_timestamp32 Unexecuted instantiation: os_time_common.c:pj_set_timestamp32 Unexecuted instantiation: pool.c:pj_set_timestamp32 Unexecuted instantiation: pool_buf.c:pj_set_timestamp32 Unexecuted instantiation: pool_caching.c:pj_set_timestamp32 Unexecuted instantiation: rand.c:pj_set_timestamp32 Unexecuted instantiation: sock_common.c:pj_set_timestamp32 Unexecuted instantiation: string.c:pj_set_timestamp32 Unexecuted instantiation: timer.c:pj_set_timestamp32 Unexecuted instantiation: types.c:pj_set_timestamp32 Unexecuted instantiation: log_writer_stdout.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-json.c:pj_set_timestamp32 Unexecuted instantiation: scanner.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-url.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-sdp.c:pj_set_timestamp32 Unexecuted instantiation: event.c:pj_set_timestamp32 Unexecuted instantiation: sdp.c:pj_set_timestamp32 Unexecuted instantiation: sdp_neg.c:pj_set_timestamp32 Unexecuted instantiation: stream_common.c:pj_set_timestamp32 Unexecuted instantiation: vid_codec.c:pj_set_timestamp32 Unexecuted instantiation: av_sync.c:pj_set_timestamp32 Unexecuted instantiation: codec.c:pj_set_timestamp32 Unexecuted instantiation: rtcp.c:pj_set_timestamp32 Unexecuted instantiation: rtcp_xr.c:pj_set_timestamp32 Unexecuted instantiation: rtcp_fb.c:pj_set_timestamp32 Unexecuted instantiation: endpoint.c:pj_set_timestamp32 Unexecuted instantiation: transport_srtp.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-uri.c:pj_set_timestamp32 Unexecuted instantiation: sip_parser.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-presence.c:pj_set_timestamp32 Unexecuted instantiation: xml.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-dns-records.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-sip.c:pj_set_timestamp32 Unexecuted instantiation: sip_endpoint.c:pj_set_timestamp32 Unexecuted instantiation: sip_transport.c:pj_set_timestamp32 Unexecuted instantiation: sip_transport_loop.c:pj_set_timestamp32 Unexecuted instantiation: sip_transaction.c:pj_set_timestamp32 Unexecuted instantiation: sip_dialog.c:pj_set_timestamp32 Unexecuted instantiation: sip_ua_layer.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-sip-transaction.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-dns.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-video.c:pj_set_timestamp32 Unexecuted instantiation: vpx_packetizer.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-rtp.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-stream.c:pj_set_timestamp32 ilbc.c:pj_set_timestamp32 Line | Count | Source | 1439 | 189 | { | 1440 | 189 | t->u32.hi = hi; | 1441 | 189 | t->u32.lo = lo; | 1442 | 189 | } |
g711.c:pj_set_timestamp32 Line | Count | Source | 1439 | 53 | { | 1440 | 53 | t->u32.hi = hi; | 1441 | 53 | t->u32.lo = lo; | 1442 | 53 | } |
Unexecuted instantiation: fuzz-audio.c:pj_set_timestamp32 Unexecuted instantiation: opus.c:pj_set_timestamp32 Unexecuted instantiation: l16.c:pj_set_timestamp32 Unexecuted instantiation: speex_codec.c:pj_set_timestamp32 Unexecuted instantiation: g722.c:pj_set_timestamp32 Unexecuted instantiation: g722_enc.c:pj_set_timestamp32 Unexecuted instantiation: g722_dec.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-sip-dialog.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-crypto.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-xml.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-stun.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-rtcp.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-multipart.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-srtp.c:pj_set_timestamp32 Unexecuted instantiation: transport_loop.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-sdes.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-vpx.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-h264.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-http.c:pj_set_timestamp32 Unexecuted instantiation: fuzz-auth.c:pj_set_timestamp32 |
1443 | | |
1444 | | |
1445 | | /** |
1446 | | * Compare timestamp t1 and t2. |
1447 | | * @param t1 t1. |
1448 | | * @param t2 t2. |
1449 | | * @return -1 if (t1 < t2), 1 if (t1 > t2), or 0 if (t1 == t2) |
1450 | | */ |
1451 | | PJ_INLINE(int) pj_cmp_timestamp(const pj_timestamp *t1, const pj_timestamp *t2) |
1452 | 189 | { |
1453 | 189 | #if PJ_HAS_INT64 |
1454 | 189 | if (t1->u64 < t2->u64) |
1455 | 119 | return -1; |
1456 | 70 | else if (t1->u64 > t2->u64) |
1457 | 31 | return 1; |
1458 | 39 | else |
1459 | 39 | return 0; |
1460 | | #else |
1461 | | if (t1->u32.hi < t2->u32.hi || |
1462 | | (t1->u32.hi == t2->u32.hi && t1->u32.lo < t2->u32.lo)) |
1463 | | return -1; |
1464 | | else if (t1->u32.hi > t2->u32.hi || |
1465 | | (t1->u32.hi == t2->u32.hi && t1->u32.lo > t2->u32.lo)) |
1466 | | return 1; |
1467 | | else |
1468 | | return 0; |
1469 | | #endif |
1470 | 189 | } Unexecuted instantiation: fuzz-ice.c:pj_cmp_timestamp Unexecuted instantiation: ice_strans.c:pj_cmp_timestamp Unexecuted instantiation: stun_msg.c:pj_cmp_timestamp Unexecuted instantiation: stun_sock.c:pj_cmp_timestamp Unexecuted instantiation: turn_session.c:pj_cmp_timestamp ice_session.c:pj_cmp_timestamp Line | Count | Source | 1452 | 189 | { | 1453 | 189 | #if PJ_HAS_INT64 | 1454 | 189 | if (t1->u64 < t2->u64) | 1455 | 119 | return -1; | 1456 | 70 | else if (t1->u64 > t2->u64) | 1457 | 31 | return 1; | 1458 | 39 | else | 1459 | 39 | return 0; | 1460 | | #else | 1461 | | if (t1->u32.hi < t2->u32.hi || | 1462 | | (t1->u32.hi == t2->u32.hi && t1->u32.lo < t2->u32.lo)) | 1463 | | return -1; | 1464 | | else if (t1->u32.hi > t2->u32.hi || | 1465 | | (t1->u32.hi == t2->u32.hi && t1->u32.lo > t2->u32.lo)) | 1466 | | return 1; | 1467 | | else | 1468 | | return 0; | 1469 | | #endif | 1470 | 189 | } |
Unexecuted instantiation: stun_session.c:pj_cmp_timestamp Unexecuted instantiation: stun_msg_dump.c:pj_cmp_timestamp Unexecuted instantiation: srv_resolver.c:pj_cmp_timestamp Unexecuted instantiation: resolver.c:pj_cmp_timestamp Unexecuted instantiation: os_core_unix.c:pj_cmp_timestamp Unexecuted instantiation: os_time_unix.c:pj_cmp_timestamp Unexecuted instantiation: os_timestamp_posix.c:pj_cmp_timestamp Unexecuted instantiation: guid_simple.c:pj_cmp_timestamp Unexecuted instantiation: ioqueue_select.c:pj_cmp_timestamp Unexecuted instantiation: os_timestamp_common.c:pj_cmp_timestamp Unexecuted instantiation: pool_policy_malloc.c:pj_cmp_timestamp Unexecuted instantiation: sock_bsd.c:pj_cmp_timestamp Unexecuted instantiation: sock_select.c:pj_cmp_timestamp Unexecuted instantiation: except.c:pj_cmp_timestamp Unexecuted instantiation: hash.c:pj_cmp_timestamp Unexecuted instantiation: lock.c:pj_cmp_timestamp Unexecuted instantiation: log.c:pj_cmp_timestamp Unexecuted instantiation: os_time_common.c:pj_cmp_timestamp Unexecuted instantiation: pool.c:pj_cmp_timestamp Unexecuted instantiation: pool_buf.c:pj_cmp_timestamp Unexecuted instantiation: pool_caching.c:pj_cmp_timestamp Unexecuted instantiation: rand.c:pj_cmp_timestamp Unexecuted instantiation: sock_common.c:pj_cmp_timestamp Unexecuted instantiation: string.c:pj_cmp_timestamp Unexecuted instantiation: timer.c:pj_cmp_timestamp Unexecuted instantiation: types.c:pj_cmp_timestamp Unexecuted instantiation: log_writer_stdout.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-json.c:pj_cmp_timestamp Unexecuted instantiation: scanner.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-url.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-sdp.c:pj_cmp_timestamp Unexecuted instantiation: event.c:pj_cmp_timestamp Unexecuted instantiation: sdp.c:pj_cmp_timestamp Unexecuted instantiation: sdp_neg.c:pj_cmp_timestamp Unexecuted instantiation: stream_common.c:pj_cmp_timestamp Unexecuted instantiation: vid_codec.c:pj_cmp_timestamp Unexecuted instantiation: av_sync.c:pj_cmp_timestamp Unexecuted instantiation: codec.c:pj_cmp_timestamp Unexecuted instantiation: rtcp.c:pj_cmp_timestamp Unexecuted instantiation: rtcp_xr.c:pj_cmp_timestamp Unexecuted instantiation: rtcp_fb.c:pj_cmp_timestamp Unexecuted instantiation: endpoint.c:pj_cmp_timestamp Unexecuted instantiation: transport_srtp.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-uri.c:pj_cmp_timestamp Unexecuted instantiation: sip_parser.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-presence.c:pj_cmp_timestamp Unexecuted instantiation: xml.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-dns-records.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-sip.c:pj_cmp_timestamp Unexecuted instantiation: sip_endpoint.c:pj_cmp_timestamp Unexecuted instantiation: sip_transport.c:pj_cmp_timestamp Unexecuted instantiation: sip_transport_loop.c:pj_cmp_timestamp Unexecuted instantiation: sip_transaction.c:pj_cmp_timestamp Unexecuted instantiation: sip_dialog.c:pj_cmp_timestamp Unexecuted instantiation: sip_ua_layer.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-sip-transaction.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-dns.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-video.c:pj_cmp_timestamp Unexecuted instantiation: vpx_packetizer.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-rtp.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-stream.c:pj_cmp_timestamp Unexecuted instantiation: gsm.c:pj_cmp_timestamp Unexecuted instantiation: ilbc.c:pj_cmp_timestamp Unexecuted instantiation: g711.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-audio.c:pj_cmp_timestamp Unexecuted instantiation: opus.c:pj_cmp_timestamp Unexecuted instantiation: l16.c:pj_cmp_timestamp Unexecuted instantiation: speex_codec.c:pj_cmp_timestamp Unexecuted instantiation: g722.c:pj_cmp_timestamp Unexecuted instantiation: g722_enc.c:pj_cmp_timestamp Unexecuted instantiation: g722_dec.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-sip-dialog.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-crypto.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-xml.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-stun.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-rtcp.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-multipart.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-srtp.c:pj_cmp_timestamp Unexecuted instantiation: transport_loop.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-sdes.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-vpx.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-h264.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-http.c:pj_cmp_timestamp Unexecuted instantiation: fuzz-auth.c:pj_cmp_timestamp |
1471 | | |
1472 | | |
1473 | | /** |
1474 | | * Add timestamp t2 to t1. |
1475 | | * @param t1 t1. |
1476 | | * @param t2 t2. |
1477 | | */ |
1478 | | PJ_INLINE(void) pj_add_timestamp(pj_timestamp *t1, const pj_timestamp *t2) |
1479 | 0 | { |
1480 | 0 | #if PJ_HAS_INT64 |
1481 | 0 | t1->u64 += t2->u64; |
1482 | | #else |
1483 | | pj_uint32_t old = t1->u32.lo; |
1484 | | t1->u32.hi += t2->u32.hi; |
1485 | | t1->u32.lo += t2->u32.lo; |
1486 | | if (t1->u32.lo < old) |
1487 | | ++t1->u32.hi; |
1488 | | #endif |
1489 | 0 | } Unexecuted instantiation: fuzz-ice.c:pj_add_timestamp Unexecuted instantiation: ice_strans.c:pj_add_timestamp Unexecuted instantiation: stun_msg.c:pj_add_timestamp Unexecuted instantiation: stun_sock.c:pj_add_timestamp Unexecuted instantiation: turn_session.c:pj_add_timestamp Unexecuted instantiation: ice_session.c:pj_add_timestamp Unexecuted instantiation: stun_session.c:pj_add_timestamp Unexecuted instantiation: stun_msg_dump.c:pj_add_timestamp Unexecuted instantiation: srv_resolver.c:pj_add_timestamp Unexecuted instantiation: resolver.c:pj_add_timestamp Unexecuted instantiation: os_core_unix.c:pj_add_timestamp Unexecuted instantiation: os_time_unix.c:pj_add_timestamp Unexecuted instantiation: os_timestamp_posix.c:pj_add_timestamp Unexecuted instantiation: guid_simple.c:pj_add_timestamp Unexecuted instantiation: ioqueue_select.c:pj_add_timestamp Unexecuted instantiation: os_timestamp_common.c:pj_add_timestamp Unexecuted instantiation: pool_policy_malloc.c:pj_add_timestamp Unexecuted instantiation: sock_bsd.c:pj_add_timestamp Unexecuted instantiation: sock_select.c:pj_add_timestamp Unexecuted instantiation: except.c:pj_add_timestamp Unexecuted instantiation: hash.c:pj_add_timestamp Unexecuted instantiation: lock.c:pj_add_timestamp Unexecuted instantiation: log.c:pj_add_timestamp Unexecuted instantiation: os_time_common.c:pj_add_timestamp Unexecuted instantiation: pool.c:pj_add_timestamp Unexecuted instantiation: pool_buf.c:pj_add_timestamp Unexecuted instantiation: pool_caching.c:pj_add_timestamp Unexecuted instantiation: rand.c:pj_add_timestamp Unexecuted instantiation: sock_common.c:pj_add_timestamp Unexecuted instantiation: string.c:pj_add_timestamp Unexecuted instantiation: timer.c:pj_add_timestamp Unexecuted instantiation: types.c:pj_add_timestamp Unexecuted instantiation: log_writer_stdout.c:pj_add_timestamp Unexecuted instantiation: fuzz-json.c:pj_add_timestamp Unexecuted instantiation: scanner.c:pj_add_timestamp Unexecuted instantiation: fuzz-url.c:pj_add_timestamp Unexecuted instantiation: fuzz-sdp.c:pj_add_timestamp Unexecuted instantiation: event.c:pj_add_timestamp Unexecuted instantiation: sdp.c:pj_add_timestamp Unexecuted instantiation: sdp_neg.c:pj_add_timestamp Unexecuted instantiation: stream_common.c:pj_add_timestamp Unexecuted instantiation: vid_codec.c:pj_add_timestamp Unexecuted instantiation: av_sync.c:pj_add_timestamp Unexecuted instantiation: codec.c:pj_add_timestamp Unexecuted instantiation: rtcp.c:pj_add_timestamp Unexecuted instantiation: rtcp_xr.c:pj_add_timestamp Unexecuted instantiation: rtcp_fb.c:pj_add_timestamp Unexecuted instantiation: endpoint.c:pj_add_timestamp Unexecuted instantiation: transport_srtp.c:pj_add_timestamp Unexecuted instantiation: fuzz-uri.c:pj_add_timestamp Unexecuted instantiation: sip_parser.c:pj_add_timestamp Unexecuted instantiation: fuzz-presence.c:pj_add_timestamp Unexecuted instantiation: xml.c:pj_add_timestamp Unexecuted instantiation: fuzz-dns-records.c:pj_add_timestamp Unexecuted instantiation: fuzz-sip.c:pj_add_timestamp Unexecuted instantiation: sip_endpoint.c:pj_add_timestamp Unexecuted instantiation: sip_transport.c:pj_add_timestamp Unexecuted instantiation: sip_transport_loop.c:pj_add_timestamp Unexecuted instantiation: sip_transaction.c:pj_add_timestamp Unexecuted instantiation: sip_dialog.c:pj_add_timestamp Unexecuted instantiation: sip_ua_layer.c:pj_add_timestamp Unexecuted instantiation: fuzz-sip-transaction.c:pj_add_timestamp Unexecuted instantiation: fuzz-dns.c:pj_add_timestamp Unexecuted instantiation: fuzz-video.c:pj_add_timestamp Unexecuted instantiation: vpx_packetizer.c:pj_add_timestamp Unexecuted instantiation: fuzz-rtp.c:pj_add_timestamp Unexecuted instantiation: fuzz-stream.c:pj_add_timestamp Unexecuted instantiation: gsm.c:pj_add_timestamp Unexecuted instantiation: ilbc.c:pj_add_timestamp Unexecuted instantiation: g711.c:pj_add_timestamp Unexecuted instantiation: fuzz-audio.c:pj_add_timestamp Unexecuted instantiation: opus.c:pj_add_timestamp Unexecuted instantiation: l16.c:pj_add_timestamp Unexecuted instantiation: speex_codec.c:pj_add_timestamp Unexecuted instantiation: g722.c:pj_add_timestamp Unexecuted instantiation: g722_enc.c:pj_add_timestamp Unexecuted instantiation: g722_dec.c:pj_add_timestamp Unexecuted instantiation: fuzz-sip-dialog.c:pj_add_timestamp Unexecuted instantiation: fuzz-crypto.c:pj_add_timestamp Unexecuted instantiation: fuzz-xml.c:pj_add_timestamp Unexecuted instantiation: fuzz-stun.c:pj_add_timestamp Unexecuted instantiation: fuzz-rtcp.c:pj_add_timestamp Unexecuted instantiation: fuzz-multipart.c:pj_add_timestamp Unexecuted instantiation: fuzz-srtp.c:pj_add_timestamp Unexecuted instantiation: transport_loop.c:pj_add_timestamp Unexecuted instantiation: fuzz-sdes.c:pj_add_timestamp Unexecuted instantiation: fuzz-vpx.c:pj_add_timestamp Unexecuted instantiation: fuzz-h264.c:pj_add_timestamp Unexecuted instantiation: fuzz-http.c:pj_add_timestamp Unexecuted instantiation: fuzz-auth.c:pj_add_timestamp |
1490 | | |
1491 | | /** |
1492 | | * Add timestamp t2 to t1. |
1493 | | * @param t1 t1. |
1494 | | * @param t2 t2. |
1495 | | */ |
1496 | | PJ_INLINE(void) pj_add_timestamp32(pj_timestamp *t1, pj_uint32_t t2) |
1497 | 0 | { |
1498 | 0 | #if PJ_HAS_INT64 |
1499 | 0 | t1->u64 += t2; |
1500 | 0 | #else |
1501 | 0 | pj_uint32_t old = t1->u32.lo; |
1502 | 0 | t1->u32.lo += t2; |
1503 | 0 | if (t1->u32.lo < old) |
1504 | 0 | ++t1->u32.hi; |
1505 | 0 | #endif |
1506 | 0 | } Unexecuted instantiation: fuzz-ice.c:pj_add_timestamp32 Unexecuted instantiation: ice_strans.c:pj_add_timestamp32 Unexecuted instantiation: stun_msg.c:pj_add_timestamp32 Unexecuted instantiation: stun_sock.c:pj_add_timestamp32 Unexecuted instantiation: turn_session.c:pj_add_timestamp32 Unexecuted instantiation: ice_session.c:pj_add_timestamp32 Unexecuted instantiation: stun_session.c:pj_add_timestamp32 Unexecuted instantiation: stun_msg_dump.c:pj_add_timestamp32 Unexecuted instantiation: srv_resolver.c:pj_add_timestamp32 Unexecuted instantiation: resolver.c:pj_add_timestamp32 Unexecuted instantiation: os_core_unix.c:pj_add_timestamp32 Unexecuted instantiation: os_time_unix.c:pj_add_timestamp32 Unexecuted instantiation: os_timestamp_posix.c:pj_add_timestamp32 Unexecuted instantiation: guid_simple.c:pj_add_timestamp32 Unexecuted instantiation: ioqueue_select.c:pj_add_timestamp32 Unexecuted instantiation: os_timestamp_common.c:pj_add_timestamp32 Unexecuted instantiation: pool_policy_malloc.c:pj_add_timestamp32 Unexecuted instantiation: sock_bsd.c:pj_add_timestamp32 Unexecuted instantiation: sock_select.c:pj_add_timestamp32 Unexecuted instantiation: except.c:pj_add_timestamp32 Unexecuted instantiation: hash.c:pj_add_timestamp32 Unexecuted instantiation: lock.c:pj_add_timestamp32 Unexecuted instantiation: log.c:pj_add_timestamp32 Unexecuted instantiation: os_time_common.c:pj_add_timestamp32 Unexecuted instantiation: pool.c:pj_add_timestamp32 Unexecuted instantiation: pool_buf.c:pj_add_timestamp32 Unexecuted instantiation: pool_caching.c:pj_add_timestamp32 Unexecuted instantiation: rand.c:pj_add_timestamp32 Unexecuted instantiation: sock_common.c:pj_add_timestamp32 Unexecuted instantiation: string.c:pj_add_timestamp32 Unexecuted instantiation: timer.c:pj_add_timestamp32 Unexecuted instantiation: types.c:pj_add_timestamp32 Unexecuted instantiation: log_writer_stdout.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-json.c:pj_add_timestamp32 Unexecuted instantiation: scanner.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-url.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-sdp.c:pj_add_timestamp32 Unexecuted instantiation: event.c:pj_add_timestamp32 Unexecuted instantiation: sdp.c:pj_add_timestamp32 Unexecuted instantiation: sdp_neg.c:pj_add_timestamp32 Unexecuted instantiation: stream_common.c:pj_add_timestamp32 Unexecuted instantiation: vid_codec.c:pj_add_timestamp32 Unexecuted instantiation: av_sync.c:pj_add_timestamp32 Unexecuted instantiation: codec.c:pj_add_timestamp32 Unexecuted instantiation: rtcp.c:pj_add_timestamp32 Unexecuted instantiation: rtcp_xr.c:pj_add_timestamp32 Unexecuted instantiation: rtcp_fb.c:pj_add_timestamp32 Unexecuted instantiation: endpoint.c:pj_add_timestamp32 Unexecuted instantiation: transport_srtp.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-uri.c:pj_add_timestamp32 Unexecuted instantiation: sip_parser.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-presence.c:pj_add_timestamp32 Unexecuted instantiation: xml.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-dns-records.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-sip.c:pj_add_timestamp32 Unexecuted instantiation: sip_endpoint.c:pj_add_timestamp32 Unexecuted instantiation: sip_transport.c:pj_add_timestamp32 Unexecuted instantiation: sip_transport_loop.c:pj_add_timestamp32 Unexecuted instantiation: sip_transaction.c:pj_add_timestamp32 Unexecuted instantiation: sip_dialog.c:pj_add_timestamp32 Unexecuted instantiation: sip_ua_layer.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-sip-transaction.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-dns.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-video.c:pj_add_timestamp32 Unexecuted instantiation: vpx_packetizer.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-rtp.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-stream.c:pj_add_timestamp32 Unexecuted instantiation: gsm.c:pj_add_timestamp32 Unexecuted instantiation: ilbc.c:pj_add_timestamp32 Unexecuted instantiation: g711.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-audio.c:pj_add_timestamp32 Unexecuted instantiation: opus.c:pj_add_timestamp32 Unexecuted instantiation: l16.c:pj_add_timestamp32 Unexecuted instantiation: speex_codec.c:pj_add_timestamp32 Unexecuted instantiation: g722.c:pj_add_timestamp32 Unexecuted instantiation: g722_enc.c:pj_add_timestamp32 Unexecuted instantiation: g722_dec.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-sip-dialog.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-crypto.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-xml.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-stun.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-rtcp.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-multipart.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-srtp.c:pj_add_timestamp32 Unexecuted instantiation: transport_loop.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-sdes.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-vpx.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-h264.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-http.c:pj_add_timestamp32 Unexecuted instantiation: fuzz-auth.c:pj_add_timestamp32 |
1507 | | |
1508 | | /** |
1509 | | * Substract timestamp t2 from t1. |
1510 | | * @param t1 t1. |
1511 | | * @param t2 t2. |
1512 | | */ |
1513 | | PJ_INLINE(void) pj_sub_timestamp(pj_timestamp *t1, const pj_timestamp *t2) |
1514 | 0 | { |
1515 | 0 | #if PJ_HAS_INT64 |
1516 | 0 | t1->u64 -= t2->u64; |
1517 | | #else |
1518 | | t1->u32.hi -= t2->u32.hi; |
1519 | | if (t1->u32.lo >= t2->u32.lo) |
1520 | | t1->u32.lo -= t2->u32.lo; |
1521 | | else { |
1522 | | t1->u32.lo -= t2->u32.lo; |
1523 | | --t1->u32.hi; |
1524 | | } |
1525 | | #endif |
1526 | 0 | } Unexecuted instantiation: fuzz-ice.c:pj_sub_timestamp Unexecuted instantiation: ice_strans.c:pj_sub_timestamp Unexecuted instantiation: stun_msg.c:pj_sub_timestamp Unexecuted instantiation: stun_sock.c:pj_sub_timestamp Unexecuted instantiation: turn_session.c:pj_sub_timestamp Unexecuted instantiation: ice_session.c:pj_sub_timestamp Unexecuted instantiation: stun_session.c:pj_sub_timestamp Unexecuted instantiation: stun_msg_dump.c:pj_sub_timestamp Unexecuted instantiation: srv_resolver.c:pj_sub_timestamp Unexecuted instantiation: resolver.c:pj_sub_timestamp Unexecuted instantiation: os_core_unix.c:pj_sub_timestamp Unexecuted instantiation: os_time_unix.c:pj_sub_timestamp Unexecuted instantiation: os_timestamp_posix.c:pj_sub_timestamp Unexecuted instantiation: guid_simple.c:pj_sub_timestamp Unexecuted instantiation: ioqueue_select.c:pj_sub_timestamp Unexecuted instantiation: os_timestamp_common.c:pj_sub_timestamp Unexecuted instantiation: pool_policy_malloc.c:pj_sub_timestamp Unexecuted instantiation: sock_bsd.c:pj_sub_timestamp Unexecuted instantiation: sock_select.c:pj_sub_timestamp Unexecuted instantiation: except.c:pj_sub_timestamp Unexecuted instantiation: hash.c:pj_sub_timestamp Unexecuted instantiation: lock.c:pj_sub_timestamp Unexecuted instantiation: log.c:pj_sub_timestamp Unexecuted instantiation: os_time_common.c:pj_sub_timestamp Unexecuted instantiation: pool.c:pj_sub_timestamp Unexecuted instantiation: pool_buf.c:pj_sub_timestamp Unexecuted instantiation: pool_caching.c:pj_sub_timestamp Unexecuted instantiation: rand.c:pj_sub_timestamp Unexecuted instantiation: sock_common.c:pj_sub_timestamp Unexecuted instantiation: string.c:pj_sub_timestamp Unexecuted instantiation: timer.c:pj_sub_timestamp Unexecuted instantiation: types.c:pj_sub_timestamp Unexecuted instantiation: log_writer_stdout.c:pj_sub_timestamp Unexecuted instantiation: fuzz-json.c:pj_sub_timestamp Unexecuted instantiation: scanner.c:pj_sub_timestamp Unexecuted instantiation: fuzz-url.c:pj_sub_timestamp Unexecuted instantiation: fuzz-sdp.c:pj_sub_timestamp Unexecuted instantiation: event.c:pj_sub_timestamp Unexecuted instantiation: sdp.c:pj_sub_timestamp Unexecuted instantiation: sdp_neg.c:pj_sub_timestamp Unexecuted instantiation: stream_common.c:pj_sub_timestamp Unexecuted instantiation: vid_codec.c:pj_sub_timestamp Unexecuted instantiation: av_sync.c:pj_sub_timestamp Unexecuted instantiation: codec.c:pj_sub_timestamp Unexecuted instantiation: rtcp.c:pj_sub_timestamp Unexecuted instantiation: rtcp_xr.c:pj_sub_timestamp Unexecuted instantiation: rtcp_fb.c:pj_sub_timestamp Unexecuted instantiation: endpoint.c:pj_sub_timestamp Unexecuted instantiation: transport_srtp.c:pj_sub_timestamp Unexecuted instantiation: fuzz-uri.c:pj_sub_timestamp Unexecuted instantiation: sip_parser.c:pj_sub_timestamp Unexecuted instantiation: fuzz-presence.c:pj_sub_timestamp Unexecuted instantiation: xml.c:pj_sub_timestamp Unexecuted instantiation: fuzz-dns-records.c:pj_sub_timestamp Unexecuted instantiation: fuzz-sip.c:pj_sub_timestamp Unexecuted instantiation: sip_endpoint.c:pj_sub_timestamp Unexecuted instantiation: sip_transport.c:pj_sub_timestamp Unexecuted instantiation: sip_transport_loop.c:pj_sub_timestamp Unexecuted instantiation: sip_transaction.c:pj_sub_timestamp Unexecuted instantiation: sip_dialog.c:pj_sub_timestamp Unexecuted instantiation: sip_ua_layer.c:pj_sub_timestamp Unexecuted instantiation: fuzz-sip-transaction.c:pj_sub_timestamp Unexecuted instantiation: fuzz-dns.c:pj_sub_timestamp Unexecuted instantiation: fuzz-video.c:pj_sub_timestamp Unexecuted instantiation: vpx_packetizer.c:pj_sub_timestamp Unexecuted instantiation: fuzz-rtp.c:pj_sub_timestamp Unexecuted instantiation: fuzz-stream.c:pj_sub_timestamp Unexecuted instantiation: gsm.c:pj_sub_timestamp Unexecuted instantiation: ilbc.c:pj_sub_timestamp Unexecuted instantiation: g711.c:pj_sub_timestamp Unexecuted instantiation: fuzz-audio.c:pj_sub_timestamp Unexecuted instantiation: opus.c:pj_sub_timestamp Unexecuted instantiation: l16.c:pj_sub_timestamp Unexecuted instantiation: speex_codec.c:pj_sub_timestamp Unexecuted instantiation: g722.c:pj_sub_timestamp Unexecuted instantiation: g722_enc.c:pj_sub_timestamp Unexecuted instantiation: g722_dec.c:pj_sub_timestamp Unexecuted instantiation: fuzz-sip-dialog.c:pj_sub_timestamp Unexecuted instantiation: fuzz-crypto.c:pj_sub_timestamp Unexecuted instantiation: fuzz-xml.c:pj_sub_timestamp Unexecuted instantiation: fuzz-stun.c:pj_sub_timestamp Unexecuted instantiation: fuzz-rtcp.c:pj_sub_timestamp Unexecuted instantiation: fuzz-multipart.c:pj_sub_timestamp Unexecuted instantiation: fuzz-srtp.c:pj_sub_timestamp Unexecuted instantiation: transport_loop.c:pj_sub_timestamp Unexecuted instantiation: fuzz-sdes.c:pj_sub_timestamp Unexecuted instantiation: fuzz-vpx.c:pj_sub_timestamp Unexecuted instantiation: fuzz-h264.c:pj_sub_timestamp Unexecuted instantiation: fuzz-http.c:pj_sub_timestamp Unexecuted instantiation: fuzz-auth.c:pj_sub_timestamp |
1527 | | |
1528 | | /** |
1529 | | * Substract timestamp t2 from t1. |
1530 | | * @param t1 t1. |
1531 | | * @param t2 t2. |
1532 | | */ |
1533 | | PJ_INLINE(void) pj_sub_timestamp32(pj_timestamp *t1, pj_uint32_t t2) |
1534 | 0 | { |
1535 | 0 | #if PJ_HAS_INT64 |
1536 | 0 | t1->u64 -= t2; |
1537 | 0 | #else |
1538 | 0 | if (t1->u32.lo >= t2) |
1539 | 0 | t1->u32.lo -= t2; |
1540 | 0 | else { |
1541 | 0 | t1->u32.lo -= t2; |
1542 | 0 | --t1->u32.hi; |
1543 | 0 | } |
1544 | 0 | #endif |
1545 | 0 | } Unexecuted instantiation: fuzz-ice.c:pj_sub_timestamp32 Unexecuted instantiation: ice_strans.c:pj_sub_timestamp32 Unexecuted instantiation: stun_msg.c:pj_sub_timestamp32 Unexecuted instantiation: stun_sock.c:pj_sub_timestamp32 Unexecuted instantiation: turn_session.c:pj_sub_timestamp32 Unexecuted instantiation: ice_session.c:pj_sub_timestamp32 Unexecuted instantiation: stun_session.c:pj_sub_timestamp32 Unexecuted instantiation: stun_msg_dump.c:pj_sub_timestamp32 Unexecuted instantiation: srv_resolver.c:pj_sub_timestamp32 Unexecuted instantiation: resolver.c:pj_sub_timestamp32 Unexecuted instantiation: os_core_unix.c:pj_sub_timestamp32 Unexecuted instantiation: os_time_unix.c:pj_sub_timestamp32 Unexecuted instantiation: os_timestamp_posix.c:pj_sub_timestamp32 Unexecuted instantiation: guid_simple.c:pj_sub_timestamp32 Unexecuted instantiation: ioqueue_select.c:pj_sub_timestamp32 Unexecuted instantiation: os_timestamp_common.c:pj_sub_timestamp32 Unexecuted instantiation: pool_policy_malloc.c:pj_sub_timestamp32 Unexecuted instantiation: sock_bsd.c:pj_sub_timestamp32 Unexecuted instantiation: sock_select.c:pj_sub_timestamp32 Unexecuted instantiation: except.c:pj_sub_timestamp32 Unexecuted instantiation: hash.c:pj_sub_timestamp32 Unexecuted instantiation: lock.c:pj_sub_timestamp32 Unexecuted instantiation: log.c:pj_sub_timestamp32 Unexecuted instantiation: os_time_common.c:pj_sub_timestamp32 Unexecuted instantiation: pool.c:pj_sub_timestamp32 Unexecuted instantiation: pool_buf.c:pj_sub_timestamp32 Unexecuted instantiation: pool_caching.c:pj_sub_timestamp32 Unexecuted instantiation: rand.c:pj_sub_timestamp32 Unexecuted instantiation: sock_common.c:pj_sub_timestamp32 Unexecuted instantiation: string.c:pj_sub_timestamp32 Unexecuted instantiation: timer.c:pj_sub_timestamp32 Unexecuted instantiation: types.c:pj_sub_timestamp32 Unexecuted instantiation: log_writer_stdout.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-json.c:pj_sub_timestamp32 Unexecuted instantiation: scanner.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-url.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-sdp.c:pj_sub_timestamp32 Unexecuted instantiation: event.c:pj_sub_timestamp32 Unexecuted instantiation: sdp.c:pj_sub_timestamp32 Unexecuted instantiation: sdp_neg.c:pj_sub_timestamp32 Unexecuted instantiation: stream_common.c:pj_sub_timestamp32 Unexecuted instantiation: vid_codec.c:pj_sub_timestamp32 Unexecuted instantiation: av_sync.c:pj_sub_timestamp32 Unexecuted instantiation: codec.c:pj_sub_timestamp32 Unexecuted instantiation: rtcp.c:pj_sub_timestamp32 Unexecuted instantiation: rtcp_xr.c:pj_sub_timestamp32 Unexecuted instantiation: rtcp_fb.c:pj_sub_timestamp32 Unexecuted instantiation: endpoint.c:pj_sub_timestamp32 Unexecuted instantiation: transport_srtp.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-uri.c:pj_sub_timestamp32 Unexecuted instantiation: sip_parser.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-presence.c:pj_sub_timestamp32 Unexecuted instantiation: xml.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-dns-records.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-sip.c:pj_sub_timestamp32 Unexecuted instantiation: sip_endpoint.c:pj_sub_timestamp32 Unexecuted instantiation: sip_transport.c:pj_sub_timestamp32 Unexecuted instantiation: sip_transport_loop.c:pj_sub_timestamp32 Unexecuted instantiation: sip_transaction.c:pj_sub_timestamp32 Unexecuted instantiation: sip_dialog.c:pj_sub_timestamp32 Unexecuted instantiation: sip_ua_layer.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-sip-transaction.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-dns.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-video.c:pj_sub_timestamp32 Unexecuted instantiation: vpx_packetizer.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-rtp.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-stream.c:pj_sub_timestamp32 Unexecuted instantiation: gsm.c:pj_sub_timestamp32 Unexecuted instantiation: ilbc.c:pj_sub_timestamp32 Unexecuted instantiation: g711.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-audio.c:pj_sub_timestamp32 Unexecuted instantiation: opus.c:pj_sub_timestamp32 Unexecuted instantiation: l16.c:pj_sub_timestamp32 Unexecuted instantiation: speex_codec.c:pj_sub_timestamp32 Unexecuted instantiation: g722.c:pj_sub_timestamp32 Unexecuted instantiation: g722_enc.c:pj_sub_timestamp32 Unexecuted instantiation: g722_dec.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-sip-dialog.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-crypto.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-xml.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-stun.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-rtcp.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-multipart.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-srtp.c:pj_sub_timestamp32 Unexecuted instantiation: transport_loop.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-sdes.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-vpx.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-h264.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-http.c:pj_sub_timestamp32 Unexecuted instantiation: fuzz-auth.c:pj_sub_timestamp32 |
1546 | | |
1547 | | /** |
1548 | | * Get the timestamp difference between t2 and t1 (that is t2 minus t1), |
1549 | | * and return a 32bit signed integer difference. |
1550 | | */ |
1551 | | PJ_INLINE(pj_int32_t) pj_timestamp_diff32(const pj_timestamp *t1, |
1552 | | const pj_timestamp *t2) |
1553 | 5.37k | { |
1554 | | /* Be careful with the signess (I think!) */ |
1555 | 5.37k | #if PJ_HAS_INT64 |
1556 | 5.37k | pj_int64_t diff = t2->u64 - t1->u64; |
1557 | 5.37k | return (pj_int32_t) diff; |
1558 | | #else |
1559 | | pj_int32 diff = t2->u32.lo - t1->u32.lo; |
1560 | | return diff; |
1561 | | #endif |
1562 | 5.37k | } Unexecuted instantiation: fuzz-ice.c:pj_timestamp_diff32 Unexecuted instantiation: ice_strans.c:pj_timestamp_diff32 Unexecuted instantiation: stun_msg.c:pj_timestamp_diff32 Unexecuted instantiation: stun_sock.c:pj_timestamp_diff32 Unexecuted instantiation: turn_session.c:pj_timestamp_diff32 Unexecuted instantiation: ice_session.c:pj_timestamp_diff32 Unexecuted instantiation: stun_session.c:pj_timestamp_diff32 Unexecuted instantiation: stun_msg_dump.c:pj_timestamp_diff32 Unexecuted instantiation: srv_resolver.c:pj_timestamp_diff32 Unexecuted instantiation: resolver.c:pj_timestamp_diff32 Unexecuted instantiation: os_core_unix.c:pj_timestamp_diff32 Unexecuted instantiation: os_time_unix.c:pj_timestamp_diff32 Unexecuted instantiation: os_timestamp_posix.c:pj_timestamp_diff32 Unexecuted instantiation: guid_simple.c:pj_timestamp_diff32 Unexecuted instantiation: ioqueue_select.c:pj_timestamp_diff32 Unexecuted instantiation: os_timestamp_common.c:pj_timestamp_diff32 Unexecuted instantiation: pool_policy_malloc.c:pj_timestamp_diff32 Unexecuted instantiation: sock_bsd.c:pj_timestamp_diff32 Unexecuted instantiation: sock_select.c:pj_timestamp_diff32 Unexecuted instantiation: except.c:pj_timestamp_diff32 Unexecuted instantiation: hash.c:pj_timestamp_diff32 Unexecuted instantiation: lock.c:pj_timestamp_diff32 Unexecuted instantiation: log.c:pj_timestamp_diff32 Unexecuted instantiation: os_time_common.c:pj_timestamp_diff32 Unexecuted instantiation: pool.c:pj_timestamp_diff32 Unexecuted instantiation: pool_buf.c:pj_timestamp_diff32 Unexecuted instantiation: pool_caching.c:pj_timestamp_diff32 Unexecuted instantiation: rand.c:pj_timestamp_diff32 Unexecuted instantiation: sock_common.c:pj_timestamp_diff32 Unexecuted instantiation: string.c:pj_timestamp_diff32 Unexecuted instantiation: timer.c:pj_timestamp_diff32 Unexecuted instantiation: types.c:pj_timestamp_diff32 Unexecuted instantiation: log_writer_stdout.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-json.c:pj_timestamp_diff32 Unexecuted instantiation: scanner.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-url.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-sdp.c:pj_timestamp_diff32 Unexecuted instantiation: event.c:pj_timestamp_diff32 Unexecuted instantiation: sdp.c:pj_timestamp_diff32 Unexecuted instantiation: sdp_neg.c:pj_timestamp_diff32 Unexecuted instantiation: stream_common.c:pj_timestamp_diff32 Unexecuted instantiation: vid_codec.c:pj_timestamp_diff32 Unexecuted instantiation: av_sync.c:pj_timestamp_diff32 Unexecuted instantiation: codec.c:pj_timestamp_diff32 Unexecuted instantiation: rtcp.c:pj_timestamp_diff32 Unexecuted instantiation: rtcp_xr.c:pj_timestamp_diff32 Unexecuted instantiation: rtcp_fb.c:pj_timestamp_diff32 Unexecuted instantiation: endpoint.c:pj_timestamp_diff32 Unexecuted instantiation: transport_srtp.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-uri.c:pj_timestamp_diff32 Unexecuted instantiation: sip_parser.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-presence.c:pj_timestamp_diff32 Unexecuted instantiation: xml.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-dns-records.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-sip.c:pj_timestamp_diff32 Unexecuted instantiation: sip_endpoint.c:pj_timestamp_diff32 Unexecuted instantiation: sip_transport.c:pj_timestamp_diff32 Unexecuted instantiation: sip_transport_loop.c:pj_timestamp_diff32 Unexecuted instantiation: sip_transaction.c:pj_timestamp_diff32 Unexecuted instantiation: sip_dialog.c:pj_timestamp_diff32 Unexecuted instantiation: sip_ua_layer.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-sip-transaction.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-dns.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-video.c:pj_timestamp_diff32 Unexecuted instantiation: vpx_packetizer.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-rtp.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-stream.c:pj_timestamp_diff32 gsm.c:pj_timestamp_diff32 Line | Count | Source | 1553 | 1.38k | { | 1554 | | /* Be careful with the signess (I think!) */ | 1555 | 1.38k | #if PJ_HAS_INT64 | 1556 | 1.38k | pj_int64_t diff = t2->u64 - t1->u64; | 1557 | 1.38k | return (pj_int32_t) diff; | 1558 | | #else | 1559 | | pj_int32 diff = t2->u32.lo - t1->u32.lo; | 1560 | | return diff; | 1561 | | #endif | 1562 | 1.38k | } |
ilbc.c:pj_timestamp_diff32 Line | Count | Source | 1553 | 301 | { | 1554 | | /* Be careful with the signess (I think!) */ | 1555 | 301 | #if PJ_HAS_INT64 | 1556 | 301 | pj_int64_t diff = t2->u64 - t1->u64; | 1557 | 301 | return (pj_int32_t) diff; | 1558 | | #else | 1559 | | pj_int32 diff = t2->u32.lo - t1->u32.lo; | 1560 | | return diff; | 1561 | | #endif | 1562 | 301 | } |
g711.c:pj_timestamp_diff32 Line | Count | Source | 1553 | 2.76k | { | 1554 | | /* Be careful with the signess (I think!) */ | 1555 | 2.76k | #if PJ_HAS_INT64 | 1556 | 2.76k | pj_int64_t diff = t2->u64 - t1->u64; | 1557 | 2.76k | return (pj_int32_t) diff; | 1558 | | #else | 1559 | | pj_int32 diff = t2->u32.lo - t1->u32.lo; | 1560 | | return diff; | 1561 | | #endif | 1562 | 2.76k | } |
Unexecuted instantiation: fuzz-audio.c:pj_timestamp_diff32 Unexecuted instantiation: opus.c:pj_timestamp_diff32 Unexecuted instantiation: l16.c:pj_timestamp_diff32 Unexecuted instantiation: speex_codec.c:pj_timestamp_diff32 g722.c:pj_timestamp_diff32 Line | Count | Source | 1553 | 925 | { | 1554 | | /* Be careful with the signess (I think!) */ | 1555 | 925 | #if PJ_HAS_INT64 | 1556 | 925 | pj_int64_t diff = t2->u64 - t1->u64; | 1557 | 925 | return (pj_int32_t) diff; | 1558 | | #else | 1559 | | pj_int32 diff = t2->u32.lo - t1->u32.lo; | 1560 | | return diff; | 1561 | | #endif | 1562 | 925 | } |
Unexecuted instantiation: g722_enc.c:pj_timestamp_diff32 Unexecuted instantiation: g722_dec.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-sip-dialog.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-crypto.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-xml.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-stun.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-rtcp.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-multipart.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-srtp.c:pj_timestamp_diff32 Unexecuted instantiation: transport_loop.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-sdes.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-vpx.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-h264.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-http.c:pj_timestamp_diff32 Unexecuted instantiation: fuzz-auth.c:pj_timestamp_diff32 |
1563 | | |
1564 | | |
1565 | | /** |
1566 | | * Calculate the elapsed time, and store it in pj_time_val. |
1567 | | * This function calculates the elapsed time using highest precision |
1568 | | * calculation that is available for current platform, considering |
1569 | | * whether floating point or 64-bit precision arithmetic is available. |
1570 | | * For maximum portability, application should prefer to use this function |
1571 | | * rather than calculating the elapsed time by itself. |
1572 | | * |
1573 | | * @param start The starting timestamp. |
1574 | | * @param stop The end timestamp. |
1575 | | * |
1576 | | * @return Elapsed time as #pj_time_val. |
1577 | | * |
1578 | | * @see pj_elapsed_usec(), pj_elapsed_cycle(), pj_elapsed_nanosec() |
1579 | | */ |
1580 | | PJ_DECL(pj_time_val) pj_elapsed_time( const pj_timestamp *start, |
1581 | | const pj_timestamp *stop ); |
1582 | | |
1583 | | /** |
1584 | | * Calculate the elapsed time as 32-bit miliseconds. |
1585 | | * This function calculates the elapsed time using highest precision |
1586 | | * calculation that is available for current platform, considering |
1587 | | * whether floating point or 64-bit precision arithmetic is available. |
1588 | | * For maximum portability, application should prefer to use this function |
1589 | | * rather than calculating the elapsed time by itself. |
1590 | | * |
1591 | | * @param start The starting timestamp. |
1592 | | * @param stop The end timestamp. |
1593 | | * |
1594 | | * @return Elapsed time in milisecond. |
1595 | | * |
1596 | | * @see pj_elapsed_time(), pj_elapsed_cycle(), pj_elapsed_nanosec() |
1597 | | */ |
1598 | | PJ_DECL(pj_uint32_t) pj_elapsed_msec( const pj_timestamp *start, |
1599 | | const pj_timestamp *stop ); |
1600 | | |
1601 | | /** |
1602 | | * Variant of #pj_elapsed_msec() which returns 64bit value. |
1603 | | */ |
1604 | | PJ_DECL(pj_uint64_t) pj_elapsed_msec64(const pj_timestamp *start, |
1605 | | const pj_timestamp *stop ); |
1606 | | |
1607 | | /** |
1608 | | * Calculate the elapsed time in 32-bit microseconds. |
1609 | | * This function calculates the elapsed time using highest precision |
1610 | | * calculation that is available for current platform, considering |
1611 | | * whether floating point or 64-bit precision arithmetic is available. |
1612 | | * For maximum portability, application should prefer to use this function |
1613 | | * rather than calculating the elapsed time by itself. |
1614 | | * |
1615 | | * @param start The starting timestamp. |
1616 | | * @param stop The end timestamp. |
1617 | | * |
1618 | | * @return Elapsed time in microsecond. |
1619 | | * |
1620 | | * @see pj_elapsed_time(), pj_elapsed_cycle(), pj_elapsed_nanosec() |
1621 | | */ |
1622 | | PJ_DECL(pj_uint32_t) pj_elapsed_usec( const pj_timestamp *start, |
1623 | | const pj_timestamp *stop ); |
1624 | | |
1625 | | /** |
1626 | | * Calculate the elapsed time in 32-bit nanoseconds. |
1627 | | * This function calculates the elapsed time using highest precision |
1628 | | * calculation that is available for current platform, considering |
1629 | | * whether floating point or 64-bit precision arithmetic is available. |
1630 | | * For maximum portability, application should prefer to use this function |
1631 | | * rather than calculating the elapsed time by itself. |
1632 | | * |
1633 | | * @param start The starting timestamp. |
1634 | | * @param stop The end timestamp. |
1635 | | * |
1636 | | * @return Elapsed time in nanoseconds. |
1637 | | * |
1638 | | * @see pj_elapsed_time(), pj_elapsed_cycle(), pj_elapsed_usec() |
1639 | | */ |
1640 | | PJ_DECL(pj_uint32_t) pj_elapsed_nanosec( const pj_timestamp *start, |
1641 | | const pj_timestamp *stop ); |
1642 | | |
1643 | | /** |
1644 | | * Calculate the elapsed time in 32-bit cycles. |
1645 | | * This function calculates the elapsed time using highest precision |
1646 | | * calculation that is available for current platform, considering |
1647 | | * whether floating point or 64-bit precision arithmetic is available. |
1648 | | * For maximum portability, application should prefer to use this function |
1649 | | * rather than calculating the elapsed time by itself. |
1650 | | * |
1651 | | * @param start The starting timestamp. |
1652 | | * @param stop The end timestamp. |
1653 | | * |
1654 | | * @return Elapsed time in cycles. |
1655 | | * |
1656 | | * @see pj_elapsed_usec(), pj_elapsed_time(), pj_elapsed_nanosec() |
1657 | | */ |
1658 | | PJ_DECL(pj_uint32_t) pj_elapsed_cycle( const pj_timestamp *start, |
1659 | | const pj_timestamp *stop ); |
1660 | | |
1661 | | |
1662 | | #endif /* PJ_HAS_HIGH_RES_TIMER */ |
1663 | | |
1664 | | /** @} */ |
1665 | | |
1666 | | |
1667 | | /* **************************************************************************/ |
1668 | | /** |
1669 | | * @defgroup PJ_APP_OS Application execution |
1670 | | * @ingroup PJ_OS |
1671 | | * @{ |
1672 | | */ |
1673 | | |
1674 | | /** |
1675 | | * Type for application main function. |
1676 | | */ |
1677 | | typedef int (*pj_main_func_ptr)(int argc, char *argv[]); |
1678 | | |
1679 | | /** |
1680 | | * Run the application. This function has to be called in the main thread |
1681 | | * and after doing the necessary initialization according to the flags |
1682 | | * provided, it will call main_func() function. |
1683 | | * |
1684 | | * @param main_func Application's main function. |
1685 | | * @param argc Number of arguments from the main() function, which |
1686 | | * will be passed to main_func() function. |
1687 | | * @param argv The arguments from the main() function, which will |
1688 | | * be passed to main_func() function. |
1689 | | * @param flags Flags for application execution, currently must be 0. |
1690 | | * |
1691 | | * @return main_func()'s return value. |
1692 | | */ |
1693 | | PJ_DECL(int) pj_run_app(pj_main_func_ptr main_func, int argc, char *argv[], |
1694 | | unsigned flags); |
1695 | | |
1696 | | /** @} */ |
1697 | | |
1698 | | |
1699 | | /* **************************************************************************/ |
1700 | | /** |
1701 | | * Internal PJLIB function to initialize the threading subsystem. |
1702 | | * @return PJ_SUCCESS or the appropriate error code. |
1703 | | */ |
1704 | | pj_status_t pj_thread_init(void); |
1705 | | |
1706 | | |
1707 | | /* **************************************************************************/ |
1708 | | /** |
1709 | | * Set file descriptor close-on-exec flag |
1710 | | * |
1711 | | * @param fd The file descriptor |
1712 | | * @return on success, PJ_SUCCESS |
1713 | | * |
1714 | | */ |
1715 | | PJ_DECL(pj_status_t) pj_set_cloexec_flag(int fd); |
1716 | | |
1717 | | |
1718 | | PJ_END_DECL |
1719 | | |
1720 | | #endif /* __PJ_OS_H__ */ |
1721 | | |