]>
Commit | Line | Data |
---|---|---|
ee9dd372 TT |
1 | // -*- c++ -*- |
2 | // no-threads.h - Defines for using no threads. | |
3 | ||
006d133d | 4 | /* Copyright (C) 1998, 1999, 2004, 2006 Free Software Foundation |
ee9dd372 TT |
5 | |
6 | This file is part of libgcj. | |
7 | ||
8 | This software is copyrighted work licensed under the terms of the | |
9 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for | |
10 | details. */ | |
11 | ||
12 | #ifndef __JV_NO_THREADS__ | |
13 | #define __JV_NO_THREADS__ | |
14 | ||
15 | #include "config.h" | |
16 | ||
17 | #include <stdlib.h> | |
18 | #ifdef HAVE_UNISTD_H | |
19 | #include <unistd.h> | |
20 | #endif | |
21 | ||
22 | // | |
23 | // Typedefs. | |
24 | // | |
25 | ||
26 | typedef int _Jv_ConditionVariable_t; | |
27 | typedef int _Jv_Mutex_t; | |
ee9dd372 TT |
28 | typedef void _Jv_ThreadStartFunc (java::lang::Thread *); |
29 | ||
006d133d AT |
30 | // |
31 | // Declarations | |
32 | // | |
33 | ||
34 | class _Jv_Thread_t { }; | |
ee9dd372 TT |
35 | |
36 | // | |
37 | // Condition variables. | |
38 | // | |
39 | ||
40 | inline void | |
41 | _Jv_CondInit (_Jv_ConditionVariable_t *) | |
42 | { | |
43 | } | |
44 | ||
45 | // Waiting is ok provided there is a timeout. Otherwise we will just | |
46 | // wait forever. | |
47 | inline int | |
48 | _Jv_CondWait (_Jv_ConditionVariable_t *, _Jv_Mutex_t *, | |
49 | jlong millis, jint nanos) | |
50 | { | |
51 | if (millis == 0 && nanos == 0) | |
52 | JvFail ("_Jv_CondWait without timeout"); | |
53 | ||
54 | #ifdef HAVE_SLEEP | |
55 | int seconds = millis / 1000; | |
56 | if (seconds > 0) | |
57 | sleep (seconds); | |
58 | #endif | |
59 | ||
60 | return 0; | |
61 | } | |
62 | ||
63 | inline int | |
64 | _Jv_CondNotify (_Jv_ConditionVariable_t *, _Jv_Mutex_t *) | |
65 | { | |
66 | // It is ok to notify -- it just has no effect. | |
67 | return 0; | |
68 | } | |
69 | ||
70 | inline int | |
71 | _Jv_CondNotifyAll (_Jv_ConditionVariable_t *, _Jv_Mutex_t *) | |
72 | { | |
73 | // It is ok to notify -- it just has no effect. | |
74 | return 0; | |
75 | } | |
76 | ||
77 | ||
78 | // | |
79 | // Mutexes. | |
80 | // | |
81 | ||
7edc2bad | 82 | inline int _Jv_MutexCheckMonitor (_Jv_Mutex_t *) |
16a10fb6 JQ |
83 | { |
84 | return 0; | |
85 | } | |
86 | ||
ee9dd372 TT |
87 | inline void |
88 | _Jv_MutexInit (_Jv_Mutex_t *) | |
89 | { | |
90 | } | |
91 | ||
92 | inline int | |
93 | _Jv_MutexLock (_Jv_Mutex_t *) | |
94 | { | |
95 | return 0; | |
96 | } | |
97 | ||
98 | inline int | |
99 | _Jv_MutexUnlock (_Jv_Mutex_t *) | |
100 | { | |
101 | return 0; | |
102 | } | |
103 | ||
104 | ||
105 | // | |
106 | // Thread creation and manipulation. | |
107 | // | |
108 | ||
109 | inline void | |
110 | _Jv_InitThreads (void) | |
111 | { | |
112 | } | |
113 | ||
c93d7fae PB |
114 | _Jv_Thread_t * |
115 | _Jv_ThreadInitData (java::lang::Thread *); | |
e301621d | 116 | |
ee9dd372 | 117 | inline void |
7edc2bad | 118 | _Jv_ThreadDestroyData (_Jv_Thread_t *) |
ee9dd372 | 119 | { |
ee9dd372 TT |
120 | } |
121 | ||
122 | inline java::lang::Thread * | |
123 | _Jv_ThreadCurrent (void) | |
124 | { | |
125 | extern java::lang::Thread *_Jv_OnlyThread; | |
126 | return _Jv_OnlyThread; | |
127 | } | |
128 | ||
129 | inline void | |
130 | _Jv_ThreadYield (void) | |
131 | { | |
132 | } | |
133 | ||
134 | inline void | |
135 | _Jv_ThreadSetPriority (_Jv_Thread_t *, jint) | |
136 | { | |
137 | } | |
138 | ||
c93d7fae | 139 | inline void |
7edc2bad | 140 | _Jv_ThreadRegister (_Jv_Thread_t *) |
c93d7fae PB |
141 | { |
142 | } | |
143 | ||
144 | inline void | |
145 | _Jv_ThreadUnRegister (void) | |
146 | { | |
147 | } | |
148 | ||
ee9dd372 TT |
149 | void _Jv_ThreadStart (java::lang::Thread *, _Jv_Thread_t *, |
150 | _Jv_ThreadStartFunc *meth); | |
151 | ||
152 | inline void | |
153 | _Jv_ThreadWait (void) | |
154 | { | |
155 | } | |
156 | ||
157 | inline void | |
158 | _Jv_ThreadInterrupt (_Jv_Thread_t *) | |
159 | { | |
160 | } | |
161 | ||
162 | #endif /* __JV_NO_THREADS__ */ |