]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_thr.c
fix ITS#3499 (may need further testing)
[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-2005 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"
22
23 /*******************
24  *                 *
25  * Solaris Threads *
26  *                 *
27  *******************/
28
29 int
30 ldap_int_thread_initialize( void )
31 {
32         return 0;
33 }
34
35 int
36 ldap_int_thread_destroy( void )
37 {
38         return 0;
39 }
40
41 #ifdef LDAP_THREAD_HAVE_SETCONCURRENCY
42 int
43 ldap_pvt_thread_set_concurrency(int n)
44 {
45         return thr_setconcurrency( n );
46 }
47 #endif
48
49 #ifdef LDAP_THREAD_HAVE_GETCONCURRENCY
50 int
51 ldap_pvt_thread_get_concurrency(void)
52 {
53         return thr_getconcurrency();
54 }
55 #endif
56
57 int 
58 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
59         int detach,
60         void *(*start_routine)( void *),
61         void *arg)
62 {
63         return( thr_create( NULL, LDAP_PVT_THREAD_STACK_SIZE, start_routine,
64                 arg, detach ? THR_DETACHED : 0, thread ) );
65 }
66
67 void 
68 ldap_pvt_thread_exit( void *retval )
69 {
70         thr_exit( NULL );
71 }
72
73 int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
74 {
75         thr_join( thread, NULL, thread_return );
76         return 0;
77 }
78
79 int 
80 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
81 {
82         thr_kill( thread, signo );
83         return 0;
84 }
85         
86 int 
87 ldap_pvt_thread_yield( void )
88 {
89         thr_yield();
90         return 0;
91 }
92
93 int 
94 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
95 {
96         return( cond_init( cond, USYNC_THREAD, NULL ) );
97 }
98
99 int 
100 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
101 {
102         return( cond_signal( cond ) );
103 }
104
105 int
106 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
107 {
108         return( cond_broadcast( cv ) );
109 }
110
111 int 
112 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
113         ldap_pvt_thread_mutex_t *mutex )
114 {
115         return( cond_wait( cond, mutex ) );
116 }
117
118 int
119 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
120 {
121         return( cond_destroy( cv ) );
122 }
123
124 int 
125 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
126 {
127         return( mutex_init( mutex, USYNC_THREAD, NULL ) );
128 }
129
130 int 
131 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
132 {
133         return( mutex_destroy( mutex ) );
134 }
135
136 int 
137 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
138 {
139         return( mutex_lock( mutex ) );
140 }
141
142 int 
143 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
144 {
145         return( mutex_unlock( mutex ) );
146 }
147
148 int
149 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
150 {
151         return( mutex_trylock( mp ) );
152 }
153
154 ldap_pvt_thread_t
155 ldap_pvt_thread_self( void )
156 {
157         return thr_self();
158 }
159
160 #endif /* HAVE_THR */