bh_thread.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "bh_thread.h"
  17. #include "bh_assert.h"
  18. #include "bh_memory.h"
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <sys/time.h>
  22. int _vm_thread_sys_init()
  23. {
  24. return 0;
  25. }
  26. void vm_thread_sys_destroy(void)
  27. {
  28. }
  29. int _vm_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
  30. void *arg, unsigned int stack_size, int prio)
  31. {
  32. return BHT_ERROR;
  33. // return BHT_OK;
  34. }
  35. int _vm_thread_create(korp_tid *tid, thread_start_routine_t start, void *arg,
  36. unsigned int stack_size)
  37. {
  38. return _vm_thread_create_with_prio(tid, start, arg, stack_size,
  39. BH_THREAD_DEFAULT_PRIORITY);
  40. }
  41. korp_tid _vm_self_thread()
  42. {
  43. return 0;
  44. }
  45. void vm_thread_exit(void * code)
  46. {
  47. }
  48. // storage for one thread
  49. static void *_tls_store = NULL;
  50. void *_vm_tls_get(unsigned idx)
  51. {
  52. return _tls_store;
  53. }
  54. int _vm_tls_put(unsigned idx, void * tls)
  55. {
  56. _tls_store = tls;
  57. return BHT_OK;
  58. //return BHT_ERROR;
  59. }
  60. int _vm_mutex_init(korp_mutex *mutex)
  61. {
  62. return BHT_OK;
  63. //return BHT_ERROR;
  64. }
  65. int _vm_recursive_mutex_init(korp_mutex *mutex)
  66. {
  67. return BHT_OK;
  68. //return BHT_ERROR;
  69. }
  70. int _vm_mutex_destroy(korp_mutex *mutex)
  71. {
  72. return BHT_OK;
  73. //return BHT_ERROR;
  74. }
  75. /* Returned error (EINVAL, EAGAIN and EDEADLK) from
  76. locking the mutex indicates some logic error present in
  77. the program somewhere.
  78. Don't try to recover error for an existing unknown error.*/
  79. void vm_mutex_lock(korp_mutex *mutex)
  80. {
  81. }
  82. int vm_mutex_trylock(korp_mutex *mutex)
  83. {
  84. return BHT_OK;
  85. //return BHT_ERROR;
  86. }
  87. /* Returned error (EINVAL, EAGAIN and EPERM) from
  88. unlocking the mutex indicates some logic error present
  89. in the program somewhere.
  90. Don't try to recover error for an existing unknown error.*/
  91. void vm_mutex_unlock(korp_mutex *mutex)
  92. {
  93. }
  94. int _vm_sem_init(korp_sem* sem, unsigned int c)
  95. {
  96. return BHT_OK;
  97. //return BHT_ERROR;
  98. }
  99. int _vm_sem_destroy(korp_sem *sem)
  100. {
  101. return BHT_OK;
  102. //return BHT_ERROR;
  103. }
  104. int _vm_sem_wait(korp_sem *sem)
  105. {
  106. return BHT_OK;
  107. //return BHT_ERROR;
  108. }
  109. int _vm_sem_reltimedwait(korp_sem *sem, int mills)
  110. {
  111. return BHT_OK;
  112. //return BHT_ERROR;
  113. }
  114. int _vm_sem_post(korp_sem *sem)
  115. {
  116. return BHT_OK;
  117. //return BHT_ERROR;
  118. }
  119. int _vm_cond_init(korp_cond *cond)
  120. {
  121. return BHT_OK;
  122. //return BHT_ERROR;
  123. }
  124. int _vm_cond_destroy(korp_cond *cond)
  125. {
  126. return BHT_OK;
  127. //return BHT_ERROR;
  128. }
  129. int _vm_cond_wait(korp_cond *cond, korp_mutex *mutex)
  130. {
  131. return BHT_OK;
  132. //return BHT_ERROR;
  133. }
  134. int _vm_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, int mills)
  135. {
  136. return BHT_OK;
  137. //return BHT_ERROR;
  138. }
  139. int _vm_cond_signal(korp_cond *cond)
  140. {
  141. return BHT_OK;
  142. //return BHT_ERROR;
  143. }
  144. int _vm_cond_broadcast(korp_cond *cond)
  145. {
  146. return BHT_OK;
  147. //return BHT_ERROR;
  148. }
  149. int _vm_thread_cancel(korp_tid thread)
  150. {
  151. return 0;
  152. }
  153. int _vm_thread_join(korp_tid thread, void **value_ptr, int mills)
  154. {
  155. return 0;
  156. }
  157. int _vm_thread_detach(korp_tid thread)
  158. {
  159. return 0;
  160. }