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