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