28 #if defined(POLARSSL_THREADING_C)
32 #if defined(POLARSSL_THREADING_DUMMY)
33 static int threading_mutex_init_dummy( threading_mutex_t *mutex )
39 static int threading_mutex_free_dummy( threading_mutex_t *mutex )
45 static int threading_mutex_lock_dummy( threading_mutex_t *mutex )
51 static int threading_mutex_unlock_dummy( threading_mutex_t *mutex )
57 int (*polarssl_mutex_init)( threading_mutex_t * ) = threading_mutex_init_dummy;
58 int (*polarssl_mutex_free)( threading_mutex_t * ) = threading_mutex_free_dummy;
59 int (*polarssl_mutex_lock)( threading_mutex_t * ) = threading_mutex_lock_dummy;
60 int (*polarssl_mutex_unlock)( threading_mutex_t * ) = threading_mutex_unlock_dummy;
63 #if defined(POLARSSL_THREADING_PTHREAD)
64 static int threading_mutex_init_pthread( threading_mutex_t *mutex )
69 if( pthread_mutex_init( mutex, NULL ) != 0 )
75 static int threading_mutex_free_pthread( threading_mutex_t *mutex )
80 if( pthread_mutex_destroy( mutex ) != 0 )
86 static int threading_mutex_lock_pthread( threading_mutex_t *mutex )
91 if( pthread_mutex_lock( mutex ) != 0 )
97 static int threading_mutex_unlock_pthread( threading_mutex_t *mutex )
102 if( pthread_mutex_unlock( mutex ) != 0 )
108 int (*polarssl_mutex_init)( threading_mutex_t * ) = threading_mutex_init_pthread;
109 int (*polarssl_mutex_free)( threading_mutex_t * ) = threading_mutex_free_pthread;
110 int (*polarssl_mutex_lock)( threading_mutex_t * ) = threading_mutex_lock_pthread;
111 int (*polarssl_mutex_unlock)( threading_mutex_t * ) = threading_mutex_unlock_pthread;
114 #if defined(POLARSSL_THREADING_ALT)
115 int (*polarssl_mutex_init)( threading_mutex_t * ) = NULL;
116 int (*polarssl_mutex_free)( threading_mutex_t * ) = NULL;
117 int (*polarssl_mutex_lock)( threading_mutex_t * ) = NULL;
118 int (*polarssl_mutex_unlock)( threading_mutex_t * ) = NULL;
120 int threading_set_alt(
int (*mutex_init)( threading_mutex_t * ),
121 int (*mutex_free)( threading_mutex_t * ),
122 int (*mutex_lock)( threading_mutex_t * ),
123 int (*mutex_unlock)( threading_mutex_t * ) )