thr_thr.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* thr_thr.c - wrappers around solaris threads */
  2. /* $OpenLDAP$ */
  3. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  4. *
  5. * Copyright 1998-2022 The OpenLDAP Foundation.
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted only as authorized by the OpenLDAP
  10. * Public License.
  11. *
  12. * A copy of this license is available in file LICENSE in the
  13. * top-level directory of the distribution or, alternatively, at
  14. * <http://www.OpenLDAP.org/license.html>.
  15. */
  16. #include "portable.h"
  17. #if defined( HAVE_THR )
  18. #include "ldap_pvt_thread.h" /* Get the thread interface */
  19. #define LDAP_THREAD_IMPLEMENTATION
  20. #include "ldap_thr_debug.h" /* May rename the symbols defined below */
  21. /*******************
  22. * *
  23. * Solaris Threads *
  24. * *
  25. *******************/
  26. int
  27. ldap_int_thread_initialize( void )
  28. {
  29. return 0;
  30. }
  31. int
  32. ldap_int_thread_destroy( void )
  33. {
  34. return 0;
  35. }
  36. #ifdef LDAP_THREAD_HAVE_SETCONCURRENCY
  37. int
  38. ldap_pvt_thread_set_concurrency(int n)
  39. {
  40. return thr_setconcurrency( n );
  41. }
  42. #endif
  43. #ifdef LDAP_THREAD_HAVE_GETCONCURRENCY
  44. int
  45. ldap_pvt_thread_get_concurrency(void)
  46. {
  47. return thr_getconcurrency();
  48. }
  49. #endif
  50. int
  51. ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
  52. int detach,
  53. void *(*start_routine)( void *),
  54. void *arg)
  55. {
  56. return( thr_create( NULL, LDAP_PVT_THREAD_STACK_SIZE, start_routine,
  57. arg, detach ? THR_DETACHED : 0, thread ) );
  58. }
  59. void
  60. ldap_pvt_thread_exit( void *retval )
  61. {
  62. thr_exit( NULL );
  63. }
  64. int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
  65. {
  66. thr_join( thread, NULL, thread_return );
  67. return 0;
  68. }
  69. int
  70. ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
  71. {
  72. thr_kill( thread, signo );
  73. return 0;
  74. }
  75. int
  76. ldap_pvt_thread_yield( void )
  77. {
  78. thr_yield();
  79. return 0;
  80. }
  81. int
  82. ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
  83. {
  84. return( cond_init( cond, USYNC_THREAD, NULL ) );
  85. }
  86. int
  87. ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
  88. {
  89. return( cond_signal( cond ) );
  90. }
  91. int
  92. ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
  93. {
  94. return( cond_broadcast( cv ) );
  95. }
  96. int
  97. ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
  98. ldap_pvt_thread_mutex_t *mutex )
  99. {
  100. return( cond_wait( cond, mutex ) );
  101. }
  102. int
  103. ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
  104. {
  105. return( cond_destroy( cv ) );
  106. }
  107. int
  108. ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
  109. {
  110. return( mutex_init( mutex, USYNC_THREAD, NULL ) );
  111. }
  112. int
  113. ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
  114. {
  115. return( mutex_destroy( mutex ) );
  116. }
  117. int
  118. ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
  119. {
  120. return( mutex_lock( mutex ) );
  121. }
  122. int
  123. ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
  124. {
  125. return( mutex_unlock( mutex ) );
  126. }
  127. int
  128. ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
  129. {
  130. return( mutex_trylock( mp ) );
  131. }
  132. int
  133. ldap_pvt_thread_mutex_recursive_init( ldap_pvt_thread_mutex_t *mutex )
  134. {
  135. return( mutex_init( mutex, USYNC_THREAD | LOCK_RECURSIVE, NULL ) );
  136. }
  137. ldap_pvt_thread_t
  138. ldap_pvt_thread_self( void )
  139. {
  140. return thr_self();
  141. }
  142. int
  143. ldap_pvt_thread_key_create( ldap_pvt_thread_key_t *key )
  144. {
  145. return thr_keycreate( key, NULL );
  146. }
  147. int
  148. ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key )
  149. {
  150. return( 0 );
  151. }
  152. int
  153. ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key, void *data )
  154. {
  155. return thr_setspecific( key, data );
  156. }
  157. int
  158. ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key, void **data )
  159. {
  160. return thr_getspecific( key, data );
  161. }
  162. #endif /* HAVE_THR */