pthread-threads.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* classes: h_files */
  2. #ifndef SCM_PTHREADS_THREADS_H
  3. #define SCM_PTHREADS_THREADS_H
  4. /* Copyright (C) 2002, 2005, 2006 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
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but 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 02110-1301 USA
  19. */
  20. /* The pthreads-threads implementation. This is a direct mapping.
  21. */
  22. #include <pthread.h>
  23. #include <sched.h>
  24. /* Threads
  25. */
  26. #define scm_i_pthread_t pthread_t
  27. #define scm_i_pthread_self pthread_self
  28. #define scm_i_pthread_create pthread_create
  29. #define scm_i_pthread_detach pthread_detach
  30. #define scm_i_pthread_exit pthread_exit
  31. #define scm_i_sched_yield sched_yield
  32. /* Signals
  33. */
  34. #define scm_i_pthread_sigmask pthread_sigmask
  35. /* Mutexes
  36. */
  37. #if SCM_NEED_BRACES_ON_PTHREAD_MUTEX_INITIALIZER
  38. # define SCM_I_PTHREAD_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
  39. #else
  40. # define SCM_I_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  41. #endif
  42. #define scm_i_pthread_mutex_t pthread_mutex_t
  43. #define scm_i_pthread_mutex_init pthread_mutex_init
  44. #define scm_i_pthread_mutex_destroy pthread_mutex_destroy
  45. #define scm_i_pthread_mutex_trylock pthread_mutex_trylock
  46. #define scm_i_pthread_mutex_lock pthread_mutex_lock
  47. #define scm_i_pthread_mutex_unlock pthread_mutex_unlock
  48. extern pthread_mutexattr_t scm_i_pthread_mutexattr_recursive[1];
  49. /* Condition variables
  50. */
  51. #define SCM_I_PTHREAD_COND_INITIALIZER PTHREAD_COND_INITIALIZER
  52. #define scm_i_pthread_cond_t pthread_cond_t
  53. #define scm_i_pthread_cond_init pthread_cond_init
  54. #define scm_i_pthread_cond_destroy pthread_cond_destroy
  55. #define scm_i_pthread_cond_signal pthread_cond_signal
  56. #define scm_i_pthread_cond_broadcast pthread_cond_broadcast
  57. #define scm_i_pthread_cond_wait pthread_cond_wait
  58. #define scm_i_pthread_cond_timedwait pthread_cond_timedwait
  59. /* Onces
  60. */
  61. #define scm_i_pthread_once_t pthread_once_t
  62. #define scm_i_pthread_once pthread_once
  63. #if SCM_NEED_BRACES_ON_PTHREAD_ONCE_INIT
  64. #define SCM_I_PTHREAD_ONCE_INIT { PTHREAD_ONCE_INIT }
  65. #else
  66. #define SCM_I_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
  67. #endif
  68. /* Thread specific storage
  69. */
  70. #define scm_i_pthread_key_t pthread_key_t
  71. #define scm_i_pthread_key_create pthread_key_create
  72. #define scm_i_pthread_setspecific pthread_setspecific
  73. #define scm_i_pthread_getspecific pthread_getspecific
  74. /* Convenience functions
  75. */
  76. #define scm_i_scm_pthread_mutex_lock scm_pthread_mutex_lock
  77. #define scm_i_dynwind_pthread_mutex_lock scm_dynwind_pthread_mutex_lock
  78. #define scm_i_scm_pthread_cond_wait scm_pthread_cond_wait
  79. #define scm_i_scm_pthread_cond_timedwait scm_pthread_cond_timedwait
  80. #endif /* SCM_PTHREADS_THREADS_H */
  81. /*
  82. Local Variables:
  83. c-file-style: "gnu"
  84. End:
  85. */