text: /*
   * Copyright (C) 2020 XiaoMi Corporation.  All rights reserved.
   * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
   */
  
  #include "platform_api_extension.h"
  #include "platform_api_vmcore.h"
  
  korp_tid
  os_self_thread()
  {
      return (korp_tid)pthread_self();
  }
  
  int
  os_mutex_init(korp_mutex *mutex)
  {
      return pthread_mutex_init(mutex, NULL) == 0 ? BHT_OK : BHT_ERROR;
  }
  
  int
  os_mutex_destroy(korp_mutex *mutex)
  {
      int ret;
  
      assert(mutex);
      ret = pthread_mutex_destroy(mutex);
  
      return ret == 0 ? BHT_OK : BHT_ERROR;
  }
  
  int
  os_mutex_lock(korp_mutex *mutex)
  {
      int ret;
  
      assert(mutex);
      ret = pthread_mutex_lock(mutex);
  
      return ret == 0 ? BHT_OK : BHT_ERROR;
  }
  
  int
  os_mutex_unlock(korp_mutex *mutex)
  {
      int ret;
  
      assert(mutex);
      ret = pthread_mutex_unlock(mutex);
  
      return ret == 0 ? BHT_OK : BHT_ERROR;
  }
  
  uint8 *
  os_thread_get_stack_boundary()
  {
      return NULL;
  }
  
  int
  os_cond_init(korp_cond *cond)
  {
      assert(cond);
  
      if (pthread_cond_init(cond, NULL) != BHT_OK)
          return BHT_ERROR;
  
      return BHT_OK;
  }
  
  int
  os_cond_destroy(korp_cond *cond)
  {
      assert(cond);
  
      if (pthread_cond_destroy(cond) != BHT_OK)
          return BHT_ERROR;
  
      return BHT_OK;
  }
  