Back to index

openldap  2.4.31
thr_thr.c
Go to the documentation of this file.
00001 /* thr_thr.c - wrappers around solaris threads */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #include "portable.h"
00018 
00019 #if defined( HAVE_THR )
00020 
00021 #include "ldap_pvt_thread.h" /* Get the thread interface */
00022 #define LDAP_THREAD_IMPLEMENTATION
00023 #include "ldap_thr_debug.h"  /* May rename the symbols defined below */
00024 
00025 /*******************
00026  *                 *
00027  * Solaris Threads *
00028  *                 *
00029  *******************/
00030 
00031 int
00032 ldap_int_thread_initialize( void )
00033 {
00034        return 0;
00035 }
00036 
00037 int
00038 ldap_int_thread_destroy( void )
00039 {
00040        return 0;
00041 }
00042 
00043 #ifdef LDAP_THREAD_HAVE_SETCONCURRENCY
00044 int
00045 ldap_pvt_thread_set_concurrency(int n)
00046 {
00047        return thr_setconcurrency( n );
00048 }
00049 #endif
00050 
00051 #ifdef LDAP_THREAD_HAVE_GETCONCURRENCY
00052 int
00053 ldap_pvt_thread_get_concurrency(void)
00054 {
00055        return thr_getconcurrency();
00056 }
00057 #endif
00058 
00059 int 
00060 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
00061        int detach,
00062        void *(*start_routine)( void *),
00063        void *arg)
00064 {
00065        return( thr_create( NULL, LDAP_PVT_THREAD_STACK_SIZE, start_routine,
00066               arg, detach ? THR_DETACHED : 0, thread ) );
00067 }
00068 
00069 void 
00070 ldap_pvt_thread_exit( void *retval )
00071 {
00072        thr_exit( NULL );
00073 }
00074 
00075 int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
00076 {
00077        thr_join( thread, NULL, thread_return );
00078        return 0;
00079 }
00080 
00081 int 
00082 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
00083 {
00084        thr_kill( thread, signo );
00085        return 0;
00086 }
00087        
00088 int 
00089 ldap_pvt_thread_yield( void )
00090 {
00091        thr_yield();
00092        return 0;
00093 }
00094 
00095 int 
00096 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
00097 {
00098        return( cond_init( cond, USYNC_THREAD, NULL ) );
00099 }
00100 
00101 int 
00102 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
00103 {
00104        return( cond_signal( cond ) );
00105 }
00106 
00107 int
00108 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
00109 {
00110        return( cond_broadcast( cv ) );
00111 }
00112 
00113 int 
00114 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
00115        ldap_pvt_thread_mutex_t *mutex )
00116 {
00117        return( cond_wait( cond, mutex ) );
00118 }
00119 
00120 int
00121 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
00122 {
00123        return( cond_destroy( cv ) );
00124 }
00125 
00126 int 
00127 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
00128 {
00129        return( mutex_init( mutex, USYNC_THREAD, NULL ) );
00130 }
00131 
00132 int 
00133 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
00134 {
00135        return( mutex_destroy( mutex ) );
00136 }
00137 
00138 int 
00139 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
00140 {
00141        return( mutex_lock( mutex ) );
00142 }
00143 
00144 int 
00145 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
00146 {
00147        return( mutex_unlock( mutex ) );
00148 }
00149 
00150 int
00151 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
00152 {
00153        return( mutex_trylock( mp ) );
00154 }
00155 
00156 ldap_pvt_thread_t
00157 ldap_pvt_thread_self( void )
00158 {
00159        return thr_self();
00160 }
00161 
00162 int
00163 ldap_pvt_thread_key_create( ldap_pvt_thread_key_t *key )
00164 {
00165        return thr_keycreate( key, NULL );
00166 }
00167 
00168 int
00169 ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key )
00170 {
00171        return( 0 );
00172 }
00173 
00174 int
00175 ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key, void *data )
00176 {
00177        return thr_setspecific( key, data );
00178 }
00179 
00180 int
00181 ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key, void **data )
00182 {
00183        return thr_getspecific( key, data );
00184 }
00185 
00186 #endif /* HAVE_THR */