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