1 // Package : omnithread
2 // omnithread/posix.h Created : 7/94 tjr
4 // Copyright (C) 2006 Free Software Foundation, Inc.
5 // Copyright (C) 1994,1995,1996, 1997 Olivetti & Oracle Research Laboratory
7 // This file is part of the omnithread library
9 // The omnithread library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Library General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Library General Public License for more details.
19 // You should have received a copy of the GNU Library General Public
20 // License along with this library; if not, write to the Free
21 // Software Foundation, Inc., 51 Franklin Street, Boston, MA
25 // OMNI thread implementation classes for posix threads
28 #ifndef __omnithread_posix_h_
29 #define __omnithread_posix_h_
31 #if defined(__alpha__) && defined(__osf1__) || defined(__hpux__)
32 // stop unnecessary definitions of TRY, etc on OSF
41 # ifndef WIN32_LEAN_AND_MEAN
42 # define WIN32_LEAN_AND_MEAN
43 # define OMNI_DEFINED_WIN32_LEAN_AND_MEAN
46 # include "pthread_nt.h"
47 # ifdef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
48 # undef WIN32_LEAN_AND_MEAN
49 # undef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
53 extern "C" void* omni_thread_wrapper(void* ptr);
55 #define OMNI_MUTEX_IMPLEMENTATION \
56 pthread_mutex_t posix_mutex;
58 #define OMNI_MUTEX_LOCK_IMPLEMENTATION \
59 pthread_mutex_lock(&posix_mutex);
61 #define OMNI_MUTEX_TRYLOCK_IMPLEMENTATION \
62 (pthread_mutex_trylock(&posix_mutex)==0);
64 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \
65 pthread_mutex_unlock(&posix_mutex);
67 #define OMNI_CONDITION_IMPLEMENTATION \
68 pthread_cond_t posix_cond;
70 #define OMNI_SEMAPHORE_IMPLEMENTATION \
76 #define OMNI_THREAD_IMPLEMENTATION \
77 pthread_t posix_thread; \
78 static int posix_priority(priority_t); \
79 friend void* omni_thread_wrapper(void* ptr);