00001 #ifndef __CBTHR_H_
00002 #define __CBTHR_H_
00003
00086 #ifndef W32_THREADS
00087 # if (defined(_WIN32) || (defined(UNDER_CE)))
00088 # define W32_THREADS
00089 # endif
00090 #endif
00091
00092 #ifndef FOR_MS_WINDOWS
00093 # if (defined(W32_THREADS) && ! defined(__WINE__))
00094 # define FOR_MS_WINDOWS
00095 # endif
00096 #endif
00097
00098 #ifdef W32_THREADS
00099
00100 # include <windows.h>
00101 # define CBTHRFUNCTYPE DWORD __stdcall
00102 # define CBTHREND { ExitThread(0); return 0; }
00103
00104 # ifdef __cplusplus
00105 extern "C" {
00106 # endif
00107
00108 typedef HANDLE t_cbthr;
00109 typedef CRITICAL_SECTION t_cbthrcs;
00110 typedef DWORD (__stdcall *t_cbthrfunc)(void *);
00111
00112 # ifdef __cplusplus
00113 }
00114 # endif
00115
00116 #else
00117
00118 # include <pthread.h>
00119 # define CBTHRFUNCTYPE void*
00120 # define CBTHREND { pthread_exit(NULL); return NULL; }
00121
00122 # ifdef __cplusplus
00123 extern "C" {
00124 # endif
00125
00126 typedef pthread_t t_cbthr;
00127 typedef pthread_mutex_t t_cbthrcs;
00128 typedef CBTHRFUNCTYPE (*t_cbthrfunc)(void *);
00129
00130 # ifdef __cplusplus
00131 }
00132 # endif
00133
00134 #endif
00135
00136 #ifdef __cplusplus
00137 extern "C" {
00138 #endif
00139
00140 extern const t_cbthr CBINVALIDTHREAD;
00141
00149 int cbthr_create(t_cbthr *theThread,
00150 t_cbthrfunc aThrFunc,
00151 void *thrFuncParms);
00152
00158 int cbthr_join(t_cbthr aThread);
00159
00173 int cbthr_init_cs(t_cbthrcs *aCritSec);
00174
00179 int cbthr_enter_cs(t_cbthrcs *aCritSec);
00180
00187 int cbthr_leave_cs(t_cbthrcs *aCritSec);
00188
00193 int cbthr_delete_cs(t_cbthrcs *aCritSec);
00194
00195 # ifdef __cplusplus
00196 }
00197 # endif
00198
00199 #endif
00200