Back to index

openldap  2.4.31
thr_cthreads.c
Go to the documentation of this file.
00001 /* thr_cthreads.c - wrapper for mach cthreads */
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 /* This work was initially developed by Luke Howard for inclusion
00017  * in U-MICH LDAP 3.3.
00018  */
00019 
00020 #include "portable.h"
00021 
00022 #if defined( HAVE_MACH_CTHREADS )
00023 #include "ldap_pvt_thread.h" /* Get the thread interface */
00024 #define LDAP_THREAD_IMPLEMENTATION
00025 #include "ldap_thr_debug.h"  /* May rename the symbols defined below */
00026 
00027 int
00028 ldap_int_thread_initialize( void )
00029 {
00030        return 0;
00031 }
00032 
00033 int
00034 ldap_int_thread_destroy( void )
00035 {
00036        return 0;
00037 }
00038 
00039 int 
00040 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
00041        int detach,
00042        void *(*start_routine)( void *), void *arg)
00043 {
00044        *thread = cthread_fork( (cthread_fn_t) start_routine, arg);
00045        return ( *thread == NULL ? -1 : 0 );      
00046 }
00047 
00048 void 
00049 ldap_pvt_thread_exit( void *retval )
00050 {
00051        cthread_exit( (any_t) retval );
00052 }
00053 
00054 int 
00055 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
00056 {
00057        void *status;
00058        status = (void *) cthread_join ( thread );
00059        if (thread_return != NULL)
00060               {
00061               *thread_return = status;
00062               }
00063        return 0;
00064 }
00065 
00066 int 
00067 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
00068 {
00069        return 0;
00070 }
00071 
00072 int 
00073 ldap_pvt_thread_yield( void )
00074 {
00075        cthread_yield();
00076        return 0;
00077 }
00078 
00079 int 
00080 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
00081 {
00082        condition_init( cond );
00083        return( 0 );
00084 }
00085 
00086 int 
00087 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
00088 {
00089        condition_clear( cond );
00090        return( 0 );
00091 }
00092 
00093 int 
00094 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
00095 {
00096        condition_signal( cond );
00097        return( 0 );
00098 }
00099 
00100 int
00101 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
00102 {
00103        condition_broadcast( cond );
00104        return( 0 );
00105 }
00106 
00107 int 
00108 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
00109                        ldap_pvt_thread_mutex_t *mutex )
00110 {
00111        condition_wait( cond, mutex );
00112        return( 0 );  
00113 }
00114 
00115 int 
00116 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
00117 {
00118        mutex_init( mutex );
00119        mutex->name = NULL;
00120        return ( 0 );
00121 }
00122 
00123 int 
00124 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
00125 {
00126        mutex_clear( mutex );
00127        return ( 0 ); 
00128 }
00129        
00130 int 
00131 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
00132 {
00133        mutex_lock( mutex );
00134        return ( 0 );
00135 }
00136 
00137 int 
00138 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
00139 {
00140        mutex_unlock( mutex );
00141        return ( 0 );
00142 }
00143 
00144 int
00145 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
00146 {
00147        return mutex_try_lock( mutex );
00148 }
00149 
00150 ldap_pvt_thread_t
00151 ldap_pvt_thread_self( void )
00152 {
00153        return cthread_self();
00154 }
00155 
00156 int
00157 ldap_pvt_thread_key_create( ldap_pvt_thread_key_t *key )
00158 {
00159        return cthread_keycreate( key );
00160 }
00161 
00162 int
00163 ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key )
00164 {
00165        return( 0 );
00166 }
00167 
00168 int
00169 ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key, void *data )
00170 {
00171        return cthread_setspecific( key, data );
00172 }
00173 
00174 int
00175 ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key, void **data )
00176 {
00177        return cthread_getspecific( key, data );
00178 }
00179 
00180 #endif /* HAVE_MACH_CTHREADS */