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 __omnithread_nt_h_
00028 #define __omnithread_nt_h_
00029 
00030 #ifndef WIN32_LEAN_AND_MEAN
00031 #  define WIN32_LEAN_AND_MEAN
00032 #  define OMNI_DEFINED_WIN32_LEAN_AND_MEAN
00033 #endif
00034 
00035 #include <windows.h>
00036 
00037 #ifdef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
00038 #  undef WIN32_LEAN_AND_MEAN
00039 #  undef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
00040 #endif
00041 
00042 
00043 #ifndef __BCPLUSPLUS__
00044 #define OMNI_THREAD_WRAPPER \
00045     unsigned __stdcall omni_thread_wrapper(LPVOID ptr);
00046 #else
00047 #define OMNI_THREAD_WRAPPER \
00048     void _USERENTRY omni_thread_wrapper(void *ptr);
00049 #endif
00050 
00051 extern "C" OMNI_THREAD_WRAPPER;
00052 
00053 #define OMNI_MUTEX_IMPLEMENTATION                       \
00054     CRITICAL_SECTION crit;
00055 
00056 #define OMNI_MUTEX_LOCK_IMPLEMENTATION                  \
00057     EnterCriticalSection(&crit);
00058 
00059 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION                \
00060     LeaveCriticalSection(&crit);
00061 
00062 #define OMNI_CONDITION_IMPLEMENTATION                   \
00063     CRITICAL_SECTION crit;                              \
00064     omni_thread* waiting_head;                          \
00065     omni_thread* waiting_tail;
00066 
00067 #define OMNI_SEMAPHORE_IMPLEMENTATION                   \
00068     HANDLE nt_sem;
00069 
00070 #define OMNI_THREAD_IMPLEMENTATION                      \
00071     HANDLE handle;                                      \
00072     DWORD nt_id;                                        \
00073     void* return_val;                                   \
00074     HANDLE cond_semaphore;                              \
00075     omni_thread* cond_next;                             \
00076     omni_thread* cond_prev;                             \
00077     BOOL cond_waiting;                                  \
00078     static int nt_priority(priority_t);                 \
00079     friend class omni_condition;                        \
00080     friend OMNI_THREAD_WRAPPER;
00081 
00082 #endif