source: vendor/gcc/3.2.2/libjava/include/win32-threads.h

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1// -*- c++ -*-
2// win32-threads.h - Defines for using Win32 threads.
3
4/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
5
6 This file is part of libgcj.
7
8This software is copyrighted work licensed under the terms of the
9Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
10details. */
11
12#ifndef __JV_WIN32_THREADS__
13#define __JV_WIN32_THREADS__
14
15#include <windows.h>
16
17//
18// Typedefs.
19//
20
21typedef struct _Jv_ConditionVariable_t {
22 HANDLE ev[2];
23 CRITICAL_SECTION count_mutex;
24 int blocked_count;
25};
26
27typedef CRITICAL_SECTION _Jv_Mutex_t;
28
29typedef struct
30{
31 int flags; // Flags are defined in implementation.
32 HANDLE handle; // Actual handle to the thread
33 java::lang::Thread *thread_obj;
34} _Jv_Thread_t;
35
36typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
37
38//
39// Condition variables.
40//
41
42int _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint nanos);
43void _Jv_CondInit (_Jv_ConditionVariable_t *cv);
44void _Jv_CondDestroy (_Jv_ConditionVariable_t *cv);
45int _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *);
46int _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *);
47
48//
49// Mutexes.
50// We use CRITICAL_SECTIONs instead of CreateMutex() for better performance
51//
52
53inline void _Jv_MutexInit (_Jv_Mutex_t *mu)
54{
55 InitializeCriticalSection(mu);
56}
57
58#define _Jv_HaveMutexDestroy
59inline void _Jv_MutexDestroy (_Jv_Mutex_t *mu)
60{
61 DeleteCriticalSection(mu);
62 mu = NULL;
63}
64
65inline int _Jv_MutexUnlock (_Jv_Mutex_t *mu)
66{
67 LeaveCriticalSection(mu);
68 return 0;
69}
70
71inline int _Jv_MutexLock (_Jv_Mutex_t *mu)
72{
73 EnterCriticalSection(mu);
74 return 0;
75}
76
77//
78// Thread creation and manipulation.
79//
80
81void _Jv_InitThreads (void);
82_Jv_Thread_t *_Jv_ThreadInitData (java::lang::Thread *thread);
83void _Jv_ThreadDestroyData (_Jv_Thread_t *data);
84
85inline java::lang::Thread* _Jv_ThreadCurrent (void)
86{
87 extern DWORD _Jv_ThreadKey;
88 return (java::lang::Thread *) TlsGetValue(_Jv_ThreadKey);
89}
90
91inline _Jv_Thread_t *_Jv_ThreadCurrentData(void)
92{
93 extern DWORD _Jv_ThreadDataKey;
94 return (_Jv_Thread_t *) TlsGetValue(_Jv_ThreadDataKey);
95}
96
97inline void _Jv_ThreadYield (void)
98{
99 // FIXME: win98 freezes hard (OS hang) when we use this --
100 // for now, we simply don't yield
101 // Sleep (0);
102}
103
104void _Jv_ThreadRegister (_Jv_Thread_t *data);
105void _Jv_ThreadUnRegister ();
106
107void _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio);
108void _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
109 _Jv_ThreadStartFunc *meth);
110void _Jv_ThreadWait (void);
111void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
112
113// Remove defines from <windows.h> that conflict with various things in libgcj code
114
115#undef TRUE
116#undef FALSE
117#undef MAX_PRIORITY
118#undef MIN_PRIORITY
119#undef min
120#undef max
121#undef interface
122#undef STRICT
123#undef VOID
124
125#endif /* __JV_WIN32_THREADS__ */
Note: See TracBrowser for help on using the repository browser.