dn_thread.h
Go to the documentation of this file.
00001 #ifndef DN_THREAD_H_
00002 #define DN_THREAD_H_
00003 
00038 #ifndef _DN_EXP_THREAD
00039 #define _DN_EXP_THREAD
00040 #endif /* _DN_EXP_THREAD */
00041 
00062 #if defined(_USE_WIN_API)
00063 #define begin_thread(p_thread, function, arg) { *p_thread = (HANDLE)_beginthreadex(NULL, 0, function, arg, 0, NULL); }
00064 #define exit_thread(thread) { if(thread != NULL) { WaitForSingleObject(thread, INFINITE); CloseHandle(thread); thread = NULL; } }
00065 #define dn_sleep(n) Sleep(n)
00066 typedef HANDLE MUTEX;
00067 typedef HANDLE THREAD;
00068 typedef unsigned int THRET;
00069 #define THTYPE __stdcall
00070 typedef HANDLE EVENT;
00071 #elif defined(_USE_LINUX_API)
00072 #define begin_thread(p_thread, function, arg) pthread_create(p_thread, NULL, function, arg)
00073 #define exit_thread(thread) pthread_join(thread, NULL)
00074 #define dn_sleep(n) usleep((n) * 1000)
00075 typedef pthread_mutex_t MUTEX;
00076 typedef pthread_t THREAD;
00077 typedef void *THRET;
00078 #define THTYPE
00079 #define STATUS_WAIT_0 ((uint32_t)0x00000000L)
00080 #define WAIT_OBJECT_0 ((STATUS_WAIT_0) + 0)
00081 typedef struct EVENT
00082   {
00083     pthread_mutex_t mutex;
00084     pthread_cond_t cond;
00085     int mode;
00086     int signal;
00087   }EVENT;
00088 #endif
00089 
00094 #ifndef INFINITE
00095 #define INFINITE ((uint32_t)-1)
00096 #endif
00097 
00098 #ifdef __cplusplus
00099 extern "C"
00100 {
00101 #endif
00102 
00108   _DN_EXP_THREAD HRESULT
00109   initialize_mutex(MUTEX *pmutex);
00110 
00117   _DN_EXP_THREAD HRESULT
00118   release_mutex(MUTEX *pmutex);
00119 
00126   _DN_EXP_THREAD HRESULT
00127   lock_mutex(MUTEX *pmutex, uint32_t timeout);
00128 
00134   _DN_EXP_THREAD HRESULT
00135   unlock_mutex(MUTEX *pmutex);
00136 
00144   _DN_EXP_THREAD HRESULT
00145   create_event(EVENT *pevt, int reset_mode, int init_signal);
00146 
00153   _DN_EXP_THREAD HRESULT
00154   destroy_event(EVENT *pevt);
00155 
00161   _DN_EXP_THREAD HRESULT
00162   set_event(EVENT *pevt);
00163 
00169   _DN_EXP_THREAD HRESULT
00170   reset_event(EVENT *pevt);
00171 
00178   _DN_EXP_THREAD HRESULT
00179   wait_event(EVENT *pevt, uint32_t timeout);
00180 
00189   _DN_EXP_THREAD HRESULT
00190   wait_event_multi(EVENT **pevt, uint32_t count, uint32_t timeout,
00191       int wait_all);
00192 
00199 #define calc_time_diff(start, end) (((end) >= (start)) ? ((end) - (start)) : ((((uint32_t)-1) - (end)) + (start)))
00200 
00205   _DN_EXP_THREAD uint32_t
00206   gettimeofday_msec();
00207 
00208 #ifdef __cplusplus
00209 }
00210 #endif
00211 
00212 #endif /* DN_THREAD_H_ */


bcap_core
Author(s): DENSO WAVE INCORPORATED
autogenerated on Thu Jun 6 2019 21:00:03