pthread.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /* Data type define of pthread, mutex, cond and key */
  8. typedef unsigned int pthread_t;
  9. typedef unsigned int pthread_mutex_t;
  10. typedef unsigned int pthread_cond_t;
  11. typedef unsigned int pthread_key_t;
  12. /* Thread APIs */
  13. int pthread_create(pthread_t *thread, const void *attr,
  14. void *(*start_routine) (void *), void *arg);
  15. int pthread_join(pthread_t thread, void **retval);
  16. int pthread_detach(pthread_t thread);
  17. int pthread_cancel(pthread_t thread);
  18. pthread_t pthread_self(void);
  19. void pthread_exit(void *retval);
  20. /* Mutex APIs */
  21. int pthread_mutex_init(pthread_mutex_t *mutex, const void *attr);
  22. int pthread_mutex_lock(pthread_mutex_t *mutex);
  23. int pthread_mutex_unlock(pthread_mutex_t *mutex);
  24. int pthread_mutex_destroy(pthread_mutex_t *mutex);
  25. /* Cond APIs */
  26. int pthread_cond_init(pthread_cond_t *cond, const void *attr);
  27. int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
  28. int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
  29. unsigned int useconds);
  30. int pthread_cond_signal(pthread_cond_t *cond);
  31. int pthread_cond_destroy(pthread_cond_t *cond);
  32. /* Pthread key APIs */
  33. int pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
  34. int pthread_setspecific(pthread_key_t key, const void *value);
  35. void *pthread_getspecific(pthread_key_t key);
  36. int pthread_key_delete(pthread_key_t key);
  37. #endif /* end of _WAMR_LIB_PTHREAD_H */