pthread-threads.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* classes: h_files */
  2. #ifndef SCM_PTHREADS_THREADS_H
  3. #define SCM_PTHREADS_THREADS_H
  4. /* Copyright (C) 2002, 2005, 2006, 2011 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. /* The pthreads-threads implementation. This is a direct mapping.
  22. */
  23. #include <pthread.h>
  24. #include <sched.h>
  25. /* Threads
  26. */
  27. #define scm_i_pthread_t pthread_t
  28. #define scm_i_pthread_self pthread_self
  29. #define scm_i_pthread_create pthread_create
  30. #define scm_i_pthread_detach pthread_detach
  31. #define scm_i_pthread_exit pthread_exit
  32. #define scm_i_pthread_cancel pthread_cancel
  33. #define scm_i_pthread_cleanup_push pthread_cleanup_push
  34. #define scm_i_pthread_cleanup_pop pthread_cleanup_pop
  35. #define scm_i_sched_yield sched_yield
  36. /* Signals
  37. */
  38. #define scm_i_pthread_sigmask pthread_sigmask
  39. /* Mutexes
  40. */
  41. #if SCM_NEED_BRACES_ON_PTHREAD_MUTEX_INITIALIZER
  42. # define SCM_I_PTHREAD_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
  43. #else
  44. # define SCM_I_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  45. #endif
  46. #define scm_i_pthread_mutex_t pthread_mutex_t
  47. #define scm_i_pthread_mutex_init pthread_mutex_init
  48. #define scm_i_pthread_mutex_destroy pthread_mutex_destroy
  49. #define scm_i_pthread_mutex_trylock pthread_mutex_trylock
  50. #define scm_i_pthread_mutex_lock pthread_mutex_lock
  51. #define scm_i_pthread_mutex_unlock pthread_mutex_unlock
  52. extern pthread_mutexattr_t scm_i_pthread_mutexattr_recursive[1];
  53. /* Condition variables
  54. */
  55. #define SCM_I_PTHREAD_COND_INITIALIZER PTHREAD_COND_INITIALIZER
  56. #define scm_i_pthread_cond_t pthread_cond_t
  57. #define scm_i_pthread_cond_init pthread_cond_init
  58. #define scm_i_pthread_cond_destroy pthread_cond_destroy
  59. #define scm_i_pthread_cond_signal pthread_cond_signal
  60. #define scm_i_pthread_cond_broadcast pthread_cond_broadcast
  61. #define scm_i_pthread_cond_wait pthread_cond_wait
  62. #define scm_i_pthread_cond_timedwait pthread_cond_timedwait
  63. /* Onces
  64. */
  65. #define scm_i_pthread_once_t pthread_once_t
  66. #define scm_i_pthread_once pthread_once
  67. #if SCM_NEED_BRACES_ON_PTHREAD_ONCE_INIT
  68. #define SCM_I_PTHREAD_ONCE_INIT { PTHREAD_ONCE_INIT }
  69. #else
  70. #define SCM_I_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
  71. #endif
  72. /* Thread specific storage
  73. */
  74. #define scm_i_pthread_key_t pthread_key_t
  75. #define scm_i_pthread_key_create pthread_key_create
  76. #define scm_i_pthread_setspecific pthread_setspecific
  77. #define scm_i_pthread_getspecific pthread_getspecific
  78. /* Convenience functions
  79. */
  80. #define scm_i_scm_pthread_mutex_lock scm_pthread_mutex_lock
  81. #define scm_i_dynwind_pthread_mutex_lock scm_dynwind_pthread_mutex_lock
  82. #define scm_i_scm_pthread_cond_wait scm_pthread_cond_wait
  83. #define scm_i_scm_pthread_cond_timedwait scm_pthread_cond_timedwait
  84. #endif /* SCM_PTHREADS_THREADS_H */
  85. /*
  86. Local Variables:
  87. c-file-style: "gnu"
  88. End:
  89. */