www.pudn.com > streamrtp.rar > util.h
/*------------------------------------------------------------------------- * util.h - align, hton24 *------------------------------------------------------------------------- */ #ifndef UTIL_H #define UTIL_H #include#include /* thread states */ #define THR_NOTRUNNING 0 #define THR_INITIALIZING 1 #define THR_RUNNING 2 #define THR_TERMINATE 3 #define UTIL_STOPTHREADDELTA {0, 10000000} /* 10 ms */ #define UTIL_STOPTHREADMAXTRIES 15 /* max signals to send */ /* Misc utilities */ #define align(val, align) (val + (val % align != 0 ? align - (val % align) : 0)) #define hton24(v) (((v&0xff) << 16) | (v&0xff00) | ((v&0xff0000)>>16)) /* Time utilities */ struct timespec timesub(struct timespec, struct timespec); struct timespec timeadd(struct timespec, struct timespec); mediatime_t timeflatten(struct timespec, int); struct timespec timeunflatten(mediatime_t, int); int timecmp(struct timespec, struct timespec); /* Thread utilities */ int startthread(pthread_t *, void *(*)(void *), void *, pthread_mutex_t *, pthread_cond_t *, int *); int stopthread(pthread_t *, pthread_mutex_t *, pthread_cond_t *, int *); /* signal handler */ void nullfcn(int); #endif