* c-common.h (genrtl_clear_out_block): Remove.
[official-gcc.git] / libjava / include / win32-threads.h
blob4938d5faf57a19d15f9ce02db0c5f53848736207
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 } _Jv_Thread_t;
30 typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
33 // Condition variables.
36 inline void
37 _Jv_CondInit (_Jv_ConditionVariable_t *cv)
39 *cv = CreateEvent (NULL, 0, 0, NULL);
42 #define _Jv_HaveCondDestroy
44 inline void
45 _Jv_CondDestroy (_Jv_ConditionVariable_t *cv)
47 CloseHandle (*cv);
48 cv = NULL;
51 int _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
52 jlong millis, jint nanos);
54 inline int
55 _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *)
57 // FIXME: check for mutex ownership?
58 return PulseEvent (*cv) ? 0 : _JV_NOT_OWNER; // FIXME?
61 inline int
62 _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *)
64 // FIXME: check for mutex ownership?
65 return PulseEvent (*cv) ? 0 : _JV_NOT_OWNER; // FIXME?
69 // Mutexes.
72 inline void
73 _Jv_MutexInit (_Jv_Mutex_t *mu)
75 *mu = CreateMutex (NULL, 0, NULL);
78 #define _Jv_HaveMutexDestroy
80 inline void
81 _Jv_MutexDestroy (_Jv_Mutex_t *mu)
83 CloseHandle (*mu);
84 mu = NULL;
87 int _Jv_MutexLock (_Jv_Mutex_t *mu);
89 inline int
90 _Jv_MutexUnlock (_Jv_Mutex_t *mu)
92 return ReleaseMutex(*mu) ? 0 : GetLastError(); // FIXME: Map error code?
96 // Thread creation and manipulation.
99 void _Jv_InitThreads (void);
100 void _Jv_ThreadInitData (_Jv_Thread_t **data, java::lang::Thread *thread);
102 inline java::lang::Thread *
103 _Jv_ThreadCurrent (void)
105 extern DWORD _Jv_ThreadKey;
106 return (java::lang::Thread *) TlsGetValue(_Jv_ThreadKey);
109 inline _Jv_Thread_t *
110 _Jv_ThreadCurrentData (void)
112 extern DWORD _Jv_ThreadDataKey;
113 return (_Jv_Thread_t *) TlsGetValue(_Jv_ThreadDataKey);
116 inline void
117 _Jv_ThreadYield (void)
119 Sleep (0);
122 void _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio);
123 void _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
124 _Jv_ThreadStartFunc *meth);
125 void _Jv_ThreadWait (void);
126 void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
128 // Remove defines from <windows.h> that conflict with various things in libgcj code
130 #undef TRUE
131 #undef FALSE
132 #undef MAX_PRIORITY
133 #undef MIN_PRIORITY
134 #undef min
135 #undef max
136 #undef interface
137 #undef STRICT
138 #undef VOID
140 #endif /* __JV_WIN32_THREADS__ */