]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_thr.c
Define env.variable SLAPD_DEBUG to override the default debug level
[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_set_concurrency(int n)
35 {
36         return thr_setconcurrency( n );
37 }
38
39 int
40 ldap_pvt_thread_get_concurrency(void)
41 {
42         return thr_getconcurrency();
43 }
44
45 int 
46 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
47         int detach,
48         void *(*start_routine)( void *),
49         void *arg)
50 {
51         return( thr_create( NULL, 0, start_routine, arg,
52                 detach ? THR_DETACHED : 0,
53                 thread ) );
54 }
55
56 void 
57 ldap_pvt_thread_exit( void *retval )
58 {
59         thr_exit( NULL );
60 }
61
62 int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
63 {
64         thr_join( thread, NULL, thread_return );
65         return 0;
66 }
67
68 int 
69 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
70 {
71         thr_kill( thread, signo );
72         return 0;
73 }
74         
75 int 
76 ldap_pvt_thread_yield( void )
77 {
78         thr_yield();
79         return 0;
80 }
81
82 int 
83 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
84 {
85         return( cond_init( cond, USYNC_THREAD, NULL ) );
86 }
87
88 int 
89 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
90 {
91         return( cond_signal( cond ) );
92 }
93
94 int
95 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
96 {
97         return( cond_broadcast( cv ) );
98 }
99
100 int 
101 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
102                           ldap_pvt_thread_mutex_t *mutex )
103 {
104         return( cond_wait( cond, mutex ) );
105 }
106
107 int
108 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
109 {
110         return( cond_destroy( cv ) );
111 }
112
113 int 
114 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
115 {
116         return( mutex_init( mutex, USYNC_THREAD, NULL ) );
117 }
118
119 int 
120 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
121 {
122         return( mutex_destroy( mutex ) );
123 }
124
125 int 
126 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
127 {
128         return( mutex_lock( mutex ) );
129 }
130
131 int 
132 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
133 {
134         return( mutex_unlock( mutex ) );
135 }
136
137 int
138 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
139 {
140         return( mutex_trylock( mp ) );
141 }
142
143 #endif /* HAVE_THR */