1 // Package : omnithread
2 // omnithread/posix.h Created : 7/94 tjr
3 //
4 // Copyright (C) 1994,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 posix threads
25 //
26
27 #ifndef __omnithread_posix_h_
28 #define __omnithread_posix_h_
29
30 #if defined(__alpha__) && defined(__osf1__) || defined(__hpux__)
31 // stop unnecessary definitions of TRY, etc on OSF
32 #ifndef EXC_HANDLING
33 #define EXC_HANDLING
34 #endif
35 #endif
36
37 #ifdef __VMS
38 #define pthread_mutex_lock PTHREAD_MUTEX_LOCK
39 #define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK
40 #endif
41
42 // Use our pthreads_win32 port to WINCE (marcelruff.info)
43 #if defined(WINCE)
44 #include <pthreads/pthread.h>
45 #else
46
47 #ifndef __POSIX_NT__
48 # include <pthread.h>
49 #else
50 # ifndef WIN32_LEAN_AND_MEAN
51 # define WIN32_LEAN_AND_MEAN
52 # define OMNI_DEFINED_WIN32_LEAN_AND_MEAN
53 # endif
54 # include <windows.h>
55 # include "pthread_nt.h"
56 # ifdef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
57 # undef WIN32_LEAN_AND_MEAN
58 # undef OMNI_DEFINED_WIN32_LEAN_AND_MEAN
59 # endif
60 #endif
61 #endif
62
63 extern "C" void* omni_thread_wrapper(void* ptr);
64
65 #define OMNI_MUTEX_IMPLEMENTATION \
66 pthread_mutex_t posix_mutex;
67
68 #define OMNI_MUTEX_LOCK_IMPLEMENTATION \
69 pthread_mutex_lock(&posix_mutex);
70
71 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \
72 pthread_mutex_unlock(&posix_mutex);
73
74 #define OMNI_CONDITION_IMPLEMENTATION \
75 pthread_cond_t posix_cond;
76
77 #define OMNI_SEMAPHORE_IMPLEMENTATION \
78 omni_mutex m; \
79 omni_condition c; \
80 int value;
81
82 #define OMNI_THREAD_IMPLEMENTATION \
83 pthread_t posix_thread; \
84 static int posix_priority(priority_t); \
85 friend void* omni_thread_wrapper(void* ptr);
86
87 #endif
syntax highlighted by Code2HTML, v. 0.9.1