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
12 #ifndef __JV_WIN32_THREADS__
13 #define __JV_WIN32_THREADS__
21 typedef HANDLE _Jv_ConditionVariable_t
;
22 typedef HANDLE _Jv_Mutex_t
;
26 int flags
; // Flags are defined in implementation.
27 HANDLE handle
; // Actual handle to the thread
30 typedef void _Jv_ThreadStartFunc (java::lang::Thread
*);
33 // Condition variables.
37 _Jv_CondInit (_Jv_ConditionVariable_t
*cv
)
39 *cv
= CreateEvent (NULL
, 0, 0, NULL
);
42 #define _Jv_HaveCondDestroy
45 _Jv_CondDestroy (_Jv_ConditionVariable_t
*cv
)
51 int _Jv_CondWait (_Jv_ConditionVariable_t
*cv
, _Jv_Mutex_t
*mu
,
52 jlong millis
, jint nanos
);
55 _Jv_CondNotify (_Jv_ConditionVariable_t
*cv
, _Jv_Mutex_t
*)
57 return PulseEvent (*cv
) ? 0 : GetLastError (); // FIXME: Map error code?
61 _Jv_CondNotifyAll (_Jv_ConditionVariable_t
*cv
, _Jv_Mutex_t
*)
63 return PulseEvent (*cv
) ? 0 : GetLastError (); // FIXME: Map error code?
71 _Jv_MutexInit (_Jv_Mutex_t
*mu
)
73 *mu
= CreateMutex (NULL
, 0, NULL
);
76 #define _Jv_HaveMutexDestroy
79 _Jv_MutexDestroy (_Jv_Mutex_t
*mu
)
85 int _Jv_MutexLock (_Jv_Mutex_t
*mu
);
88 _Jv_MutexUnlock (_Jv_Mutex_t
*mu
)
90 return ReleaseMutex(*mu
) ? 0 : GetLastError(); // FIXME: Map error code?
94 // Thread creation and manipulation.
97 void _Jv_InitThreads (void);
98 void _Jv_ThreadInitData (_Jv_Thread_t
**data
, java::lang::Thread
*thread
);
100 inline java::lang::Thread
*
101 _Jv_ThreadCurrent (void)
103 extern DWORD _Jv_ThreadKey
;
104 return (java::lang::Thread
*) TlsGetValue(_Jv_ThreadKey
);
107 inline _Jv_Thread_t
*
108 _Jv_ThreadCurrentData (void)
110 extern DWORD _Jv_ThreadDataKey
;
111 return (_Jv_Thread_t
*) TlsGetValue(_Jv_ThreadDataKey
);
115 _Jv_ThreadYield (void)
120 void _Jv_ThreadSetPriority (_Jv_Thread_t
*data
, jint prio
);
121 void _Jv_ThreadStart (java::lang::Thread
*thread
, _Jv_Thread_t
*data
,
122 _Jv_ThreadStartFunc
*meth
);
123 void _Jv_ThreadWait (void);
124 void _Jv_ThreadInterrupt (_Jv_Thread_t
*data
);
126 // Remove defines from <windows.h> that conflict with various things in libgcj code
138 #endif /* __JV_WIN32_THREADS__ */