libosip  5.3.0
How-To handle portability.

Description.

The libosip2 library also offer high portability through a common API for conditions variables, fifos, threads, mutex and semaphore: all you need to write portable applications.

The target and active development platforms are: linux, windows, macosx, android and iOS. Those platforms are tested every day and you can use the git repository without fear!

Additionnaly, wince, windows mobile, vxworks, unix, linux on arm -and more- have been also tested regularly. If you have troubles for some system, please ask the mailing list (osip-.nosp@m.dev@.nosp@m.gnu.o.nosp@m.rg)

#include <osip2/osip_mt.h>
#include <osip2/osip_time.h>
oSIP condition variables definitions
oSIP fifo Routines
oSIP Thread, Mutex and Semaphore definitions

Threads

void *_my_thread (void *arg)
{
struct sometype_t *excontext = (struct sometype_t *) arg;
int i;
while (stopthread == 0) {
do_actions (excontext);
}
return NULL;
}
struct osip_thread *thread;
thread = osip_thread_create (20000, _my_thread, argpointer);
void osip_thread_exit(void)
struct osip_thread * osip_thread_create(int stacksize, void *(*func)(void *), void *arg)
i = osip_thread_join (thread);
osip_free (thread);
int osip_thread_join(struct osip_thread *thread)

Mutex

struct osip_mutex *mutex;
mutex = osip_mutex_init ();
do_actions ();
int osip_mutex_lock(struct osip_mutex *mut)
int osip_mutex_unlock(struct osip_mutex *mut)
struct osip_mutex * osip_mutex_init(void)
void osip_mutex_destroy(struct osip_mutex *mut)

Time

libosip2 is also providing a common time API.

This is usefull to implement in various way a CLOCK_MONOTONIC time and make time adjustement when a drift is discovered against realtime clock.

Note**: It is required to call osip_compensatetime on Android which goes regularly into deep sleep mode. When this happens, the MONOTONIC clock is not increasing. This may also happen for other OS as well.

int osip_gettimeofday (struct timeval *tp, void *tz);
void osip_compensatetime ();