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., 59 Temple Place - Suite 330, Boston, MA
21 // 02111-1307, 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_UNLOCK_IMPLEMENTATION \
60 LeaveCriticalSection(&crit);
61
62 #define OMNI_CONDITION_IMPLEMENTATION \
63 CRITICAL_SECTION crit; \
64 omni_thread* waiting_head; \
65 omni_thread* waiting_tail;
66
67 #define OMNI_SEMAPHORE_IMPLEMENTATION \
68 HANDLE nt_sem;
69
70 #define OMNI_THREAD_IMPLEMENTATION \
71 HANDLE handle; \
72 DWORD nt_id; \
73 void* return_val; \
74 HANDLE cond_semaphore; \
75 omni_thread* cond_next; \
76 omni_thread* cond_prev; \
77 BOOL cond_waiting; \
78 static int nt_priority(priority_t); \
79 friend class omni_condition; \
80 friend OMNI_THREAD_WRAPPER;
81
82 #endif
syntax highlighted by Code2HTML, v. 0.9.1