]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_thr.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / libldap_r / thr_thr.c
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-2013 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
17 #include "portable.h"
18
19 #if defined( HAVE_THR )
20
21 #include "ldap_pvt_thread.h" /* Get the thread interface */
22 #define LDAP_THREAD_IMPLEMENTATION
23 #include "ldap_thr_debug.h"      /* May rename the symbols defined below */
24
25 /*******************
26  *                 *
27  * Solaris Threads *
28  *                 *
29  *******************/
30
31 int
32 ldap_int_thread_initialize( void )
33 {
34         return 0;
35 }
36
37 int
38 ldap_int_thread_destroy( void )
39 {
40         return 0;
41 }
42
43 #ifdef LDAP_THREAD_HAVE_SETCONCURRENCY
44 int
45 ldap_pvt_thread_set_concurrency(int n)
46 {
47         return thr_setconcurrency( n );
48 }
49 #endif
50
51 #ifdef LDAP_THREAD_HAVE_GETCONCURRENCY
52 int
53 ldap_pvt_thread_get_concurrency(void)
54 {
55         return thr_getconcurrency();
56 }
57 #endif
58
59 int 
60 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
61         int detach,
62         void *(*start_routine)( void *),
63         void *arg)
64 {
65         return( thr_create( NULL, LDAP_PVT_THREAD_STACK_SIZE, start_routine,
66                 arg, detach ? THR_DETACHED : 0, thread ) );
67 }
68
69 void 
70 ldap_pvt_thread_exit( void *retval )
71 {
72         thr_exit( NULL );
73 }
74
75 int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
76 {
77         thr_join( thread, NULL, thread_return );
78         return 0;
79 }
80
81 int 
82 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
83 {
84         thr_kill( thread, signo );
85         return 0;
86 }
87         
88 int 
89 ldap_pvt_thread_yield( void )
90 {
91         thr_yield();
92         return 0;
93 }
94
95 int 
96 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
97 {
98         return( cond_init( cond, USYNC_THREAD, NULL ) );
99 }
100
101 int 
102 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
103 {
104         return( cond_signal( cond ) );
105 }
106
107 int
108 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
109 {
110         return( cond_broadcast( cv ) );
111 }
112
113 int 
114 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
115         ldap_pvt_thread_mutex_t *mutex )
116 {
117         return( cond_wait( cond, mutex ) );
118 }
119
120 int
121 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
122 {
123         return( cond_destroy( cv ) );
124 }
125
126 int 
127 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
128 {
129         return( mutex_init( mutex, USYNC_THREAD, NULL ) );
130 }
131
132 int 
133 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
134 {
135         return( mutex_destroy( mutex ) );
136 }
137
138 int 
139 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
140 {
141         return( mutex_lock( mutex ) );
142 }
143
144 int 
145 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
146 {
147         return( mutex_unlock( mutex ) );
148 }
149
150 int
151 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
152 {
153         return( mutex_trylock( mp ) );
154 }
155
156 ldap_pvt_thread_t
157 ldap_pvt_thread_self( void )
158 {
159         return thr_self();
160 }
161
162 int
163 ldap_pvt_thread_key_create( ldap_pvt_thread_key_t *key )
164 {
165         return thr_keycreate( key, NULL );
166 }
167
168 int
169 ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key )
170 {
171         return( 0 );
172 }
173
174 int
175 ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key, void *data )
176 {
177         return thr_setspecific( key, data );
178 }
179
180 int
181 ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key, void **data )
182 {
183         return thr_getspecific( key, data );
184 }
185
186 #endif /* HAVE_THR */