- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Configs/TI_DSP_BIOS/pthread_dspbios.h

    00001 #ifndef PTHREAD_DSPBIOS_H
    00002 #define PTHREAD_DSPBIOS_H
    00003
    00004 #include <stdarg.h>
    00005
    00006 using std::va_list;
    00007
    00008 #include <std.h>
    00009 #include <sem.h>
    00010 #include <lck.h>
    00011 #include <tsk.h>
    00012
    00013 #define pthread_mutex_t LCK_Handle
    00014 #define pthread_mutex_lock(MUTEX) LCK_pend(*(MUTEX),SYS_FOREVER)
    00015 #define pthread_mutex_unlock(MUTEX) LCK_post(*(MUTEX))
    00016
    00017 inline int pthread_mutex_init(LCK_Handle *MUTEX,int ATTR)
    00018      {
    00019         *MUTEX=LCK_create(NULL);
    00020         return 0;
    00021      }
    00022
    00023 #define pthread_mutex_destroy(MUTEX) LCK_delete(*(MUTEX));
    00024
    00025 #define pthread_cond_t SEM_Handle
    00026 inline int pthread_cond_init(SEM_Handle *COND,int ATTR)
    00027            {
    00028            *COND=SEM_create(0,NULL);
    00029            return 0;
    00030            }
    00031
    00032 inline void pthread_cond_wait(SEM_Handle *COND,LCK_Handle *MUTEX)
    00033    {
    00034    LCK_post(*MUTEX);
    00035    SEM_pend(*COND,SYS_FOREVER);
    00036    LCK_pend(*MUTEX,SYS_FOREVER);
    00037    }
    00038
    00039 #define pthread_cond_broadcast(COND) SEM_post(*(COND))
    00040 #define pthread_cond_destroy(COND) SEM_delete(*(COND))
    00041
    00042 #define pthread_t TSK_Handle
    00043 inline int pthread_create_func(void *(*FUNC)(void *), void *ARG) {
    00044         return (int)(*FUNC)(ARG);
    00045 }
    00046
    00047 inline int pthread_create(TSK_Handle *TASK,TSK_Attrs *ATTR,void *(*FUNC)(void *),void *ARG)
    00048           {
    00049                 // very ugly pointer casts. probably not compatible with the Arg and Fxn DSP/BIOS types
    00050           *TASK=TSK_create((Fxn)pthread_create_func,NULL,(Arg) FUNC, (Arg)ARG);
    00051           return 0;
    00052           }
    00053
    00054
    00055 #define pthread_cleanup_push(FUNC,ARG)
    00056 #define pthread_cleanup_pop(RET)
    00057 #define pthread_join(THREAD,NULL)
    00058 #define pthread_setcanceltype(CANCELTYPE,NULL)
    00059 #define pthread_setcancelstate(CANCELSTATE,NULL)
    00060 #define pthread_testcancel()
    00061 #define pthread_cancel(THREAD) TSK_delete(THREAD)
    00062 #define pthread_attr_t TSK_Attrs
    00063 #define pthread_attr_init(ATTR) 0
    00064 #define pthread_attr_setdetachstate(ATTR,DETACHSTATE)
    00065 #define pthread_attr_setscope(ATTR,SCOPE)
    00066 #define pthread_attr_destroy(ATTR)
    00067
    00068 #endif