pthread.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include <stdlib.h>
  6. #include <pthread.h>
  7. int ocall_pthread_rwlock_init(void **rwlock, void *attr)
  8. {
  9. int ret = 0;
  10. *rwlock = malloc(sizeof(pthread_rwlock_t));
  11. if (*rwlock == NULL)
  12. return -1;
  13. ret = pthread_rwlock_init((pthread_rwlock_t *)*rwlock, NULL);
  14. if (ret != 0) {
  15. free(*rwlock);
  16. *rwlock = NULL;
  17. }
  18. (void)attr;
  19. return ret;
  20. }
  21. int ocall_pthread_rwlock_destroy(void *rwlock)
  22. {
  23. pthread_rwlock_t *lock = (pthread_rwlock_t *)rwlock;
  24. int ret;
  25. ret = pthread_rwlock_destroy(lock);
  26. free(lock);
  27. return ret;
  28. }
  29. int ocall_pthread_rwlock_rdlock(void *rwlock)
  30. {
  31. return pthread_rwlock_rdlock((pthread_rwlock_t *)rwlock);
  32. }
  33. int ocall_pthread_rwlock_wrlock(void *rwlock)
  34. {
  35. return pthread_rwlock_wrlock((pthread_rwlock_t *)rwlock);
  36. }
  37. int ocall_pthread_rwlock_unlock(void *rwlock)
  38. {
  39. return pthread_rwlock_unlock((pthread_rwlock_t *)rwlock);
  40. }