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
28 java::lang::Thread
*thread_obj
;
31 typedef void _Jv_ThreadStartFunc (java::lang::Thread
*);
34 // Condition variables.
38 _Jv_CondInit (_Jv_ConditionVariable_t
*cv
)
40 *cv
= CreateEvent (NULL
, 0, 0, NULL
);
43 #define _Jv_HaveCondDestroy
46 _Jv_CondDestroy (_Jv_ConditionVariable_t
*cv
)
52 int _Jv_CondWait (_Jv_ConditionVariable_t
*cv
, _Jv_Mutex_t
*mu
,
53 jlong millis
, jint nanos
);
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?
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?
74 _Jv_MutexInit (_Jv_Mutex_t
*mu
)
76 *mu
= CreateMutex (NULL
, 0, NULL
);
79 #define _Jv_HaveMutexDestroy
82 _Jv_MutexDestroy (_Jv_Mutex_t
*mu
)
88 int _Jv_MutexLock (_Jv_Mutex_t
*mu
);
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
);
119 _Jv_ThreadYield (void)
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
145 #endif /* __JV_WIN32_THREADS__ */