pthread_internal.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2010-10-26 Bernard the first version
  9. */
  10. #ifndef __PTHREAD_INTERNAL_H__
  11. #define __PTHREAD_INTERNAL_H__
  12. #include <rtthread.h>
  13. #include <pthread.h>
  14. struct _pthread_cleanup
  15. {
  16. void (*cleanup_func)(void *parameter);
  17. void *parameter;
  18. struct _pthread_cleanup *next;
  19. };
  20. typedef struct _pthread_cleanup _pthread_cleanup_t;
  21. struct _pthread_key_data
  22. {
  23. int is_used;
  24. void (*destructor)(void *parameter);
  25. };
  26. typedef struct _pthread_key_data _pthread_key_data_t;
  27. #ifndef PTHREAD_NUM_MAX
  28. #define PTHREAD_NUM_MAX 32
  29. #endif
  30. #define PTHREAD_MAGIC 0x70746873
  31. struct _pthread_data
  32. {
  33. rt_uint32_t magic;
  34. pthread_attr_t attr;
  35. rt_thread_t tid;
  36. void* (*thread_entry)(void *parameter);
  37. void *thread_parameter;
  38. /* return value */
  39. void *return_value;
  40. /* semaphore for joinable thread */
  41. rt_sem_t joinable_sem;
  42. /* cancel state and type */
  43. rt_uint8_t cancelstate;
  44. volatile rt_uint8_t canceltype;
  45. volatile rt_uint8_t canceled;
  46. _pthread_cleanup_t *cleanup;
  47. void** tls; /* thread-local storage area */
  48. };
  49. typedef struct _pthread_data _pthread_data_t;
  50. _pthread_data_t *_pthread_get_data(pthread_t thread);
  51. int clock_time_to_tick(const struct timespec *time);
  52. void posix_mq_system_init(void);
  53. void posix_sem_system_init(void);
  54. void pthread_key_system_init(void);
  55. #endif