pthread.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  17. */
  18. #pragma GCC system_header
  19. #include_next <pthread.h>
  20. #ifndef _COBALT_PTHREAD_H
  21. #define _COBALT_PTHREAD_H
  22. #include <boilerplate/libc.h>
  23. #include <cobalt/wrappers.h>
  24. #include <cobalt/uapi/thread.h>
  25. typedef struct pthread_attr_ex {
  26. pthread_attr_t std;
  27. struct {
  28. int personality;
  29. int sched_policy;
  30. struct sched_param_ex sched_param;
  31. } nonstd;
  32. } pthread_attr_ex_t;
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. COBALT_DECL(int, pthread_attr_init, (pthread_attr_t *attr));
  37. COBALT_DECL(int, pthread_create,
  38. (pthread_t *ptid_r, const pthread_attr_t *attr,
  39. void *(*start)(void *), void *arg));
  40. COBALT_DECL(int, pthread_getschedparam,
  41. (pthread_t thread, int *policy, struct sched_param *param));
  42. COBALT_DECL(int, pthread_setschedparam,
  43. (pthread_t thread, int policy, const struct sched_param *param));
  44. COBALT_DECL(int, pthread_setschedprio, (pthread_t thread, int prio));
  45. COBALT_DECL(int, pthread_mutex_init,
  46. (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr));
  47. COBALT_DECL(int, pthread_mutex_destroy, (pthread_mutex_t *mutex));
  48. COBALT_DECL(int, pthread_mutex_lock, (pthread_mutex_t *mutex));
  49. COBALT_DECL_TIME64(int, pthread_mutex_timedlock, __pthread_mutex_timedlock64,
  50. (pthread_mutex_t *mutex, const struct timespec *to));
  51. COBALT_DECL(int, pthread_mutex_trylock, (pthread_mutex_t *mutex));
  52. COBALT_DECL(int, pthread_mutex_unlock, (pthread_mutex_t *mutex));
  53. COBALT_DECL(int, pthread_mutex_setprioceiling,
  54. (pthread_mutex_t *__restrict mutex, int prioceiling,
  55. int *__restrict old_ceiling));
  56. COBALT_DECL(int, pthread_mutex_getprioceiling,
  57. (pthread_mutex_t *__restrict mutex, int *__restrict old_ceiling));
  58. COBALT_DECL(int, pthread_cond_init,
  59. (pthread_cond_t *cond, const pthread_condattr_t *attr));
  60. COBALT_DECL(int, pthread_cond_destroy, (pthread_cond_t *cond));
  61. COBALT_DECL(int, pthread_cond_wait,
  62. (pthread_cond_t *cond, pthread_mutex_t *mutex));
  63. COBALT_DECL_TIME64(int, pthread_cond_timedwait, __pthread_cond_timedwait64,
  64. (pthread_cond_t *cond, pthread_mutex_t *mutex,
  65. const struct timespec *abstime));
  66. COBALT_DECL(int, pthread_cond_signal, (pthread_cond_t *cond));
  67. COBALT_DECL(int, pthread_cond_broadcast, (pthread_cond_t *cond));
  68. COBALT_DECL(int, pthread_kill, (pthread_t ptid, int sig));
  69. COBALT_DECL(int, pthread_join, (pthread_t ptid, void **retval));
  70. #ifndef pthread_yield
  71. /*
  72. * linuxthreads wraps pthread_yield() to sched_yield() via a
  73. * preprocessor macro, which confuses the compiler with
  74. * COBALT_DECL(). Since Cobalt also routes pthread_yield() to its own
  75. * sched_yield() implementation internally, we can live with this
  76. * wrapping.
  77. */
  78. COBALT_DECL(int, pthread_yield, (void));
  79. #endif
  80. int pthread_setmode_np(int clrmask, int setmask,
  81. int *mask_r);
  82. COBALT_DECL(int, pthread_setname_np, (pthread_t thread, const char *name));
  83. int pthread_create_ex(pthread_t *ptid_r,
  84. const pthread_attr_ex_t *attr_ex,
  85. void *(*start)(void *),
  86. void *arg);
  87. int pthread_getschedparam_ex(pthread_t ptid,
  88. int *pol,
  89. struct sched_param_ex *par);
  90. int pthread_setschedparam_ex(pthread_t ptid,
  91. int pol,
  92. const struct sched_param_ex *par);
  93. int pthread_attr_init_ex(pthread_attr_ex_t *attr_ex);
  94. int pthread_attr_destroy_ex(pthread_attr_ex_t *attr_ex);
  95. int pthread_attr_setschedpolicy_ex(pthread_attr_ex_t *attr_ex,
  96. int policy);
  97. int pthread_attr_getschedpolicy_ex(const pthread_attr_ex_t *attr_ex,
  98. int *policy);
  99. int pthread_attr_setschedparam_ex(pthread_attr_ex_t *attr_ex,
  100. const struct sched_param_ex *param_ex);
  101. int pthread_attr_getschedparam_ex(const pthread_attr_ex_t *attr_ex,
  102. struct sched_param_ex *param_ex);
  103. int pthread_attr_getinheritsched_ex(const pthread_attr_ex_t *attr_ex,
  104. int *inheritsched);
  105. int pthread_attr_setinheritsched_ex(pthread_attr_ex_t *attr_ex,
  106. int inheritsched);
  107. int pthread_attr_getdetachstate_ex(const pthread_attr_ex_t *attr_ex,
  108. int *detachstate);
  109. int pthread_attr_setdetachstate_ex(pthread_attr_ex_t *attr_ex,
  110. int detachstate);
  111. int pthread_attr_setdetachstate_ex(pthread_attr_ex_t *attr_ex,
  112. int detachstate);
  113. int pthread_attr_getstacksize_ex(const pthread_attr_ex_t *attr_ex,
  114. size_t *stacksize);
  115. int pthread_attr_setstacksize_ex(pthread_attr_ex_t *attr_ex,
  116. size_t stacksize);
  117. int pthread_attr_getscope_ex(const pthread_attr_ex_t *attr_ex,
  118. int *scope);
  119. int pthread_attr_setscope_ex(pthread_attr_ex_t *attr_ex,
  120. int scope);
  121. int pthread_attr_getpersonality_ex(const pthread_attr_ex_t *attr_ex,
  122. int *personality);
  123. int pthread_attr_setpersonality_ex(pthread_attr_ex_t *attr_ex,
  124. int personality);
  125. int pthread_mutex_lock_interruptible_np(pthread_mutex_t *mutex);
  126. int pthread_timedmutex_lock_interruptible_np(pthread_mutex_t *mutex, const struct timespec *to);
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. #endif /* !_COBALT_PTHREAD_H */