pthread_internal.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2006-2021, 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. #include <sys/time.h>
  15. struct _pthread_cleanup
  16. {
  17. void (*cleanup_func)(void *parameter);
  18. void *parameter;
  19. struct _pthread_cleanup *next;
  20. };
  21. typedef struct _pthread_cleanup _pthread_cleanup_t;
  22. struct _pthread_key_data
  23. {
  24. int is_used;
  25. void (*destructor)(void *parameter);
  26. };
  27. typedef struct _pthread_key_data _pthread_key_data_t;
  28. #ifndef PTHREAD_NUM_MAX
  29. #define PTHREAD_NUM_MAX 32
  30. #endif
  31. #define PTHREAD_MAGIC 0x70746873
  32. struct _pthread_data
  33. {
  34. rt_uint32_t magic;
  35. pthread_attr_t attr;
  36. rt_thread_t tid;
  37. void* (*thread_entry)(void *parameter);
  38. void *thread_parameter;
  39. /* return value */
  40. void *return_value;
  41. /* semaphore for joinable thread */
  42. rt_sem_t joinable_sem;
  43. /* cancel state and type */
  44. rt_uint8_t cancelstate;
  45. volatile rt_uint8_t canceltype;
  46. volatile rt_uint8_t canceled;
  47. _pthread_cleanup_t *cleanup;
  48. void** tls; /* thread-local storage area */
  49. };
  50. typedef struct _pthread_data _pthread_data_t;
  51. _pthread_data_t *_pthread_get_data(pthread_t thread);
  52. #endif