26 #if !defined(POLARSSL_CONFIG_FILE)
29 #include POLARSSL_CONFIG_FILE
32 #if defined(POLARSSL_THREADING_C)
36 #if defined(POLARSSL_THREADING_PTHREAD)
37 static int threading_mutex_init_pthread( threading_mutex_t *mutex )
42 if( pthread_mutex_init( mutex, NULL ) != 0 )
48 static int threading_mutex_free_pthread( threading_mutex_t *mutex )
53 if( pthread_mutex_destroy( mutex ) != 0 )
59 static int threading_mutex_lock_pthread( threading_mutex_t *mutex )
64 if( pthread_mutex_lock( mutex ) != 0 )
70 static int threading_mutex_unlock_pthread( threading_mutex_t *mutex )
75 if( pthread_mutex_unlock( mutex ) != 0 )
81 int (*polarssl_mutex_init)( threading_mutex_t * ) = threading_mutex_init_pthread;
82 int (*polarssl_mutex_free)( threading_mutex_t * ) = threading_mutex_free_pthread;
83 int (*polarssl_mutex_lock)( threading_mutex_t * ) = threading_mutex_lock_pthread;
84 int (*polarssl_mutex_unlock)( threading_mutex_t * ) = threading_mutex_unlock_pthread;
87 #if defined(POLARSSL_THREADING_ALT)
88 static int threading_mutex_fail( threading_mutex_t *mutex )
94 int (*polarssl_mutex_init)( threading_mutex_t * ) = threading_mutex_fail;
95 int (*polarssl_mutex_free)( threading_mutex_t * ) = threading_mutex_fail;
96 int (*polarssl_mutex_lock)( threading_mutex_t * ) = threading_mutex_fail;
97 int (*polarssl_mutex_unlock)( threading_mutex_t * ) = threading_mutex_fail;
99 int threading_set_alt(
int (*mutex_init)( threading_mutex_t * ),
100 int (*mutex_free)( threading_mutex_t * ),
101 int (*mutex_lock)( threading_mutex_t * ),
102 int (*mutex_unlock)( threading_mutex_t * ) )