1 // Package : omnithread
2 // omnithread/nt.h Created : 6/95 tjr
4 // Copyright (C) 1995, 1996, 1997 Olivetti & Oracle Research Laboratory
6 // This file is part of the omnithread library
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.
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.
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
24 // OMNI thread implementation classes for NT threads.
27 #ifndef __omnithread_nt_h_
28 #define __omnithread_nt_h_
30 #ifndef WIN32_LEAN_AND_MEAN
31 # define WIN32_LEAN_AND_MEAN
32 # define OMNI_DEFINED_WIN32_LEAN_AND_MEAN
37 #ifdef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
38 # undef WIN32_LEAN_AND_MEAN
39 # undef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
43 #ifndef __BCPLUSPLUS__
44 #define OMNI_THREAD_WRAPPER \
45 unsigned __stdcall omni_thread_wrapper(LPVOID ptr);
47 #define OMNI_THREAD_WRAPPER \
48 void _USERENTRY omni_thread_wrapper(void *ptr);
51 extern "C" OMNI_THREAD_WRAPPER;
53 #define OMNI_MUTEX_IMPLEMENTATION \
54 CRITICAL_SECTION crit;
56 #define OMNI_MUTEX_LOCK_IMPLEMENTATION \
57 EnterCriticalSection(&crit);
59 #define OMNI_MUTEX_TRYLOCK_IMPLEMENTATION \
60 TryEnterCriticalSection(&crit);
62 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \
63 LeaveCriticalSection(&crit);
65 #define OMNI_CONDITION_IMPLEMENTATION \
66 CRITICAL_SECTION crit; \
67 omni_thread* waiting_head; \
68 omni_thread* waiting_tail;
70 #define OMNI_SEMAPHORE_IMPLEMENTATION \
73 #define OMNI_THREAD_IMPLEMENTATION \
77 HANDLE cond_semaphore; \
78 omni_thread* cond_next; \
79 omni_thread* cond_prev; \
81 static int nt_priority(priority_t); \
82 friend class omni_condition; \
83 friend OMNI_THREAD_WRAPPER;