pthread.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _WAMR_LIB_PTHREAD_H
  6. #define _WAMR_LIB_PTHREAD_H
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #include <stdint.h>
  11. /* Data type define of pthread, mutex, cond and key */
  12. typedef unsigned int pthread_t;
  13. typedef unsigned int pthread_mutex_t;
  14. typedef unsigned int pthread_cond_t;
  15. typedef unsigned int pthread_key_t;
  16. /* Thread APIs */
  17. int
  18. pthread_create(pthread_t *thread, const void *attr,
  19. void *(*start_routine)(void *), void *arg);
  20. int
  21. pthread_join(pthread_t thread, void **retval);
  22. int
  23. pthread_detach(pthread_t thread);
  24. int
  25. pthread_cancel(pthread_t thread);
  26. pthread_t
  27. pthread_self(void);
  28. void
  29. pthread_exit(void *retval);
  30. /* Mutex APIs */
  31. int
  32. pthread_mutex_init(pthread_mutex_t *mutex, const void *attr);
  33. int
  34. pthread_mutex_lock(pthread_mutex_t *mutex);
  35. int
  36. pthread_mutex_unlock(pthread_mutex_t *mutex);
  37. int
  38. pthread_mutex_destroy(pthread_mutex_t *mutex);
  39. /* Cond APIs */
  40. int
  41. pthread_cond_init(pthread_cond_t *cond, const void *attr);
  42. int
  43. pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
  44. int
  45. pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
  46. uint64_t useconds);
  47. int
  48. pthread_cond_signal(pthread_cond_t *cond);
  49. int
  50. pthread_cond_broadcast(pthread_cond_t *cond);
  51. int
  52. pthread_cond_destroy(pthread_cond_t *cond);
  53. /* Pthread key APIs */
  54. int
  55. pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
  56. int
  57. pthread_setspecific(pthread_key_t key, const void *value);
  58. void *
  59. pthread_getspecific(pthread_key_t key);
  60. int
  61. pthread_key_delete(pthread_key_t key);
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* end of _WAMR_LIB_PTHREAD_H */