mbed TLS v2.0.0
threading.h
Go to the documentation of this file.
1 
24 #ifndef MBEDTLS_THREADING_H
25 #define MBEDTLS_THREADING_H
26 
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32 
33 #include <stdlib.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A
40 #define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA -0x001C
41 #define MBEDTLS_ERR_THREADING_MUTEX_ERROR -0x001E
43 #if defined(MBEDTLS_THREADING_PTHREAD)
44 #include <pthread.h>
45 typedef struct
46 {
47  pthread_mutex_t mutex;
48  char is_valid;
49 } mbedtls_threading_mutex_t;
50 #endif
51 
52 #if defined(MBEDTLS_THREADING_ALT)
53 /* You should define the mbedtls_threading_mutex_t type in your header */
54 #include "threading_alt.h"
55 
74 void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ),
75  void (*mutex_free)( mbedtls_threading_mutex_t * ),
76  int (*mutex_lock)( mbedtls_threading_mutex_t * ),
77  int (*mutex_unlock)( mbedtls_threading_mutex_t * ) );
78 
82 void mbedtls_threading_free_alt( void );
83 #endif /* MBEDTLS_THREADING_ALT */
84 
85 /*
86  * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
87  *
88  * All these functions are expected to work or the result will be undefined.
89  */
90 extern void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t *mutex );
91 extern void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t *mutex );
92 extern int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t *mutex );
93 extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
94 
95 /*
96  * Global mutexes
97  */
98 extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
99 extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* threading.h */
mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex
Compatibility names (set of defines)
mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex
int(* mbedtls_mutex_unlock)(mbedtls_threading_mutex_t *mutex)
void(* mbedtls_mutex_free)(mbedtls_threading_mutex_t *mutex)
void(* mbedtls_mutex_init)(mbedtls_threading_mutex_t *mutex)
int(* mbedtls_mutex_lock)(mbedtls_threading_mutex_t *mutex)