| 1 | // -*- c++ -*- | 
|---|
| 2 | // no-threads.h - Defines for using no threads. | 
|---|
| 3 |  | 
|---|
| 4 | /* Copyright (C) 1998, 1999  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 int _Jv_Thread_t; | 
|---|
| 29 | typedef void _Jv_ThreadStartFunc (java::lang::Thread *); | 
|---|
| 30 |  | 
|---|
| 31 |  | 
|---|
| 32 | // | 
|---|
| 33 | // Condition variables. | 
|---|
| 34 | // | 
|---|
| 35 |  | 
|---|
| 36 | inline void | 
|---|
| 37 | _Jv_CondInit (_Jv_ConditionVariable_t *) | 
|---|
| 38 | { | 
|---|
| 39 | } | 
|---|
| 40 |  | 
|---|
| 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) | 
|---|
| 46 | { | 
|---|
| 47 | if (millis == 0 && nanos == 0) | 
|---|
| 48 | JvFail ("_Jv_CondWait without timeout"); | 
|---|
| 49 |  | 
|---|
| 50 | #ifdef HAVE_SLEEP | 
|---|
| 51 | int seconds = millis / 1000; | 
|---|
| 52 | if (seconds > 0) | 
|---|
| 53 | sleep (seconds); | 
|---|
| 54 | #endif | 
|---|
| 55 |  | 
|---|
| 56 | return 0; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | inline int | 
|---|
| 60 | _Jv_CondNotify (_Jv_ConditionVariable_t *, _Jv_Mutex_t *) | 
|---|
| 61 | { | 
|---|
| 62 | // It is ok to notify -- it just has no effect. | 
|---|
| 63 | return 0; | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | inline int | 
|---|
| 67 | _Jv_CondNotifyAll (_Jv_ConditionVariable_t *, _Jv_Mutex_t *) | 
|---|
| 68 | { | 
|---|
| 69 | // It is ok to notify -- it just has no effect. | 
|---|
| 70 | return 0; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 |  | 
|---|
| 74 | // | 
|---|
| 75 | // Mutexes. | 
|---|
| 76 | // | 
|---|
| 77 |  | 
|---|
| 78 | inline void | 
|---|
| 79 | _Jv_MutexInit (_Jv_Mutex_t *) | 
|---|
| 80 | { | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | inline int | 
|---|
| 84 | _Jv_MutexLock (_Jv_Mutex_t *) | 
|---|
| 85 | { | 
|---|
| 86 | return 0; | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 | inline int | 
|---|
| 90 | _Jv_MutexUnlock (_Jv_Mutex_t *) | 
|---|
| 91 | { | 
|---|
| 92 | return 0; | 
|---|
| 93 | } | 
|---|
| 94 |  | 
|---|
| 95 |  | 
|---|
| 96 | // | 
|---|
| 97 | // Thread creation and manipulation. | 
|---|
| 98 | // | 
|---|
| 99 |  | 
|---|
| 100 | inline void | 
|---|
| 101 | _Jv_InitThreads (void) | 
|---|
| 102 | { | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 | _Jv_Thread_t * | 
|---|
| 106 | _Jv_ThreadInitData (java::lang::Thread *); | 
|---|
| 107 |  | 
|---|
| 108 | inline void | 
|---|
| 109 | _Jv_ThreadDestroyData (_Jv_Thread_t *data) | 
|---|
| 110 | { | 
|---|
| 111 | } | 
|---|
| 112 |  | 
|---|
| 113 | inline java::lang::Thread * | 
|---|
| 114 | _Jv_ThreadCurrent (void) | 
|---|
| 115 | { | 
|---|
| 116 | extern java::lang::Thread *_Jv_OnlyThread; | 
|---|
| 117 | return _Jv_OnlyThread; | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | inline void | 
|---|
| 121 | _Jv_ThreadYield (void) | 
|---|
| 122 | { | 
|---|
| 123 | } | 
|---|
| 124 |  | 
|---|
| 125 | inline void | 
|---|
| 126 | _Jv_ThreadSetPriority (_Jv_Thread_t *, jint) | 
|---|
| 127 | { | 
|---|
| 128 | } | 
|---|
| 129 |  | 
|---|
| 130 | inline void | 
|---|
| 131 | _Jv_ThreadRegister (_Jv_Thread_t *data) | 
|---|
| 132 | { | 
|---|
| 133 | } | 
|---|
| 134 |  | 
|---|
| 135 | inline void | 
|---|
| 136 | _Jv_ThreadUnRegister (void) | 
|---|
| 137 | { | 
|---|
| 138 | } | 
|---|
| 139 |  | 
|---|
| 140 | void _Jv_ThreadStart (java::lang::Thread *, _Jv_Thread_t *, | 
|---|
| 141 | _Jv_ThreadStartFunc *meth); | 
|---|
| 142 |  | 
|---|
| 143 | inline void | 
|---|
| 144 | _Jv_ThreadWait (void) | 
|---|
| 145 | { | 
|---|
| 146 | } | 
|---|
| 147 |  | 
|---|
| 148 | inline void | 
|---|
| 149 | _Jv_ThreadInterrupt (_Jv_Thread_t *) | 
|---|
| 150 | { | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 | #endif /* __JV_NO_THREADS__ */ | 
|---|