OSDN Git Service

2011-10-30 Dmitry Plotnikov <dplotnikov@ispras.ru>
[pf3gnuchains/gcc-fork.git] / libjava / include / no-threads.h
1 // -*- c++ -*-
2 // no-threads.h - Defines for using no threads.
3
4 /* Copyright (C) 1998, 1999, 2004, 2006  Free Software Foundation
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;
28 typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
29
30 //
31 // Declarations
32 //
33
34 class _Jv_Thread_t { };
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
82 inline int _Jv_MutexCheckMonitor (_Jv_Mutex_t *)
83 {
84   return 0;
85 }
86
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
114 _Jv_Thread_t *
115 _Jv_ThreadInitData (java::lang::Thread *);
116
117 inline void
118 _Jv_ThreadDestroyData (_Jv_Thread_t *)
119 {
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
139 inline void
140 _Jv_ThreadRegister (_Jv_Thread_t *)
141 {
142 }
143
144 inline void
145 _Jv_ThreadUnRegister (void)
146 {
147 }
148
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__ */