comment/style fixes
[official-gcc.git] / libjava / include / no-threads.h
bloba598df3e87a88b5fd655cda861a4f0da5d854cf4
1 // -*- c++ -*-
2 // no-threads.h - Defines for using no threads.
4 /* Copyright (C) 1998, 1999, 2004, 2006 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 void _Jv_ThreadStartFunc (java::lang::Thread *);
31 // Declarations
34 class _Jv_Thread_t { };
37 // Condition variables.
40 inline void
41 _Jv_CondInit (_Jv_ConditionVariable_t *)
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)
51 if (millis == 0 && nanos == 0)
52 JvFail ("_Jv_CondWait without timeout");
54 #ifdef HAVE_SLEEP
55 int seconds = millis / 1000;
56 if (seconds > 0)
57 sleep (seconds);
58 #endif
60 return 0;
63 inline int
64 _Jv_CondNotify (_Jv_ConditionVariable_t *, _Jv_Mutex_t *)
66 // It is ok to notify -- it just has no effect.
67 return 0;
70 inline int
71 _Jv_CondNotifyAll (_Jv_ConditionVariable_t *, _Jv_Mutex_t *)
73 // It is ok to notify -- it just has no effect.
74 return 0;
79 // Mutexes.
82 inline int _Jv_MutexCheckMonitor (_Jv_Mutex_t *)
84 return 0;
87 inline void
88 _Jv_MutexInit (_Jv_Mutex_t *)
92 inline int
93 _Jv_MutexLock (_Jv_Mutex_t *)
95 return 0;
98 inline int
99 _Jv_MutexUnlock (_Jv_Mutex_t *)
101 return 0;
106 // Thread creation and manipulation.
109 inline void
110 _Jv_InitThreads (void)
114 _Jv_Thread_t *
115 _Jv_ThreadInitData (java::lang::Thread *);
117 inline void
118 _Jv_ThreadDestroyData (_Jv_Thread_t *)
122 inline java::lang::Thread *
123 _Jv_ThreadCurrent (void)
125 extern java::lang::Thread *_Jv_OnlyThread;
126 return _Jv_OnlyThread;
129 inline void
130 _Jv_ThreadYield (void)
134 inline void
135 _Jv_ThreadSetPriority (_Jv_Thread_t *, jint)
139 inline void
140 _Jv_ThreadRegister (_Jv_Thread_t *)
144 inline void
145 _Jv_ThreadUnRegister (void)
149 void _Jv_ThreadStart (java::lang::Thread *, _Jv_Thread_t *,
150 _Jv_ThreadStartFunc *meth);
152 inline void
153 _Jv_ThreadWait (void)
157 inline void
158 _Jv_ThreadInterrupt (_Jv_Thread_t *)
162 #endif /* __JV_NO_THREADS__ */