pthread-threads.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. /* `libgc' defines wrapper procedures for pthread calls. */
  26. #include "libguile/bdw-gc.h"
  27. /* Threads
  28. */
  29. #define scm_i_pthread_t pthread_t
  30. #define scm_i_pthread_self pthread_self
  31. #define scm_i_pthread_create GC_pthread_create
  32. #define scm_i_pthread_detach GC_pthread_detach
  33. #if SCM_HAVE_GC_PTHREAD_EXIT
  34. #define scm_i_pthread_exit GC_pthread_exit
  35. #else
  36. #define scm_i_pthread_exit pthread_exit
  37. #endif
  38. #if SCM_HAVE_GC_PTHREAD_CANCEL
  39. #define scm_i_pthread_cancel GC_pthread_cancel
  40. #else
  41. #define scm_i_pthread_cancel pthread_cancel
  42. #endif
  43. #define scm_i_pthread_cleanup_push pthread_cleanup_push
  44. #define scm_i_pthread_cleanup_pop pthread_cleanup_pop
  45. #define scm_i_sched_yield sched_yield
  46. /* Signals
  47. */
  48. #if SCM_HAVE_GC_PTHREAD_SIGMASK
  49. #define scm_i_pthread_sigmask GC_pthread_sigmask
  50. #else
  51. #define scm_i_pthread_sigmask pthread_sigmask
  52. #endif
  53. /* Mutexes
  54. */
  55. #if SCM_NEED_BRACES_ON_PTHREAD_MUTEX_INITIALIZER
  56. # define SCM_I_PTHREAD_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
  57. #else
  58. # define SCM_I_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  59. #endif
  60. #define scm_i_pthread_mutex_t pthread_mutex_t
  61. #define scm_i_pthread_mutex_init pthread_mutex_init
  62. #define scm_i_pthread_mutex_destroy pthread_mutex_destroy
  63. #define scm_i_pthread_mutex_trylock pthread_mutex_trylock
  64. #define scm_i_pthread_mutex_lock pthread_mutex_lock
  65. #define scm_i_pthread_mutex_unlock pthread_mutex_unlock
  66. extern pthread_mutexattr_t scm_i_pthread_mutexattr_recursive[1];
  67. /* Condition variables
  68. */
  69. #define SCM_I_PTHREAD_COND_INITIALIZER PTHREAD_COND_INITIALIZER
  70. #define scm_i_pthread_cond_t pthread_cond_t
  71. #define scm_i_pthread_cond_init pthread_cond_init
  72. #define scm_i_pthread_cond_destroy pthread_cond_destroy
  73. #define scm_i_pthread_cond_signal pthread_cond_signal
  74. #define scm_i_pthread_cond_broadcast pthread_cond_broadcast
  75. #define scm_i_pthread_cond_wait pthread_cond_wait
  76. #define scm_i_pthread_cond_timedwait pthread_cond_timedwait
  77. /* Onces
  78. */
  79. #define scm_i_pthread_once_t pthread_once_t
  80. #define scm_i_pthread_once pthread_once
  81. #if SCM_NEED_BRACES_ON_PTHREAD_ONCE_INIT
  82. #define SCM_I_PTHREAD_ONCE_INIT { PTHREAD_ONCE_INIT }
  83. #else
  84. #define SCM_I_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
  85. #endif
  86. /* Thread specific storage
  87. */
  88. #define scm_i_pthread_key_t pthread_key_t
  89. #define scm_i_pthread_key_create pthread_key_create
  90. #define scm_i_pthread_setspecific pthread_setspecific
  91. #define scm_i_pthread_getspecific pthread_getspecific
  92. /* Convenience functions
  93. */
  94. #define scm_i_scm_pthread_mutex_lock scm_pthread_mutex_lock
  95. #define scm_i_dynwind_pthread_mutex_lock scm_dynwind_pthread_mutex_lock
  96. #define scm_i_scm_pthread_cond_wait scm_pthread_cond_wait
  97. #define scm_i_scm_pthread_cond_timedwait scm_pthread_cond_timedwait
  98. #endif /* SCM_PTHREADS_THREADS_H */
  99. /*
  100. Local Variables:
  101. c-file-style: "gnu"
  102. End:
  103. */