GNU Radio 3.2.2 C++ API
|
00001 // Package : omnithread 00002 // omnithread/nt.h Created : 6/95 tjr 00003 // 00004 // Copyright (C) 1995, 1996, 1997 Olivetti & Oracle Research Laboratory 00005 // 00006 // This file is part of the omnithread library 00007 // 00008 // The omnithread library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free 00020 // Software Foundation, Inc., 51 Franklin Street, Boston, MA 00021 // 02110-1301, USA 00022 // 00023 // 00024 // OMNI thread implementation classes for NT threads. 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_TRYLOCK_IMPLEMENTATION \ 00060 TryEnterCriticalSection(&crit); 00061 00062 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \ 00063 LeaveCriticalSection(&crit); 00064 00065 #define OMNI_CONDITION_IMPLEMENTATION \ 00066 CRITICAL_SECTION crit; \ 00067 omni_thread* waiting_head; \ 00068 omni_thread* waiting_tail; 00069 00070 #define OMNI_SEMAPHORE_IMPLEMENTATION \ 00071 HANDLE nt_sem; 00072 00073 #define OMNI_THREAD_IMPLEMENTATION \ 00074 HANDLE handle; \ 00075 DWORD nt_id; \ 00076 void* return_val; \ 00077 HANDLE cond_semaphore; \ 00078 omni_thread* cond_next; \ 00079 omni_thread* cond_prev; \ 00080 BOOL cond_waiting; \ 00081 static int nt_priority(priority_t); \ 00082 friend class omni_condition; \ 00083 friend OMNI_THREAD_WRAPPER; 00084 00085 #endif