Imported Upstream version 3.2.2
[debian/gnuradio] / omnithread / gnuradio / ot_nt.h
1 //                              Package : omnithread
2 // omnithread/nt.h              Created : 6/95 tjr
3 //
4 //    Copyright (C) 1995, 1996, 1997 Olivetti & Oracle Research Laboratory
5 //
6 //    This file is part of the omnithread library
7 //
8 //    The omnithread library is free software; you can redistribute it and/or
9 //    modify it under the terms of the GNU Library General Public
10 //    License as published by the Free Software Foundation; either
11 //    version 2 of the License, or (at your option) any later version.
12 //
13 //    This library is distributed in the hope that it will be useful,
14 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 //    Library General Public License for more details.
17 //
18 //    You should have received a copy of the GNU Library General Public
19 //    License along with this library; if not, write to the Free
20 //    Software Foundation, Inc., 51 Franklin Street, Boston, MA  
21 //    02110-1301, USA
22 //
23 //
24 // OMNI thread implementation classes for NT threads.
25 //
26
27 #ifndef __omnithread_nt_h_
28 #define __omnithread_nt_h_
29
30 #ifndef WIN32_LEAN_AND_MEAN
31 #  define WIN32_LEAN_AND_MEAN
32 #  define OMNI_DEFINED_WIN32_LEAN_AND_MEAN
33 #endif
34
35 #include <windows.h>
36
37 #ifdef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
38 #  undef WIN32_LEAN_AND_MEAN
39 #  undef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
40 #endif
41
42
43 #ifndef __BCPLUSPLUS__
44 #define OMNI_THREAD_WRAPPER \
45     unsigned __stdcall omni_thread_wrapper(LPVOID ptr);
46 #else
47 #define OMNI_THREAD_WRAPPER \
48     void _USERENTRY omni_thread_wrapper(void *ptr);
49 #endif
50
51 extern "C" OMNI_THREAD_WRAPPER;
52
53 #define OMNI_MUTEX_IMPLEMENTATION                       \
54     CRITICAL_SECTION crit;
55
56 #define OMNI_MUTEX_LOCK_IMPLEMENTATION                  \
57     EnterCriticalSection(&crit);
58
59 #define OMNI_MUTEX_TRYLOCK_IMPLEMENTATION               \
60     TryEnterCriticalSection(&crit);
61
62 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION                \
63     LeaveCriticalSection(&crit);
64
65 #define OMNI_CONDITION_IMPLEMENTATION                   \
66     CRITICAL_SECTION crit;                              \
67     omni_thread* waiting_head;                          \
68     omni_thread* waiting_tail;
69
70 #define OMNI_SEMAPHORE_IMPLEMENTATION                   \
71     HANDLE nt_sem;
72
73 #define OMNI_THREAD_IMPLEMENTATION                      \
74     HANDLE handle;                                      \
75     DWORD nt_id;                                        \
76     void* return_val;                                   \
77     HANDLE cond_semaphore;                              \
78     omni_thread* cond_next;                             \
79     omni_thread* cond_prev;                             \
80     BOOL cond_waiting;                                  \
81     static int nt_priority(priority_t);                 \
82     friend class omni_condition;                        \
83     friend OMNI_THREAD_WRAPPER;
84
85 #endif