]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_thr.c
Add ldap_pvt_thread_destory() to un-ldap_pvt_thread_initialize().
[openldap] / libraries / libldap_r / thr_thr.c
1 /*
2  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted only
6  * as authorized by the OpenLDAP Public License.  A copy of this
7  * license is available at http://www.OpenLDAP.org/license.html or
8  * in file LICENSE in the top-level directory of the distribution.
9  */
10
11 /* thr_thr.c - wrappers around solaris threads */
12
13 #include "portable.h"
14 #include "ldap_pvt_thread.h"
15
16 #if defined( HAVE_THR )
17
18 /*******************
19  *                 *
20  * Solaris Threads *
21  *                 *
22  *******************/
23
24 int
25 ldap_pvt_thread_initialize( void )
26 {
27 #ifdef LDAP_THREAD_CONCURRENCY
28         thr_setconcurrency( LDAP_THREAD_CONCURRENCY );
29 #endif
30         return 0;
31 }
32
33 int
34 ldap_pvt_thread_destroy( void )
35 {
36         return 0;
37 }
38
39 int
40 ldap_pvt_thread_set_concurrency(int n)
41 {
42         return thr_setconcurrency( n );
43 }
44
45 int
46 ldap_pvt_thread_get_concurrency(void)
47 {
48         return thr_getconcurrency();
49 }
50
51 int 
52 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
53         int detach,
54         void *(*start_routine)( void *),
55         void *arg)
56 {
57         return( thr_create( NULL, 0, start_routine, arg,
58                 detach ? THR_DETACHED : 0,
59                 thread ) );
60 }
61
62 void 
63 ldap_pvt_thread_exit( void *retval )
64 {
65         thr_exit( NULL );
66 }
67
68 int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
69 {
70         thr_join( thread, NULL, thread_return );
71         return 0;
72 }
73
74 int 
75 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
76 {
77         thr_kill( thread, signo );
78         return 0;
79 }
80         
81 int 
82 ldap_pvt_thread_yield( void )
83 {
84         thr_yield();
85         return 0;
86 }
87
88 int 
89 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
90 {
91         return( cond_init( cond, USYNC_THREAD, NULL ) );
92 }
93
94 int 
95 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
96 {
97         return( cond_signal( cond ) );
98 }
99
100 int
101 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
102 {
103         return( cond_broadcast( cv ) );
104 }
105
106 int 
107 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
108                           ldap_pvt_thread_mutex_t *mutex )
109 {
110         return( cond_wait( cond, mutex ) );
111 }
112
113 int
114 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
115 {
116         return( cond_destroy( cv ) );
117 }
118
119 int 
120 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
121 {
122         return( mutex_init( mutex, USYNC_THREAD, NULL ) );
123 }
124
125 int 
126 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
127 {
128         return( mutex_destroy( mutex ) );
129 }
130
131 int 
132 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
133 {
134         return( mutex_lock( mutex ) );
135 }
136
137 int 
138 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
139 {
140         return( mutex_unlock( mutex ) );
141 }
142
143 int
144 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
145 {
146         return( mutex_trylock( mp ) );
147 }
148
149 #endif /* HAVE_THR */