sgx_thread.c 977 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "platform_api_vmcore.h"
  6. #include "platform_api_extension.h"
  7. korp_tid os_self_thread()
  8. {
  9. return sgx_thread_self();
  10. }
  11. int os_mutex_init(korp_mutex *mutex)
  12. {
  13. sgx_thread_mutex_t m = SGX_THREAD_MUTEX_INITIALIZER;
  14. *mutex = m;
  15. return BHT_OK;
  16. }
  17. int os_mutex_destroy(korp_mutex *mutex)
  18. {
  19. sgx_thread_mutex_destroy(mutex);
  20. return BHT_OK;
  21. }
  22. void os_mutex_lock(korp_mutex *mutex)
  23. {
  24. sgx_thread_mutex_lock(mutex);
  25. }
  26. void os_mutex_unlock(korp_mutex *mutex)
  27. {
  28. sgx_thread_mutex_unlock(mutex);
  29. }
  30. int os_cond_init(korp_cond *cond)
  31. {
  32. sgx_thread_cond_t c = SGX_THREAD_COND_INITIALIZER;
  33. *cond = c;
  34. return BHT_OK;
  35. }
  36. int os_cond_destroy(korp_cond *cond)
  37. {
  38. sgx_thread_cond_destroy(cond);
  39. return BHT_OK;
  40. }
  41. uint8 *os_thread_get_stack_boundary()
  42. {
  43. /* TODO: get sgx stack boundary */
  44. return NULL;
  45. }