2 * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
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.
11 /* thr_thr.c - wrappers around solaris threads */
15 #if defined( HAVE_GNU_PTH )
17 #include "ldap_pvt_thread.h"
25 static pth_attr_t detach_attr;
28 ldap_pvt_thread_initialize( void )
30 detach_attr = pth_attr_new();
31 pth_attr_set( detach_attr, PTH_ATTR_JOINABLE, FALSE );
36 ldap_pvt_thread_destroy( void )
38 pth_attr_destroy(detach_attr);
44 ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
46 void *(*start_routine)( void *),
49 *thread = pth_spawn( detach ? detach_attr : PTH_ATTR_DEFAULT,
52 return *thread == NULL;
56 ldap_pvt_thread_exit( void *retval )
61 int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
63 pth_join( thread, thread_return );
68 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
70 pth_raise( thread, signo );
75 ldap_pvt_thread_yield( void )
82 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
84 return( pth_cond_init( cond ) );
88 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
90 return( pth_cond_notify( cond, 0 ) );
94 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
96 return( pth_cond_notify( cond, 1 ) );
100 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
101 ldap_pvt_thread_mutex_t *mutex )
103 return( pth_cond_await( cond, mutex, NULL ) );
107 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
113 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
115 return( pth_mutex_init( mutex ) );
119 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
125 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
127 return( pth_mutex_acquire( mutex, 0, NULL ) );
131 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
133 return( pth_mutex_release( mutex ) );
137 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
139 return( pth_mutex_acquire( mutex, 1, NULL ) );
142 #endif /* HAVE_GNU_PTH */