dominance.c (calc_dfs_tree_nonrec): Reverse order of tests in if statement so we...
[official-gcc.git] / libjava / include / win32-threads.h
bloba6466322f8a5c66f029fc6f36099fd8b9b296de5
1 // -*- c++ -*-
2 // win32-threads.h - Defines for using Win32 threads.
4 /* Copyright (C) 1998, 1999, 2000 Free Software Foundation
6 This file is part of libgcj.
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
10 details. */
12 #ifndef __JV_WIN32_THREADS__
13 #define __JV_WIN32_THREADS__
15 #include <windows.h>
18 // Typedefs.
21 typedef HANDLE _Jv_ConditionVariable_t;
22 typedef HANDLE _Jv_Mutex_t;
24 typedef struct
26 int flags; // Flags are defined in implementation.
27 HANDLE handle; // Actual handle to the thread
28 java::lang::Thread *thread_obj;
29 } _Jv_Thread_t;
31 typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
34 // Condition variables.
37 inline void
38 _Jv_CondInit (_Jv_ConditionVariable_t *cv)
40 *cv = CreateEvent (NULL, 0, 0, NULL);
43 #define _Jv_HaveCondDestroy
45 inline void
46 _Jv_CondDestroy (_Jv_ConditionVariable_t *cv)
48 CloseHandle (*cv);
49 cv = NULL;
52 int _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
53 jlong millis, jint nanos);
55 inline int
56 _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *)
58 // FIXME: check for mutex ownership?
59 return PulseEvent (*cv) ? 0 : _JV_NOT_OWNER; // FIXME?
62 inline int
63 _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *)
65 // FIXME: check for mutex ownership?
66 return PulseEvent (*cv) ? 0 : _JV_NOT_OWNER; // FIXME?
70 // Mutexes.
73 inline void
74 _Jv_MutexInit (_Jv_Mutex_t *mu)
76 *mu = CreateMutex (NULL, 0, NULL);
79 #define _Jv_HaveMutexDestroy
81 inline void
82 _Jv_MutexDestroy (_Jv_Mutex_t *mu)
84 CloseHandle (*mu);
85 mu = NULL;
88 int _Jv_MutexLock (_Jv_Mutex_t *mu);
90 inline int
91 _Jv_MutexUnlock (_Jv_Mutex_t *mu)
93 return ReleaseMutex(*mu) ? 0 : GetLastError(); // FIXME: Map error code?
97 // Thread creation and manipulation.
100 void _Jv_InitThreads (void);
101 _Jv_Thread_t *_Jv_ThreadInitData (java::lang::Thread *thread);
102 void _Jv_ThreadDestroyData (_Jv_Thread_t *data);
104 inline java::lang::Thread *
105 _Jv_ThreadCurrent (void)
107 extern DWORD _Jv_ThreadKey;
108 return (java::lang::Thread *) TlsGetValue(_Jv_ThreadKey);
111 inline _Jv_Thread_t *
112 _Jv_ThreadCurrentData (void)
114 extern DWORD _Jv_ThreadDataKey;
115 return (_Jv_Thread_t *) TlsGetValue(_Jv_ThreadDataKey);
118 inline void
119 _Jv_ThreadYield (void)
121 Sleep (0);
124 void _Jv_ThreadRegister (_Jv_Thread_t *data);
125 void _Jv_ThreadUnRegister ();
127 void _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio);
128 void _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
129 _Jv_ThreadStartFunc *meth);
130 void _Jv_ThreadWait (void);
131 void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
133 // Remove defines from <windows.h> that conflict with various things in libgcj code
135 #undef TRUE
136 #undef FALSE
137 #undef MAX_PRIORITY
138 #undef MIN_PRIORITY
139 #undef min
140 #undef max
141 #undef interface
142 #undef STRICT
143 #undef VOID
145 #endif /* __JV_WIN32_THREADS__ */