2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / include / no-threads.h
blob793cfadbf1bc3a39cd80c06a91b014dd88ec5867
1 // -*- c++ -*-
2 // no-threads.h - Defines for using no threads.
4 /* Copyright (C) 1998, 1999 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_NO_THREADS__
13 #define __JV_NO_THREADS__
15 #include "config.h"
17 #include <stdlib.h>
18 #ifdef HAVE_UNISTD_H
19 #include <unistd.h>
20 #endif
23 // Typedefs.
26 typedef int _Jv_ConditionVariable_t;
27 typedef int _Jv_Mutex_t;
28 typedef int _Jv_Thread_t;
29 typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
33 // Condition variables.
36 inline void
37 _Jv_CondInit (_Jv_ConditionVariable_t *)
41 // Waiting is ok provided there is a timeout. Otherwise we will just
42 // wait forever.
43 inline int
44 _Jv_CondWait (_Jv_ConditionVariable_t *, _Jv_Mutex_t *,
45 jlong millis, jint nanos)
47 if (millis == 0 && nanos == 0)
48 JvFail ("_Jv_CondWait without timeout");
50 #ifdef HAVE_SLEEP
51 int seconds = millis / 1000;
52 if (seconds > 0)
53 sleep (seconds);
54 #endif
56 return 0;
59 inline int
60 _Jv_CondNotify (_Jv_ConditionVariable_t *, _Jv_Mutex_t *)
62 // It is ok to notify -- it just has no effect.
63 return 0;
66 inline int
67 _Jv_CondNotifyAll (_Jv_ConditionVariable_t *, _Jv_Mutex_t *)
69 // It is ok to notify -- it just has no effect.
70 return 0;
75 // Mutexes.
78 inline int _Jv_MutexCheckMonitor (_Jv_Mutex_t *mu)
80 return 0;
83 inline void
84 _Jv_MutexInit (_Jv_Mutex_t *)
88 inline int
89 _Jv_MutexLock (_Jv_Mutex_t *)
91 return 0;
94 inline int
95 _Jv_MutexUnlock (_Jv_Mutex_t *)
97 return 0;
102 // Thread creation and manipulation.
105 inline void
106 _Jv_InitThreads (void)
110 _Jv_Thread_t *
111 _Jv_ThreadInitData (java::lang::Thread *);
113 inline void
114 _Jv_ThreadDestroyData (_Jv_Thread_t *data)
118 inline java::lang::Thread *
119 _Jv_ThreadCurrent (void)
121 extern java::lang::Thread *_Jv_OnlyThread;
122 return _Jv_OnlyThread;
125 inline void
126 _Jv_ThreadYield (void)
130 inline void
131 _Jv_ThreadSetPriority (_Jv_Thread_t *, jint)
135 inline void
136 _Jv_ThreadRegister (_Jv_Thread_t *data)
140 inline void
141 _Jv_ThreadUnRegister (void)
145 void _Jv_ThreadStart (java::lang::Thread *, _Jv_Thread_t *,
146 _Jv_ThreadStartFunc *meth);
148 inline void
149 _Jv_ThreadWait (void)
153 inline void
154 _Jv_ThreadInterrupt (_Jv_Thread_t *)
158 #endif /* __JV_NO_THREADS__ */