51#if !defined(_POSIX_C_SOURCE)
52#define _POSIX_C_SOURCE 200112L
55#if !defined(MBEDTLS_CONFIG_FILE)
58#include MBEDTLS_CONFIG_FILE
61#if defined(MBEDTLS_THREADING_C)
65#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
67#if !defined(_WIN32) && (defined(unix) || \
68 defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
74#if !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \
75 ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \
76 _POSIX_THREAD_SAFE_FUNCTIONS >= 200112L ) )
85#if ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) )
86#define THREADING_USE_GMTIME
95#if defined(MBEDTLS_THREADING_PTHREAD)
96static void threading_mutex_init_pthread( mbedtls_threading_mutex_t *
mutex )
110static void threading_mutex_free_pthread( mbedtls_threading_mutex_t *
mutex )
115 (
void) pthread_mutex_destroy( &
mutex->mutex );
119static int threading_mutex_lock_pthread( mbedtls_threading_mutex_t *
mutex )
124 if( pthread_mutex_lock( &
mutex->mutex ) != 0 )
130static int threading_mutex_unlock_pthread( mbedtls_threading_mutex_t *
mutex )
135 if( pthread_mutex_unlock( &
mutex->mutex ) != 0 )
141void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t * ) = threading_mutex_init_pthread;
142void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t * ) = threading_mutex_free_pthread;
143int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t * ) = threading_mutex_lock_pthread;
144int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t * ) = threading_mutex_unlock_pthread;
149#define MUTEX_INIT = { PTHREAD_MUTEX_INITIALIZER, 1 }
153#if defined(MBEDTLS_THREADING_ALT)
154static int threading_mutex_fail( mbedtls_threading_mutex_t *
mutex )
159static void threading_mutex_dummy( mbedtls_threading_mutex_t *
mutex )
165void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t * ) = threading_mutex_dummy;
166void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t * ) = threading_mutex_dummy;
167int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t * ) = threading_mutex_fail;
168int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t * ) = threading_mutex_fail;
173void mbedtls_threading_set_alt(
void (*
mutex_init)( mbedtls_threading_mutex_t * ),
174 void (*mutex_free)( mbedtls_threading_mutex_t * ),
175 int (*
mutex_lock)( mbedtls_threading_mutex_t * ),
179 mbedtls_mutex_free = mutex_free;
183#if defined(MBEDTLS_FS_IO)
184 mbedtls_mutex_init( &mbedtls_threading_readdir_mutex );
186#if defined(THREADING_USE_GMTIME)
187 mbedtls_mutex_init( &mbedtls_threading_gmtime_mutex );
194void mbedtls_threading_free_alt(
void )
196#if defined(MBEDTLS_FS_IO)
197 mbedtls_mutex_free( &mbedtls_threading_readdir_mutex );
199#if defined(THREADING_USE_GMTIME)
200 mbedtls_mutex_free( &mbedtls_threading_gmtime_mutex );
211#if defined(MBEDTLS_FS_IO)
212mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex MUTEX_INIT;
214#if defined(THREADING_USE_GMTIME)
215mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex MUTEX_INIT;
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Configuration options (set of defines)
Threading abstraction layer.
#define MBEDTLS_ERR_THREADING_MUTEX_ERROR
#define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA