threading.h

Go to the documentation of this file.
00001 
00023 #ifndef MBEDTLS_THREADING_H
00024 #define MBEDTLS_THREADING_H
00025 
00026 #if !defined(MBEDTLS_CONFIG_FILE)
00027 #include "config.h"
00028 #else
00029 #include MBEDTLS_CONFIG_FILE
00030 #endif
00031 
00032 #include <stdlib.h>
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 #define MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE         -0x001A  
00039 #define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA              -0x001C  
00040 #define MBEDTLS_ERR_THREADING_MUTEX_ERROR                 -0x001E  
00042 #if defined(MBEDTLS_THREADING_PTHREAD)
00043 #include <pthread.h>
00044 typedef struct
00045 {
00046     pthread_mutex_t mutex;
00047     char is_valid;
00048 } mbedtls_threading_mutex_t;
00049 #endif
00050 
00051 #if defined(MBEDTLS_THREADING_ALT)
00052 /* You should define the mbedtls_threading_mutex_t type in your header */
00053 #include "threading_alt.h"
00054 
00073 void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ),
00074                        void (*mutex_free)( mbedtls_threading_mutex_t * ),
00075                        int (*mutex_lock)( mbedtls_threading_mutex_t * ),
00076                        int (*mutex_unlock)( mbedtls_threading_mutex_t * ) );
00077 
00081 void mbedtls_threading_free_alt( void );
00082 #endif /* MBEDTLS_THREADING_ALT */
00083 
00084 #if defined(MBEDTLS_THREADING_C)
00085 /*
00086  * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
00087  *
00088  * All these functions are expected to work or the result will be undefined.
00089  */
00090 extern void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t *mutex );
00091 extern void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t *mutex );
00092 extern int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t *mutex );
00093 extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
00094 
00095 /*
00096  * Global mutexes
00097  */
00098 extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
00099 extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
00100 #endif /* MBEDTLS_THREADING_C */
00101 
00102 #ifdef __cplusplus
00103 }
00104 #endif
00105 
00106 #endif /* threading.h */

Generated on 11 Mar 2017 for mbed TLS v2.4.2 by  doxygen 1.4.7