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 struct _Jv_ConditionVariable_t {
23 CRITICAL_SECTION count_mutex;
27 typedef CRITICAL_SECTION _Jv_Mutex_t;
31 int flags; // Flags are defined in implementation.
32 HANDLE handle; // Actual handle to the thread
33 java::lang::Thread *thread_obj;
36 typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
39 // Condition variables.
42 int _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint nanos);
43 void _Jv_CondInit (_Jv_ConditionVariable_t *cv);
44 void _Jv_CondDestroy (_Jv_ConditionVariable_t *cv);
45 int _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *);
46 int _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *);
50 // We use CRITICAL_SECTIONs instead of CreateMutex() for better performance
53 inline void _Jv_MutexInit (_Jv_Mutex_t *mu)
55 InitializeCriticalSection(mu);
58 #define _Jv_HaveMutexDestroy
59 inline void _Jv_MutexDestroy (_Jv_Mutex_t *mu)
61 DeleteCriticalSection(mu);
65 inline int _Jv_MutexUnlock (_Jv_Mutex_t *mu)
67 LeaveCriticalSection(mu);
71 inline int _Jv_MutexLock (_Jv_Mutex_t *mu)
73 EnterCriticalSection(mu);
78 // Thread creation and manipulation.
81 void _Jv_InitThreads (void);
82 _Jv_Thread_t *_Jv_ThreadInitData (java::lang::Thread *thread);
83 void _Jv_ThreadDestroyData (_Jv_Thread_t *data);
85 inline java::lang::Thread* _Jv_ThreadCurrent (void)
87 extern DWORD _Jv_ThreadKey;
88 return (java::lang::Thread *) TlsGetValue(_Jv_ThreadKey);
91 inline _Jv_Thread_t *_Jv_ThreadCurrentData(void)
93 extern DWORD _Jv_ThreadDataKey;
94 return (_Jv_Thread_t *) TlsGetValue(_Jv_ThreadDataKey);
97 inline void _Jv_ThreadYield (void)
99 // FIXME: win98 freezes hard (OS hang) when we use this --
100 // for now, we simply don't yield
104 void _Jv_ThreadRegister (_Jv_Thread_t *data);
105 void _Jv_ThreadUnRegister ();
107 void _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio);
108 void _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
109 _Jv_ThreadStartFunc *meth);
110 void _Jv_ThreadWait (void);
111 void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
113 // Remove defines from <windows.h> that conflict with various things in libgcj code
125 #endif /* __JV_WIN32_THREADS__ */