no-threads.h 2.3 KB

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