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