00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef UTILS_H
00028 #define UTILS_H
00029
00030 #include "ortp/event.h"
00031
00032 struct _OList {
00033 struct _OList *next;
00034 struct _OList *prev;
00035 void *data;
00036 };
00037
00038 typedef struct _OList OList;
00039
00040
00041 #define o_list_next(elem) ((elem)->next)
00042
00043 OList * o_list_append(OList *elem, void * data);
00044 OList * o_list_remove(OList *list, void *data);
00045 OList * o_list_free(OList *elem);
00046 OList *o_list_remove_link(OList *list, OList *elem);
00047
00048 #ifndef MIN
00049 #define MIN(a,b) (((a)>(b)) ? (b) : (a))
00050 #endif
00051 #ifndef MAX
00052 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
00053 #endif
00054
00055 #define return_if_fail(expr) if (!(expr)) {printf("%s:%i- assertion"#expr "failed\n",__FILE__,__LINE__); return;}
00056 #define return_val_if_fail(expr,ret) if (!(expr)) {printf("%s:%i- assertion" #expr "failed\n",__FILE__,__LINE__); return (ret);}
00057
00058
00059 #define INT_TO_POINTER(truc) ((long)(long)(truc))
00060 #define POINTER_TO_INT(truc) ((int)(long)(truc))
00061
00062 typedef struct _dwsplit_t{
00063 #ifdef ORTP_BIGENDIAN
00064 uint16_t hi;
00065 uint16_t lo;
00066 #else
00067 uint16_t lo;
00068 uint16_t hi;
00069 #endif
00070 } dwsplit_t;
00071
00072 typedef union{
00073 dwsplit_t split;
00074 uint32_t one;
00075 } poly32_t;
00076
00077 #ifdef ORTP_BIGENDIAN
00078 #define hton24(x) (x)
00079 #else
00080 #define hton24(x) ((( (x) & 0x00ff0000) >>16) | (( (x) & 0x000000ff) <<16) | ( (x) & 0x0000ff00) )
00081 #endif
00082 #define ntoh24(x) hton24(x)
00083
00084 #if defined(WIN32) || defined(_WIN32_WCE)
00085 #define is_would_block_error(errnum) (errnum==WSAEWOULDBLOCK)
00086 #else
00087 #define is_would_block_error(errnum) (errnum==EWOULDBLOCK || errnum==EAGAIN)
00088 #endif
00089
00090 void ortp_ev_queue_put(OrtpEvQueue *q, OrtpEvent *ev);
00091
00092 #endif