1 /* thr_thr.c - wrappers around solaris threads */
2 /* $OpenLDAP: pkg/ldap/libraries/libldap_r/thr_thr.c,v 1.18.2.4 2008/02/11 23:26:42 kurt Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2008 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
19 #if defined( HAVE_THR )
21 #include "ldap_pvt_thread.h" /* Get the thread interface */
22 #define LDAP_THREAD_IMPLEMENTATION
23 #include "ldap_thr_debug.h" /* May rename the symbols defined below */
32 ldap_int_thread_initialize( void )
38 ldap_int_thread_destroy( void )
43 #ifdef LDAP_THREAD_HAVE_SETCONCURRENCY
45 ldap_pvt_thread_set_concurrency(int n
)
47 return thr_setconcurrency( n
);
51 #ifdef LDAP_THREAD_HAVE_GETCONCURRENCY
53 ldap_pvt_thread_get_concurrency(void)
55 return thr_getconcurrency();
60 ldap_pvt_thread_create( ldap_pvt_thread_t
* thread
,
62 void *(*start_routine
)( void *),
65 return( thr_create( NULL
, LDAP_PVT_THREAD_STACK_SIZE
, start_routine
,
66 arg
, detach
? THR_DETACHED
: 0, thread
) );
70 ldap_pvt_thread_exit( void *retval
)
75 int ldap_pvt_thread_join( ldap_pvt_thread_t thread
, void **thread_return
)
77 thr_join( thread
, NULL
, thread_return
);
82 ldap_pvt_thread_kill( ldap_pvt_thread_t thread
, int signo
)
84 thr_kill( thread
, signo
);
89 ldap_pvt_thread_yield( void )
96 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t
*cond
)
98 return( cond_init( cond
, USYNC_THREAD
, NULL
) );
102 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t
*cond
)
104 return( cond_signal( cond
) );
108 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t
*cv
)
110 return( cond_broadcast( cv
) );
114 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t
*cond
,
115 ldap_pvt_thread_mutex_t
*mutex
)
117 return( cond_wait( cond
, mutex
) );
121 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t
*cv
)
123 return( cond_destroy( cv
) );
127 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t
*mutex
)
129 return( mutex_init( mutex
, USYNC_THREAD
, NULL
) );
133 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t
*mutex
)
135 return( mutex_destroy( mutex
) );
139 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t
*mutex
)
141 return( mutex_lock( mutex
) );
145 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t
*mutex
)
147 return( mutex_unlock( mutex
) );
151 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t
*mp
)
153 return( mutex_trylock( mp
) );
157 ldap_pvt_thread_self( void )
163 ldap_pvt_thread_key_create( ldap_pvt_thread_key_t
*key
)
165 return thr_keycreate( key
, NULL
);
169 ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key
)
175 ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key
, void *data
)
177 return thr_setspecific( key
, data
);
181 ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key
, void **data
)
183 return thr_getspecific( key
, data
);
186 #endif /* HAVE_THR */