sgx_thread.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. /* Returned error (EINVAL, EAGAIN and EDEADLK) from
  23. locking the mutex indicates some logic error present in
  24. the program somewhere.
  25. Don't try to recover error for an existing unknown error.*/
  26. void os_mutex_lock(korp_mutex *mutex)
  27. {
  28. sgx_thread_mutex_lock(mutex);
  29. }
  30. /* Returned error (EINVAL, EAGAIN and EPERM) from
  31. unlocking the mutex indicates some logic error present
  32. in the program somewhere.
  33. Don't try to recover error for an existing unknown error.*/
  34. void os_mutex_unlock(korp_mutex *mutex)
  35. {
  36. sgx_thread_mutex_unlock(mutex);
  37. }