|
HOME
SIP/media Features
High Performance SIP
Small Footprint SIP
Symbian Port
FAQ
Documentation
Licensing
Download
Development (Trac)
Projects using pjsip
Mailing List
Open Source Links
About: PJLIB, PJLIB-UTIL, PJSIP, and PJMEDIA are created by: Benny Prijono <bennylp pjsip.org>
|
|
Home --> Documentations --> PJLIB Reference
os.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJ_OS_H__
00021 #define __PJ_OS_H__
00022
00027 #include <pj/types.h>
00028
00029 PJ_BEGIN_DECL
00030
00036
00055 typedef enum pj_thread_create_flags
00056 {
00057 PJ_THREAD_SUSPENDED = 1
00058 } pj_thread_create_flags;
00059
00060
00064 typedef int (PJ_THREAD_FUNC pj_thread_proc)(void*);
00065
00069 #if !defined(PJ_THREAD_DESC_SIZE)
00070 # define PJ_THREAD_DESC_SIZE (64)
00071 #endif
00072
00077 typedef long pj_thread_desc[PJ_THREAD_DESC_SIZE];
00078
00083 PJ_DECL(pj_uint32_t) pj_getpid(void);
00084
00104 PJ_DECL(pj_status_t) pj_thread_create( pj_pool_t *pool,
00105 const char *thread_name,
00106 pj_thread_proc *proc,
00107 void *arg,
00108 pj_size_t stack_size,
00109 unsigned flags,
00110 pj_thread_t **thread );
00111
00128 PJ_DECL(pj_status_t) pj_thread_register ( const char *thread_name,
00129 pj_thread_desc desc,
00130 pj_thread_t **thread);
00131
00137 PJ_DECL(pj_bool_t) pj_thread_is_registered(void);
00138
00139
00147 PJ_DECL(int) pj_thread_get_prio(pj_thread_t *thread);
00148
00149
00160 PJ_DECL(pj_status_t) pj_thread_set_prio(pj_thread_t *thread, int prio);
00161
00168 PJ_DECL(int) pj_thread_get_prio_min(pj_thread_t *thread);
00169
00170
00177 PJ_DECL(int) pj_thread_get_prio_max(pj_thread_t *thread);
00178
00179
00191 PJ_DECL(void*) pj_thread_get_os_handle(pj_thread_t *thread);
00192
00200 PJ_DECL(const char*) pj_thread_get_name(pj_thread_t *thread);
00201
00209 PJ_DECL(pj_status_t) pj_thread_resume(pj_thread_t *thread);
00210
00216 PJ_DECL(pj_thread_t*) pj_thread_this(void);
00217
00227 PJ_DECL(pj_status_t) pj_thread_join(pj_thread_t *thread);
00228
00229
00239 PJ_DECL(pj_status_t) pj_thread_destroy(pj_thread_t *thread);
00240
00241
00249 PJ_DECL(pj_status_t) pj_thread_sleep(unsigned msec);
00250
00257 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
00258
00259 # define PJ_CHECK_STACK() pj_thread_check_stack(__FILE__, __LINE__)
00260
00264 PJ_DECL(void) pj_thread_check_stack(const char *file, int line);
00265
00269 PJ_DECL(pj_uint32_t) pj_thread_get_stack_max_usage(pj_thread_t *thread);
00270
00274 PJ_DECL(pj_status_t) pj_thread_get_stack_info(pj_thread_t *thread,
00275 const char **file,
00276 int *line);
00277 #else
00278
00279 # define PJ_CHECK_STACK()
00280
00281 # define pj_thread_get_stack_max_usage(thread) 0
00282
00283 # define pj_thread_get_stack_info(thread,f,l) (*(f)="",*(l)=0)
00284 #endif
00285
00290
00347 PJ_DECL(pj_bool_t) pj_symbianos_poll(int priority, int ms_timeout);
00348
00349
00354 typedef struct pj_symbianos_params
00355 {
00361 void *rsocketserv;
00362
00368 void *rconnection;
00369
00375 void *rhostresolver;
00376
00382 void *rhostresolver6;
00383
00384 } pj_symbianos_params;
00385
00395 PJ_DECL(pj_status_t) pj_symbianos_set_params(pj_symbianos_params *prm);
00396
00408 PJ_DECL(void) pj_symbianos_set_connection_status(pj_bool_t up);
00409
00414
00428 PJ_DECL(pj_status_t) pj_thread_local_alloc(long *index);
00429
00435 PJ_DECL(void) pj_thread_local_free(long index);
00436
00443 PJ_DECL(pj_status_t) pj_thread_local_set(long index, void *value);
00444
00451 PJ_DECL(void*) pj_thread_local_get(long index);
00452
00453
00459
00483 PJ_DECL(pj_status_t) pj_atomic_create( pj_pool_t *pool,
00484 pj_atomic_value_t initial,
00485 pj_atomic_t **atomic );
00486
00494 PJ_DECL(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var );
00495
00502 PJ_DECL(void) pj_atomic_set( pj_atomic_t *atomic_var,
00503 pj_atomic_value_t value);
00504
00512 PJ_DECL(pj_atomic_value_t) pj_atomic_get(pj_atomic_t *atomic_var);
00513
00519 PJ_DECL(void) pj_atomic_inc(pj_atomic_t *atomic_var);
00520
00528 PJ_DECL(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var);
00529
00535 PJ_DECL(void) pj_atomic_dec(pj_atomic_t *atomic_var);
00536
00544 PJ_DECL(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var);
00545
00552 PJ_DECL(void) pj_atomic_add( pj_atomic_t *atomic_var,
00553 pj_atomic_value_t value);
00554
00563 PJ_DECL(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,
00564 pj_atomic_value_t value);
00565
00570
00587 typedef enum pj_mutex_type_e
00588 {
00589 PJ_MUTEX_DEFAULT,
00590 PJ_MUTEX_SIMPLE,
00591 PJ_MUTEX_RECURSE
00592 } pj_mutex_type_e;
00593
00594
00605 PJ_DECL(pj_status_t) pj_mutex_create(pj_pool_t *pool,
00606 const char *name,
00607 int type,
00608 pj_mutex_t **mutex);
00609
00621 PJ_DECL(pj_status_t) pj_mutex_create_simple( pj_pool_t *pool, const char *name,
00622 pj_mutex_t **mutex );
00623
00635 PJ_DECL(pj_status_t) pj_mutex_create_recursive( pj_pool_t *pool,
00636 const char *name,
00637 pj_mutex_t **mutex );
00638
00645 PJ_DECL(pj_status_t) pj_mutex_lock(pj_mutex_t *mutex);
00646
00653 PJ_DECL(pj_status_t) pj_mutex_unlock(pj_mutex_t *mutex);
00654
00662 PJ_DECL(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex);
00663
00670 PJ_DECL(pj_status_t) pj_mutex_destroy(pj_mutex_t *mutex);
00671
00678 PJ_DECL(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex);
00679
00684
00700 typedef struct pj_rwmutex_t pj_rwmutex_t;
00701
00711 PJ_DECL(pj_status_t) pj_rwmutex_create(pj_pool_t *pool, const char *name,
00712 pj_rwmutex_t **mutex);
00713
00720 PJ_DECL(pj_status_t) pj_rwmutex_lock_read(pj_rwmutex_t *mutex);
00721
00728 PJ_DECL(pj_status_t) pj_rwmutex_lock_write(pj_rwmutex_t *mutex);
00729
00736 PJ_DECL(pj_status_t) pj_rwmutex_unlock_read(pj_rwmutex_t *mutex);
00737
00744 PJ_DECL(pj_status_t) pj_rwmutex_unlock_write(pj_rwmutex_t *mutex);
00745
00752 PJ_DECL(pj_status_t) pj_rwmutex_destroy(pj_rwmutex_t *mutex);
00753
00754
00760
00783 PJ_DECL(void) pj_enter_critical_section(void);
00784
00788 PJ_DECL(void) pj_leave_critical_section(void);
00789
00794
00795 #if defined(PJ_HAS_SEMAPHORE) && PJ_HAS_SEMAPHORE != 0
00796
00815 PJ_DECL(pj_status_t) pj_sem_create( pj_pool_t *pool,
00816 const char *name,
00817 unsigned initial,
00818 unsigned max,
00819 pj_sem_t **sem);
00820
00828 PJ_DECL(pj_status_t) pj_sem_wait(pj_sem_t *sem);
00829
00837 PJ_DECL(pj_status_t) pj_sem_trywait(pj_sem_t *sem);
00838
00846 PJ_DECL(pj_status_t) pj_sem_post(pj_sem_t *sem);
00847
00855 PJ_DECL(pj_status_t) pj_sem_destroy(pj_sem_t *sem);
00856
00860 #endif
00861
00862
00863
00864 #if defined(PJ_HAS_EVENT_OBJ) && PJ_HAS_EVENT_OBJ != 0
00865
00885 PJ_DECL(pj_status_t) pj_event_create(pj_pool_t *pool, const char *name,
00886 pj_bool_t manual_reset, pj_bool_t initial,
00887 pj_event_t **event);
00888
00896 PJ_DECL(pj_status_t) pj_event_wait(pj_event_t *event);
00897
00905 PJ_DECL(pj_status_t) pj_event_trywait(pj_event_t *event);
00906
00918 PJ_DECL(pj_status_t) pj_event_set(pj_event_t *event);
00919
00930 PJ_DECL(pj_status_t) pj_event_pulse(pj_event_t *event);
00931
00939 PJ_DECL(pj_status_t) pj_event_reset(pj_event_t *event);
00940
00948 PJ_DECL(pj_status_t) pj_event_destroy(pj_event_t *event);
00949
00953 #endif
00954
00955
00975 PJ_DECL(pj_status_t) pj_gettimeofday(pj_time_val *tv);
00976
00977
00986 PJ_DECL(pj_status_t) pj_time_decode(const pj_time_val *tv, pj_parsed_time *pt);
00987
00996 PJ_DECL(pj_status_t) pj_time_encode(const pj_parsed_time *pt, pj_time_val *tv);
00997
01005 PJ_DECL(pj_status_t) pj_time_local_to_gmt(pj_time_val *tv);
01006
01014 PJ_DECL(pj_status_t) pj_time_gmt_to_local(pj_time_val *tv);
01015
01020
01021 #if defined(PJ_TERM_HAS_COLOR) && PJ_TERM_HAS_COLOR != 0
01022
01036 PJ_DECL(pj_status_t) pj_term_set_color(pj_color_t color);
01037
01043 PJ_DECL(pj_color_t) pj_term_get_color(void);
01044
01049 #endif
01050
01051
01072
01073
01074
01075 #if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0
01076
01086 PJ_DECL(pj_status_t) pj_get_timestamp(pj_timestamp *ts);
01087
01094 PJ_DECL(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq);
01095
01102 PJ_INLINE(void) pj_set_timestamp32(pj_timestamp *t, pj_uint32_t hi,
01103 pj_uint32_t lo)
01104 {
01105 t->u32.hi = hi;
01106 t->u32.lo = lo;
01107 }
01108
01109
01116 PJ_INLINE(int) pj_cmp_timestamp(const pj_timestamp *t1, const pj_timestamp *t2)
01117 {
01118 #if PJ_HAS_INT64
01119 if (t1->u64 < t2->u64)
01120 return -1;
01121 else if (t1->u64 > t2->u64)
01122 return 1;
01123 else
01124 return 0;
01125 #else
01126 if (t1->u32.hi < t2->u32.hi ||
01127 (t1->u32.hi == t2->u32.hi && t1->u32.lo < t2->u32.lo))
01128 return -1;
01129 else if (t1->u32.hi > t2->u32.hi ||
01130 (t1->u32.hi == t2->u32.hi && t1->u32.lo > t2->u32.lo))
01131 return 1;
01132 else
01133 return 0;
01134 #endif
01135 }
01136
01137
01143 PJ_INLINE(void) pj_add_timestamp(pj_timestamp *t1, const pj_timestamp *t2)
01144 {
01145 #if PJ_HAS_INT64
01146 t1->u64 += t2->u64;
01147 #else
01148 pj_uint32_t old = t1->u32.lo;
01149 t1->u32.hi += t2->u32.hi;
01150 t1->u32.lo += t2->u32.lo;
01151 if (t1->u32.lo < old)
01152 ++t1->u32.hi;
01153 #endif
01154 }
01155
01161 PJ_INLINE(void) pj_add_timestamp32(pj_timestamp *t1, pj_uint32_t t2)
01162 {
01163 #if PJ_HAS_INT64
01164 t1->u64 += t2;
01165 #else
01166 pj_uint32_t old = t1->u32.lo;
01167 t1->u32.lo += t2;
01168 if (t1->u32.lo < old)
01169 ++t1->u32.hi;
01170 #endif
01171 }
01172
01178 PJ_INLINE(void) pj_sub_timestamp(pj_timestamp *t1, const pj_timestamp *t2)
01179 {
01180 #if PJ_HAS_INT64
01181 t1->u64 -= t2->u64;
01182 #else
01183 t1->u32.hi -= t2->u32.hi;
01184 if (t1->u32.lo >= t2->u32.lo)
01185 t1->u32.lo -= t2->u32.lo;
01186 else {
01187 t1->u32.lo -= t2->u32.lo;
01188 --t1->u32.hi;
01189 }
01190 #endif
01191 }
01192
01198 PJ_INLINE(void) pj_sub_timestamp32(pj_timestamp *t1, pj_uint32_t t2)
01199 {
01200 #if PJ_HAS_INT64
01201 t1->u64 -= t2;
01202 #else
01203 if (t1->u32.lo >= t2)
01204 t1->u32.lo -= t2;
01205 else {
01206 t1->u32.lo -= t2;
01207 --t1->u32.hi;
01208 }
01209 #endif
01210 }
01211
01216 PJ_INLINE(pj_int32_t) pj_timestamp_diff32(const pj_timestamp *t1,
01217 const pj_timestamp *t2)
01218 {
01219
01220 #if PJ_HAS_INT64
01221 pj_int64_t diff = t2->u64 - t1->u64;
01222 return (pj_int32_t) diff;
01223 #else
01224 pj_int32 diff = t2->u32.lo - t1->u32.lo;
01225 return diff;
01226 #endif
01227 }
01228
01229
01245 PJ_DECL(pj_time_val) pj_elapsed_time( const pj_timestamp *start,
01246 const pj_timestamp *stop );
01247
01263 PJ_DECL(pj_uint32_t) pj_elapsed_msec( const pj_timestamp *start,
01264 const pj_timestamp *stop );
01265
01269 PJ_DECL(pj_uint64_t) pj_elapsed_msec64(const pj_timestamp *start,
01270 const pj_timestamp *stop );
01271
01287 PJ_DECL(pj_uint32_t) pj_elapsed_usec( const pj_timestamp *start,
01288 const pj_timestamp *stop );
01289
01305 PJ_DECL(pj_uint32_t) pj_elapsed_nanosec( const pj_timestamp *start,
01306 const pj_timestamp *stop );
01307
01323 PJ_DECL(pj_uint32_t) pj_elapsed_cycle( const pj_timestamp *start,
01324 const pj_timestamp *stop );
01325
01326
01327 #endif
01328
01332
01337 pj_status_t pj_thread_init(void);
01338
01339
01340 PJ_END_DECL
01341
01342 #endif
01343
PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.
|
|